SQL Server Central is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
Search:  
 
 

Generate Insert Statements Easily

By Alexander Chigrik, 2001/08/09

Total article views: 2684 | Views in the last 30 days: 108

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.

By Alexander Chigrik, 2001/08/09

Total article views: 2684 | Views in the last 30 days: 108
Your response
 
 
Related tags

T-SQL Aids    
 
Like this? Try these...

DBxtra Discount

By Press Release | Category: Product News
(not yet rated) | 2,759 reads
Already registered?  

Free registration required

To read the rest of this article, and access thousands of other articles, we ask you to register on the site and subscribe to our newsletters.

Register

E-mail address:
Password:
Password (confirm):

  

Subscriptions

We ask you to register on the site and subscribe to our newsletters. Subscribing to our newsletters gets you:

  • ALL of our content (thousands of articles, scripts, and forum postings)
  • A daily newsletter (example)
  • A weekly news round up (example)
  • The opportunity to ask and answer questions in our forums
  • A daily Question of the Day to test and help you increase your knowledge of SQL Server.

We ask that you give the newsletter a try for a week. Over 200,000 SQL Server Professionals a day find it entertaining and useful. If not, you are welcome to unsubscribe at anytime.

Steve Jones
Editor, SQLServerCentral.com