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
 General SQL Server Forums
 New to SQL Server Programming
 Script Row

Author  Topic 

arusu
Yak Posting Veteran

60 Posts

Posted - 2011-12-07 : 15:35:21
Hi,

I was just wondering if SQL Server 2008 has a way of generating a script for an existing row. So say I have a Customer table.

FirstName: John
LastName: Doe
SalesId: 5

Can I have the first row generated as a script so that I would get:

INSERT INTO
Customer (FirstName, LastName, SalesId)
VALUES
('John', 'Doe', 5)

I would be ok to get all the rows scripted but I need to know if I can do this

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-12-07 : 15:37:59
You can use this generator: http://vyaskn.tripod.com/code/generate_inserts.txt

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

arusu
Yak Posting Veteran

60 Posts

Posted - 2011-12-07 : 15:48:33
I don't understand this.... I am very new to sql
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-12-07 : 15:57:58
It's a stored procedure that generates insert statements for a particular object. Run the code in the link to add the stored procedure and then execute the stored procedure while passing in the appropriate values to the input parameters. There are examples in the comment header block of the code.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

arusu
Yak Posting Veteran

60 Posts

Posted - 2011-12-07 : 16:32:19
If anyone else needs to know how to do this, I've found an easier way

go to

C:\Program Files\Microsoft SQL Server\90\Tools\Publishing\1.2
and use the SqlPubWiz.exe tool. It's a wizard, it's very straight forward and it gets the job done plus it scripts out your table for you as well if you need it.
Go to Top of Page
   

- Advertisement -