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 |
|
aravindt77
Posting Yak Master
120 Posts |
Posted - 2007-12-24 : 00:59:42
|
| Hi All,The statement which i run is as follows :_--------------------DECLARE @sql NVARCHAR(1000)SET @sql='SELECT 1 AS Col1 INTO #Tabl1'EXECUTE (@SQL)SELECT * FROM #Tabl1---------------------The output which I got is as folllows :------------------------(1 row(s) affected)Msg 208, Level 16, State 0, Line 5Invalid object name '#tabl1'.-----------------------Can anyone help me in resolving this situation !!!!!Thanks & RegardsAravind |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-12-24 : 02:02:38
|
| Why do you need dynamic sql?SELECT 1 AS Col1 INTO #Tabl1SELECT * FROM #Tabl1MadhivananFailing to plan is Planning to fail |
 |
|
|
aravindt77
Posting Yak Master
120 Posts |
Posted - 2007-12-24 : 05:43:25
|
quote: Originally posted by madhivanan Why do you need dynamic sql?SELECT 1 AS Col1 INTO #Tabl1SELECT * FROM #Tabl1MadhivananFailing to plan is Planning to fail
I have use these statments inside a SP which s implemented to arrive a dynamic search functionality ..so that we cant predict the columns at desing time.. Hope u get me |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-12-24 : 05:48:22
|
| You can't refer local temp table created inside an EXEC statement. Only other way is to use global temp table (##tabl1).Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-12-24 : 07:14:13
|
quote: Originally posted by aravindt77
quote: Originally posted by madhivanan Why do you need dynamic sql?SELECT 1 AS Col1 INTO #Tabl1SELECT * FROM #Tabl1MadhivananFailing to plan is Planning to fail
I have use these statments inside a SP which s implemented to arrive a dynamic search functionality ..so that we cant predict the columns at desing time.. Hope u get me
Refer thishttp://www.sommarskog.se/dyn-search.htmlMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|