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 - 2007-03-05 : 10:42:26
|
| Jayaraj writes "I am trying to use dynamic sql with CTE, but couldn't. Please helpI want to use CTE instead of temporary tables. I know that I can use temp table here, but I was looking for a way to use CTEDECLARE @ora AS VARCHAR(4000) SET @ora = ' SELECT * FROM OPENQUERY(IYPPRD, ''SELECT EMPLOYEE_ID , OFFICE,EMPLOYEE_POSITION, EMPLOYEE_NAME,EMAIL FROM RT_EMPLOYEE '' )' ; WITH AF_EMPLOYEE(EMPLOYEE_ID , OFFICE,EMPLOYEE_POSITION, EMPLOYEE_NAME,EMAIL) AS ( EXEC(@ora) )" |
|
|
mahesh_bote
Constraint Violating Yak Guru
298 Posts |
Posted - 2007-03-05 : 11:01:52
|
| what the thing CTE is afterall?Mahesh |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-03-05 : 11:08:54
|
| no you can't do that.you have to have your whole CTE in a string and execute it all at once.Mahesh:CTE is Common Table Expressions.It's a new thing in SQL Server 2005.Look it up in BOLCausing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
 |
|
|
|
|
|