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 - 2001-11-27 : 08:49:10
|
| Vinay writes "Hi EB, Here is another problem for me. Does SQL Server support dynamic result set definition for cursor? I want to write one cursor, in which the table name is not fixed (static), I want to select it from different tables having exactly same table structure(no of columns, column names etc... Actually these are temporary tables created on the same DDL).. DECLARE @gtemp_table_name varchar(50).... Some processing here..DECLARE @mySqlStatement = varchar(100) SET @mySqlStatement = "SELECT * FROM " + @gtemp_table_nameDECLARE mycursor FOR @mySqlStatement.........I tried with this type of syntax, but it is not allowing me. How should I go for it? Thanks and regards,Vinay Joshi." |
|
|
btrimpop
Posting Yak Master
214 Posts |
Posted - 2001-11-27 : 09:23:45
|
| You need to put the whole delcaration into a variableSET @mySqlStatement = "declare mycursor for SELECT * FROM " + @gtemp_table_nameexec(@mysqlstatement)etc.etc."In theory there is no difference between theory and practice. But in practice there is!" |
 |
|
|
|
|
|