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.
| Author |
Topic |
|
zion99
Posting Yak Master
141 Posts |
Posted - 2008-11-12 : 15:01:16
|
| Hi,From the available data in a table, is it possible to create insert data scripts for all the rows?there is an export data functionality available in sql 2005 but i want to give the generated scripts to another person who can just run these scripts & have the data populated in his DB. |
|
|
safderalimd
Starting Member
32 Posts |
Posted - 2008-11-12 : 15:55:47
|
| Here is how you do it..........create table #temp(col1 int, col2 varchar(5))insert into #temp values(1, 'emp')insert into #temp values(1, 'cons')select 'insert into new_table_name values(' + convert(varchar(5),col1) + ','+''''+col2+''')' from #tempCopy result set from above slect into seperate file and use it as DML scriptinsert into new_table_name values(1,'emp')insert into new_table_name values(1,'cons') |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2008-11-12 : 17:01:37
|
| you can also use the SSMS Tools Pack add-in in my signature. You can generate insert scripts for one or more tables or for the entore database._______________________________________________Causing trouble since 1980Blog: http://weblogs.sqlteam.com/mladenpSpeed up SSMS development: www.ssmstoolspack.com <- version 1.1 out! |
 |
|
|
zion99
Posting Yak Master
141 Posts |
Posted - 2008-11-13 : 05:19:33
|
quote: Originally posted by safderalimd Here is how you do it..........create table #temp(col1 int, col2 varchar(5))insert into #temp values(1, 'emp')insert into #temp values(1, 'cons')select 'insert into new_table_name values(' + convert(varchar(5),col1) + ','+''''+col2+''')' from #tempCopy result set from above slect into seperate file and use it as DML scriptinsert into new_table_name values(1,'emp')insert into new_table_name values(1,'cons')
thanks, but even in this scenario, i still need to manually write insert query for the temp table which i dont want to do. |
 |
|
|
|
|
|
|
|