February 5, 2008 at 3:15 am
Please help me get the insert scripts for all the user tables in a database.
"More Green More Oxygen !! Plant a tree today"
February 5, 2008 at 6:28 am
To do that automatically you can either buy a tool like Embarcadero Rapid SQL that will do it for you, write a program using SMO to walk each table generating the script, or try writing a series of cursors in TSQL to generate the scripts. There are a bunch of scripts already built in the Scripts section of this site (see the "Scripts" on the left) that do this. Here's one example[/url] (first one I saw, there are others).
For one-off scripts, simply right click the table when in SSMS and select "Script Table as" then "INSERT To" to generate a script.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
February 5, 2008 at 7:11 am
SQL Scripter is a free tool to dynamically create INSERT scripts. It works fast and well.
February 5, 2008 at 12:42 pm
you can get SSMS to script them all by using the Generate scripts option under "all tasks". Simply right-click on the DB name to get started.
----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
February 6, 2008 at 4:14 am
Thanks to all of you. I got the script from SQL Servercentral scripts and it worked perfectly.
😀
"More Green More Oxygen !! Plant a tree today"
February 6, 2008 at 2:38 pm
Hi,
Check out the belwo link
http://mallier.blogspot.com/2006/10/generate-insert-statement-in-sql-server.html
Thanks -- Vj
May 5, 2008 at 3:16 pm
Is there a way to generate select, insert, drop, update scripts in SMO ?. I know that "create script" can be generated in couple lines ..
Dim tr As Table = server.Databases("db").Tables("tbl", "dbo")
For Each st As String In tr.Script()
File.AppendAllText("C:\auto.txt", st & ControlChars.NewLine)
Next
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply