Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 generate text from table.

Author  Topic 

jeff06
Posting Yak Master

166 Posts

Posted - 2008-09-04 : 11:32:08
I have table have two colum id and date.
id date
482157482 03/01/2007
504742902 03/01/2007
478200842 03/04/2007
----


I want to generate following text string from the table

insert into #mkseg values ('482157482','03/01/2007')
insert into #mkseg values ('504742902','03/01/2007')
insert into #mkseg values ('478200842','03/04/2007')
----
how can I do that?
Thanks.
Jeff

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-09-04 : 11:37:14
[code]SELECT 'INSERT INTO #mkSeg VALUES (' + CAST(ID AS VARCHAR(11)) + ', ''' + CONVERT(CHAR(10), Date, 101) + ''')'
FROM #mkSeg[/code]


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -