I need to automate creation of INSERT scripts in order to generate test data. SSMS will generate the scripts, but requires interactive finger/button pushing. Is there any way to automate this?
Yes, after the INSERT scripts get created, they will require some sed/awk/regex manipulation which is clearly automatable.
Related
Is there a way to generate Table/View scripts and save to a directory using Stored Procedure?
I've a list of all tables/views from different databases that I need to generate but it's in the thousands and doing the task > generate scripts... for each database is very tedious.
I've been looking into Stored Procedures if it is possible to create a script that would create and save all SQL Script using a List but still haven't found any existing samples.
I found a wonderful script that collects all the (shared) datasources used on a reportserver:
LINK
I simply love this script.
However, I am looking for a way to execute this script on several reportservers and add the results to a centralised table. That way my colleagues and me would be able to see pretty quickly what datasources are used.
I could place this script on each reportserver, collect the csv's on a central server and then use SSIS to insert them into a MSSQL table. That way I would have a nice central overview of all the used datasources.
However, I would prefer to have the script in one location and then execute that script on a list of servers.
Something like:
Loop through table with servers
execute script (see link)
insert resulting csv into central table (preferably skip this step, have script insert data in table directly)
next server
Any suggestions as to what the best approach would be? Should it be a webservicetask? Scripttask?
Something else completeley?
The level of scripting in the mentioned script is right at the edge of what I understand, so if someone would know how to adapt the script in such a way that I could use it as input in a dataflow in SSIS I would be very happy.
Thanks for thinking with me,
Henro
This script is called using a utility called rs.exe so you would use an execute process task to call it. To avoid writing to a file, you could modify the script and have it insert the results into a table. The package could be set up as follows:
Create a foreach loop which iterates over a list or ado.net recordset of your servers
Put the server name in a variable
Create a variable for the arguments for the process task, referencing the server variable from step 2
Add a process task which uses the above argument and calls rs.exe
I need to create a copy of all of our production databases (SQLServer), without any data.
I need to do this on a regular basis, preferably scheduled and not manually.
Do I have to write code that extracts from systables and builds whe SQL-statements itself or is there a good way to do this?
As there is a method to do that in SQL Management Studio:
Select a database
right click
tasks
generate script
etc ...
You can then save the script generated as an sql file.
Once the script set, and if it is T-SQL, you can just add it to the jobs of your server. .And if you have only a SQL EXPRESS server (with no job schedule), I remember it was possible, a few years ago, to find some free products on the net that would do the job.
Anyone knows how to perform inline loading into SQL server, I have DsGen software provided by TCP council, it generates data files have the extension .dat. Is there any mechanism to load these files directly to SQL database (during the generation period). I have done that using import/export wizard, but that is not inline loading.
There are several ways to accomplish your task, here are two of them.
You may use the BULK INSERT command to import them. Basically, what the import wizzard does is about the same, but it let's you select the various options using a nifty GUI.
You can save the DTS package when running through the wizzard, create a SQL Server Agent job and execute this job using the sp_start_job stored procedure.
I like the BULK INSERT as it it easier to implement. Just play arround with the options until you get what you want.
I was wondering if anyone knew how to reverse engineer an Access Database. I would like to be able to generate the SQL code that is used to create the database tables and to insert all the records in the table. In other words, I would like to create whats is similar to a MySQL dump file.
Any ideas would be great
thanks
jason
There's nothing built into Access that will generate the DDL for your tables.
There are many third party tools however (ERWin, ERStudio, Visio, etc) that can generate the DDL for you.
I don't know anything that will generate the Insert scripts for you. Access does however have plenty of export/import options if you just want to create a copy of your data and then use that as an import source.
It should be pointed out that there's nothing stopping you from writing some VBA code to loop through the TableDefs and creating the DDL and insert scripts yourself.
One possible approach that may work, is to upsize your tables to SQL server, and then have SQL server generate scripts for you.
Unfortunately the resulting scripts would probably be only compatible with SQL server. So then you would have to run them on SQL server and then pull the data in tables down to access.
Access does support DDL, but unfortunately it does not have any tools are facilities built in to generate the scripts.