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 |
|
mavershang
Posting Yak Master
111 Posts |
Posted - 2009-05-21 : 13:36:02
|
| Hi there, I have a problem with exec sp_executesql output tablefor example,declare @sql nvarchar(4000)declare @i nvarchar(10)SET @i='table1'SET @sql='select * from @i'exec sp_executesql @stmt=@sql, @params = '@p as nvarchar(10)', @p = @i;Now I want to assign the result table I got to a table variable, some kinda like put a output parameter, but do not know how to do that. anyone could help me out?Thanks. |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-05-21 : 14:48:12
|
SET @sql='select * from ' + quotename( @i) E 12°55'05.63"N 56°04'39.26" |
 |
|
|
mavershang
Posting Yak Master
111 Posts |
Posted - 2009-05-21 : 15:41:04
|
Maybe I did not make it clear. I want to assign the result of "exec sp_executesql" to a table variable, but do not know how to set that in the params.Thanks for replyquote: Originally posted by Peso SET @sql='select * from ' + quotename( @i) E 12°55'05.63"N 56°04'39.26"
|
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-05-21 : 17:55:15
|
If you are using SQL Server 2005, just do an insert!insert @tablevariablenamehereexec(@sql) E 12°55'05.63"N 56°04'39.26" |
 |
|
|
|
|
|