Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

Generate Insert Statements Easily - Updated

By bakk, 2005/06/01

This script will generate insert statements for the given tables. You can pass the tables names, separated by commas, into sp_DataAsInsCommand stored procedure as in the example below:

EXEC sp_DataAsInsCommand 'employee,titleauthor,pub_info'

Updated on 5/25/01 to correct an issue with columns that are short like a column defined as char(1), to correct another issue with the Identity column (before you had to supply a list of columns in the insert statement), and to add the following two changes: 1) to print the name of the table in a comment before the insert commands, and 2) to expand the size of the parameter so a larger list of tables could be submitted to the stored procedure.

Updated on 5/5/05 to make it working again.

Total article views: 297 | Views in the last 30 days: 3
 
Related Articles
FORUM

insert special char to column

insert special char to column

FORUM

Inserting zero in Identity Column

Inserting zero in Identity Column

FORUM

Add RowID Column to Bulk Insert

Add RowID Column to Bulk Insert

FORUM

Zero being inserted in identity column

Zero being inserted in identity column

FORUM
Tags
t-sql    
 
Contribute

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones