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)
 Script database, incl. data...?

Author  Topic 

dhw
Constraint Violating Yak Guru

332 Posts

Posted - 2002-11-26 : 17:40:32
I see that through enterprise manager I can generate a sql script for my entire database. I can run this script via oSQL or the query analyzer....that is good. But I would also like the script to generate the INSERT statements for the data in some of my tables. Is there anyway to accomplish this?

Thanks....

VyasKN
SQL Server MVP & SQLTeam MVY

313 Posts

Posted - 2002-11-26 : 18:27:04
Try my stored procedure sp_generate_inserts. It is a general purpose stored procedure and scripts data from existing tables, in the form of INSERT statements. Code and documentation available at: http://vyaskn.tripod.com/code.htm#inserts

--
HTH,
Vyas
http://vyaskn.tripod.com
Go to Top of Page

ValterBorges
Master Smack Fu Yak Hacker

1429 Posts

Posted - 2002-11-26 : 18:56:09
If there is lots of data and restore time is an issue then you might be better off outputting the data to a file and then writting the script to bulk insert the data.



Go to Top of Page

dhw
Constraint Violating Yak Guru

332 Posts

Posted - 2002-11-27 : 10:49:51
Thanks to both of you. I will check out the SP and also look at the idea of exporting and then adding a bulk insert into a script.



Go to Top of Page

1fred
Posting Yak Master

158 Posts

Posted - 2002-11-27 : 11:54:03
I Have tried your SP, and it seems to have problem with the Text datatype. It only takes the 256 first character of my field of Text datatype. When it encounter a text datatype, the results are cut after the 256 character, even if I have other fields after this one. Everything else seems very fine, I made a kind of similar prog in VB but it is 5 times slower!

Go to Top of Page

VyasKN
SQL Server MVP & SQLTeam MVY

313 Posts

Posted - 2002-11-27 : 11:57:51
Make sure your Query Analyzer is set to output upto 8192 characters ( http://vyaskn.tripod.com/sql_server_tools_faq.htm#q1 ).

My procedure is supposed to get the first 8000 characters of text columns.

--
HTH,
Vyas
http://vyaskn.tripod.com
Go to Top of Page

chadmat
The Chadinator

1974 Posts

Posted - 2003-04-23 : 00:43:58
You could also try the free SQLDataScripter utility available at [url]http://www.clrsoft.com[/url]

-Chad

http://www.clrsoft.com

Software built for the Common Language Runtime.
Go to Top of Page
   

- Advertisement -