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 |
|
cognos79
Posting Yak Master
241 Posts |
Posted - 2010-01-28 : 13:22:27
|
| I am trying to write multiple statements in a dynamic sql string.declare @sql1 varchar(max)declare @sql2 varchar(max)declare @sql3 varchar(max)set @sql1 = 'SELECT * into #rd from students' set @sql2 = 'select * from #rd'set @sql3 = @sql1 + ' ' + @sql3exec @sql3.I get error saying "could not find procedure 'select * into #rd from students......'how can i achieve this using dynamic sql. |
|
|
DP978
Constraint Violating Yak Guru
269 Posts |
Posted - 2010-01-28 : 13:27:13
|
| 1. Im sure you meant set @sql3 = @sql1 + ' ' + @sql22. to run put it in parenthasis : Exec (@sql3) |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-01-29 : 02:27:05
|
| What is the need of this code?It can be as simple asselect * from studentsMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|