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 2008 Forums
 Transact-SQL (2008)
 output table content in text

Author  Topic 

jeff06
Posting Yak Master

166 Posts

Posted - 2012-04-05 : 11:18:23
I have a table t1
id name
1 john
2 tim
3 jane
4 foo
....
I want to move t1 to another sever in a stupid way. I need to
generate following text from t1

insert into #t1 values(1,'john');
insert into #t1 values(2,'tim');
insert into #t1 values(3,'jone');
insert into #t1 values(4,'foo');
....
How can I do that?
Thanks,
Jeff

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2012-04-05 : 11:26:08
[CODE]select
N'select into #t values(' + cast(id as nvarchar(10)) + N', ''' + name + ''');' SqlStmt
from t1[/CODE]

=================================================
There is a foolish corner in the brain of the wisest man. -Aristotle, philosopher (384-322 BCE)
Go to Top of Page
   

- Advertisement -