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 |
|
netedk
Starting Member
11 Posts |
Posted - 2007-08-08 : 11:56:31
|
| Hello,Is there a way to define a CTE with a dynamic query? What I want to do is somethign like this:declare @strg varchar(1000), @where varchar(1000)set @strg = 'select email, id from employees'set @strg = @strg + 'where id between 1000 and 2000';WITH table1 (rid, email)AS(exec (@strg))select *from table1Any help is welcome.ThanksMarketing Communications: http://www.realmagnet.comSoftware Development:http://www.daksatech.com |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-08-08 : 12:31:24
|
| no you can't do that.you have to have the whole CTE dynamic._______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
 |
|
|
|
|
|