Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2005
»
T-SQL (SS2K5)
»
Generate Insert script
Generate Insert script
Rate Topic
Display Mode
Topic Options
Author
Message
toprprasad
toprprasad
Posted Wednesday, August 06, 2008 2:37 AM
Forum Newbie
Group: General Forum Members
Last Login: Tuesday, September 16, 2008 3:11 AM
Points: 5,
Visits: 13
Hi...
I need a script which can generate insert statements for all the records in a table.
for eg: if a table abc has 2 records, then on executing this script, it should generate 2 insert statements with column names and values.
thx
raj
Post #547323
Abhijit More
Abhijit More
Posted Wednesday, August 06, 2008 2:42 AM
SSC Eights!
Group: General Forum Members
Last Login: Thursday, May 16, 2013 8:06 AM
Points: 900,
Visits: 654
There may be the possibilities that table either contains Primary / Identity Field or may not contains any ke, so in that case how do you insert the record ?
Abhijit - http://abhijitmore.wordpress.com
Post #547325
toprprasad
toprprasad
Posted Wednesday, August 06, 2008 2:54 AM
Forum Newbie
Group: General Forum Members
Last Login: Tuesday, September 16, 2008 3:11 AM
Points: 5,
Visits: 13
That doesnot matter... Ultimately , i need insert statement for each record in the table.
Post #547334
Anders Pedersen
Anders Pedersen
Posted Wednesday, August 06, 2008 8:23 AM
Ten Centuries
Group: General Forum Members
Last Login: Friday, May 17, 2013 7:07 AM
Points: 1,195,
Visits: 638
I'm lazy, I use ApexSQL Edit.... =)
Post #547553
Jeff Moden
Jeff Moden
Posted Wednesday, August 06, 2008 8:34 AM
SSC-Dedicated
Group: General Forum Members
Last Login: Yesterday @ 5:33 PM
Points: 32,902,
Visits: 26,783
toprprasad (8/6/2008)
Hi...
I need a script which can generate insert statements for all the records in a table.
for eg: if a table abc has 2 records, then on executing this script, it should generate 2 insert statements with column names and values.
thx
raj
See the method in the link in my signature below.
--Jeff Moden
"
RBAR
is pronounced "ree-bar" and is a "Modenism" for "
R
ow-
B
y-
A
gonizing-
R
ow".
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Post #547563
Tony Webster
Tony Webster
Posted Friday, May 14, 2010 2:41 AM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Thursday, June 14, 2012 11:40 PM
Points: 115,
Visits: 299
In case you miss is, article
Generating Insert Statements
is republished today.
Also, there is my own article,
Scripting INSERTs
, which is intended to do address a slight different issue - where you want to script individual bits of tables, perhaps subject to conditions on the records - and also you can edit the script more easily if you aren't just looking for a straight copy. It doesn't support some of the more exotic datatypes though.
I think both are subject to the provisos about IDENTITY fields etc, although I guess if you can just turn IDENTITY_INSERT on for the table in that particular case.
Tony
Post #921832
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.