March 14, 2012 at 8:22 am
Hi,
I want to move data from one node to another. Data is corrupted by developers , so I can't move all.
I want to know that is there a way exist in SSMS, where I can pass criteria on a table and get insert script on that?
March 14, 2012 at 8:26 am
thbaig1 (3/14/2012)
Hi,I want to move data from one node to another. Data is corrupted by developers , so I can't move all.
I want to know that is there a way exist in SSMS, where I can pass criteria on a table and get insert script on that?
??
insert DestinationTable ([columns])
select [columns]
from SourceTable
where [critera]
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
March 14, 2012 at 8:28 am
you could build a string up which concatinates an insert script together, the below code will give you a starting point, just need to put in the where clause to filter out the data you dont need.
SELECT
'INSERT INTO table1 (Col1, Col2, Col3) VALUES ('+
Col1,+
','+
Col2+
','+
Col3+
');'
FROM
table1
WHERE
Col1 = Avalue
March 22, 2012 at 1:58 pm
The SSMS Tools Pack has a built-in feature to help you generate INSERT statements from a table, or even from a specific query...very handy.
SSMS Tools Pack > Generate Insert statements from resultsets, tables or databases
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
March 23, 2012 at 6:56 am
opc.three (3/22/2012)
The SSMS Tools Pack has a built-in feature to help you generate INSERT statements from a table, or even from a specific query...very handy.SSMS Tools Pack > Generate Insert statements from resultsets, tables or databases
+1 on SSMSTP!! Also, vyas kondredi has a script you can use: http://vyaskn.tripod.com/code.htm Lots of good stuff there.
Best,
Kevin G. Boles
SQL Server Consultant
SQL MVP 2007-2012
TheSQLGuru on googles mail service
March 23, 2012 at 7:06 am
hadn't heard of that tool pack until this topic, must say looks great
March 23, 2012 at 4:13 pm
TheSQLGuru (3/23/2012)
opc.three (3/22/2012)
The SSMS Tools Pack has a built-in feature to help you generate INSERT statements from a table, or even from a specific query...very handy.SSMS Tools Pack > Generate Insert statements from resultsets, tables or databases
+1 on SSMSTP!! Also, vyas kondredi has a script you can use: http://vyaskn.tripod.com/code.htm Lots of good stuff there.
Thanks, Kevin. I had not run across these until now. Some of the scripts look very useful.
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
June 1, 2012 at 10:54 am
thank you opc.three. it is a great tool 🙂
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply