Solved

generate insert statement with data dynamically

Posted on 2008-06-25
1
197 Views
Last Modified: 2010-03-19
I have a table:A  that has 50 rows...

Id   code number
12   A      789
13   B      767
34   T      890
--- etc


I am trying to generate  50 insert statements with data in that table dynamically without typing 50 insert statement with data...

insert into test ( ID, code, number) values ( 12,'A', 787)
-- etc



How can i do this?
0
Comment
Question by:jung1975
1 Comment
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 500 total points
ID: 21867080
Hello jung1975,

SELECT 'Insert into test (id, code,number)  select '+ CAST(id AS varchar) +' , ''' +code+''','+ CAST (number AS varchar)
FROM urTable

GOD BLESS,

Aneesh R.
0

Featured Post

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Join & Write a Comment

Recently, when I was asked to create a new SQL 2005 cluster, Microsoft released a new service pack for MS SQL 2005 what is Service Pack 3. When I finished the installation of MS SQL 2005 I found myself troubled why the installation of SP3 failed …
In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now