April 11, 2013 at 12:34 am
Hi,
I can use GUI of the MS to script out data from a table. Is this possible using either Powershell or TSQL?
Thanks.
April 11, 2013 at 5:58 am
i just found this for powershell:
for doing it via TSQL, i've used a script by Narayana Vyas Kondreddi for years and years:
http://vyaskn.tripod.com/code.htm#inserts
there's a few parameters that need to be changed to varchar(max) if you trip over some errors, but it's a really great effort.
Lowell
April 12, 2013 at 1:20 pm
Hi There,
I usually do not promote products; However, red gates source control software plug in allows you to save data into SVN. This data then can be restored with the schema to another database.
If you do not have the money to spend, BCP the data out/in using your favorite text format. Check out my blog showing how to do this.
Microsoft even does this with the Adventure Works install script using a CSV format. I like a tilda ~ or fixed format since tabs do occur in unclean data.
BULK INSERT [Person].[ContactType] FROM '$(SqlSamplesSourceDataPath)ContactType.csv'
WITH (
CHECK_CONSTRAINTS,
CODEPAGE='ACP',
DATAFILETYPE='char',
FIELDTERMINATOR='\t',
ROWTERMINATOR='',
KEEPIDENTITY,
TABLOCK
);
Good luck
John
John Miner
Crafty DBA
www.craftydba.com
April 12, 2013 at 1:23 pm
A couple more ideas.
1 - When I was doing Oracle work in a past life, the TOAD utility had the ability to turn a record set in a data grid to a bunch of SQL INSERT statements.
This is definitely slower than BCP.
2 - Use the import export utility, which is a wizard utility tool, to create and run a simple SSIS package. This uses bulk copy operation under the hood.
Many other ways can be listed, but the import/export and bcp utilities come installed out of the box.
John Miner
Crafty DBA
www.craftydba.com
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply