SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Generate instert script for data with a twist
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

dkekesi
Starting Member

Hungary
38 Posts

Posted - 12/12/2012 :  04:48:58  Show Profile  Reply with Quote
Hi All,

I need to generate data insert scripts for tables in a database but only for tables whose name begin with 'Enum'. I have hundreds of tables full of data, but only about a dozen Enum tables that contain static data, hence I want to filter for the name.

Any type of solution is OK with me using CLR, TSQL, C#.

Thanks a lot in advance.

Best Regards,
Daniel

nigelrivett
Flowing Fount of Yak Knowledge

United Kingdom
3383 Posts

Posted - 12/12/2012 :  05:04:41  Show Profile  Visit nigelrivett's Homepage  Reply with Quote
This is an sp which takes a table name and creates insert statements for the data.
http://www.nigelrivett.net/SQLTsql/sp_CreateDataLoadScript.html
It's very old so may need some tweaking for current versions.


Create a temp table and populate it with the names of tables you require.
Loop through that calling the above sp for each table.
You can insert the output of the sp into a temp table if you want to concatenate all the rows.

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

dkekesi
Starting Member

Hungary
38 Posts

Posted - 12/12/2012 :  12:36:36  Show Profile  Reply with Quote
quote:
Originally posted by nigelrivett
This is an sp which takes a table name and creates insert statements for the data.
http://www.nigelrivett.net/SQLTsql/sp_CreateDataLoadScript.html
It's very old so may need some tweaking for current versions.


Thanks for the help. I ended up using this script here:
http://stackoverflow.com/questions/11001828/restore-to-remote-database-from-my-local-machine
It has a lot of features and handles most data types really well.
Thanks for your time, anyway.

Best Regards,
Daniel
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000