Bangladesh Microsoft Technology Community

Come, let's share our idea, opinion, experience & knowledge with each other
Welcome to Bangladesh Microsoft Technology Community Sign in | Join | Help
in Search

Visual C# Developers

Generate insert statements for a table

As professional software developers, we often face a situation where a desparate need of the SQL statement "insert into TableA values..." arises for tests & reviews and due to time constraint, it seems pretty difficult to migrate data from SQL Express to SQL 2000, etc. using a sql script.

Today I was doing a search on the web on a different keyword and accidentally got hold of a SQL statement showing how to generate insert statements for a table in your database. My bitter experience with migrating data from one version to another sparked back with the same feeling of bitterness. So, without any delay, I fired up my SQL Management Studio and copy/pasted the sql statement and hit execute button.

No! It's not working!! Incorrect syntax error!!! Embarrased and keeping the idea of just found statement, I developed my own in no time. Here it is for you to share with:

SQL

SELECT 'insert into TABLENAME values (' + cast(ID as varchar) +

',' + cast(VERSEID as varchar) + ',''' + POEM + ''');' 
AS INSERT_STAEMENTS
FROM SOMETABLE;
 
 
 
Published Thursday, April 10, 2008 4:11 AM by hamid

Comments

No Comments
Anonymous comments are disabled

This Blog

Post Calendar

<April 2008>
SuMoTuWeThFrSa
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910

Syndication

Powered by Community Server, by Telligent Systems