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.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2006-01-13 : 08:45:59
|
| GunaSekaran.P writes "You can Just Run this below script in sql 2000By Giving any table NameI am inserting into to the table #tt but i coudnt ablt to select from the table Note I am not using any Create table Statement for creating of tableCan i know how i can do this , if this is not possible let me know the reason.declare @st varchar(2000)declare @strSql nvarchar(2000)set @st='select * 'set @strSql= @st +'into #tt from tablename'print @strSqlExec sp_Executesql @strSqlselect * from #ttdrop table #tt" |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-01-13 : 09:05:24
|
| it is out of scope. Change to use global temp table ##tt-----------------'KH'if you can't beat them, have someone else to beat them |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-01-13 : 09:05:35
|
| It losts its scope after Exec statementYou need to use them in the same blockset @st='select * 'set @strSql= @st +'into #tt from tablename select * from #tt'print @strSqlExec sp_Executesql @strSqlWhy are you using Dynamic SQL?MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|