Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Import/Export (DTS) and Replication (2000)
 database sql script generation

Author  Topic 

daemon
Starting Member

2 Posts

Posted - 2004-04-29 : 13:47:57
Hi,

what is the best tool for generating an sql script for all the database objects and data. the one in enterprise manager doesn't generate the sql for the data. I want to benefit from your experience.

Thanx

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-04-29 : 14:05:25
Why do you want to generate the code for the data?

I've used this before for table lookup data:

http://vyaskn.tripod.com/code.htm#inserts

For all other data, I bcp the data out into text files using bcp.exe. I then bcp the data in from the text files using the same tool. bcp.exe is a command line tool. You can also use DTS.

Tara
Go to Top of Page

daemon
Starting Member

2 Posts

Posted - 2004-04-29 : 14:27:09
I want to generate the code because im developing a web application and i want the users to use the sql file to generate the database with all it's default data.

now im not very falmiliar with bcp can you explain what it is please and also what is DTS?

thank you
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-04-29 : 14:32:24
Do you have SQL Server Books Online? If so, look up bcp utility, go to the overview topic. Also, look up DTS, go to the overview topic. Both tools allow you to import/export data into text files. DTS allows you to do a lot more, but for what you are trying to do, bcp is the way to go. The link that I provided will do what you want but it will be much much slower than bcp.

Both tools are fairly easy to use once you understand what their purpose is and how to use them. DTS is often viewed as the easier tool since it has a GUI, but that doesn't mean that DTS should be used instead of bcp.

Tara
Go to Top of Page

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2004-04-29 : 21:08:37
Also, take a look at SQL Data Scripter from http://www.clrsoft.com/ if you want a GUI to generate INSERT statements



Damian
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2004-04-30 : 01:42:31
http://www.nigelrivett.net/DMOScriptAllDatabases.html
Will script the objects - you might find it easier in vbscript in a dts package, I'll post that versio when I get round to it.

For insert scripts
http://www.nigelrivett.net/sp_CreateDataLoadScript.html
May need tweaking depending on your data - I built it for a specific requirement.

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

tommyonline
Starting Member

3 Posts

Posted - 2004-06-02 : 06:07:02
Try [url]http://www.sqlscripter.com[/url],
this tool is able to create Insert, Update and Delete Scripts.
Easy to use (GUI) and free.
Go to Top of Page
   

- Advertisement -