Solved

generate insert statement with data dynamically

Posted on 2008-06-25
1
199 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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing XML code a very difficult part is when we like to remove all the elements or attributes from the XML that have no data. I would like to share a set of recursive MSSQL stored procedures that I have made to remove those elements from …
Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

808 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