Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select into textstring table

Status
Not open for further replies.

inhisglory

Programmer
Jul 8, 2001
10
ID
Hi, I want to save my select result into a dynamic name table.
Any one can help me...
Thank You
Yahya
 
what you have to do is using a dianamic sql.
its simple.
e.g. we have a table t1 with whatever columns it has.
declare @strSql varchar(1000)--whatever size you feel suitable
declare @tName varchar(100)
set @tName='d1' --here I assign it you may pass it as parameter to a sp where you do this whole code
set @strSql='select * into '+@tName+' from t1' -- construct the sql and then
execute(@strSql) --execute it
here I use select into; for this you must set selectinto/bulkcopy option to true in database options
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top