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;
     
     
     

This Blog

Post Calendar

<January 2009>
SuMoTuWeThFrSa
28293031123
45678910
11121314151617
18192021222324
25262728293031
1234567

Syndication

Powered by Community Server, by Telligent Systems