July 29, 2008 at 4:41 am
hi
I want to generate a script,should contains both the structure and the data existing in the database.Is ii available in sql server 2005
thanks in advance ?
July 30, 2008 at 1:34 am
For my knowledge there is no complete scripting available for what you want to do.
You can easily generate a script to create your tables and even the database (right click from SSMS). But there is no script to generate the contents of the table.
You could create something yourself with a little querying.
It should look like this (for a table with a numeric first column and a char second column):
select
'INSERT INTO Table (column1, column2) VALUES (' + Cast(column1 AS char(10)) + ', ''' + column2 ''')' AS InsertString
from [Table]
The code above creates all INSERT commands necassary to put the contents in the table. Export the results to a textfile and execute this on another server.
July 30, 2008 at 1:36 am
But maybe it is more easy to use a backup-restore procedure to create and fill a database.
Can you clearify why you want/need to script it?
July 30, 2008 at 4:23 am
Getting a backup of the existing and restoring is the best procedure to achieve your task.
Venkatesan Prabu .J
http://venkattechnicalblog.blogspot.com/
Thanks and Regards,
Venkatesan Prabu, 😛
My Blog:
http://venkattechnicalblog.blogspot.com/
July 30, 2008 at 4:56 am
In addition to my first post in this topic:
Someone allready created a SP (SP_Generate_Inserts) to script the contents of a table to INSERT commands. Look at this url: http://vyaskn.tripod.com/code/generate_inserts_2005.txt
July 31, 2008 at 10:33 am
have a look at the SQL Tool belt from redgate as well. One of the tools in there is just doing this. There is a 30 day trial available.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply