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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 with condition

Author  Topic 

peace
Constraint Violating Yak Guru

420 Posts

Posted - 2013-05-03 : 04:31:39
how can i select into temp table for with condition?

With A1(Column1,column2,column3) As
(
......

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-05-03 : 04:37:45
[code];WITH A1(Column1,column2,column3) As
(
-- Your SELECT statement
)
SELECT
FROM A1
WHERE <condition>[/code]

--
Chandu
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-05-03 : 04:43:23
not sure i understand it fully

if you want condition to be applied while populating CTE it should be


;WITH A1(Column1,column2,column3) As
(
SELECT ..
FROM..
WHERE <condition>
)
SELECT
FROM A1


If you want condition to be applied while retrieving from CTE use earlier suggestion

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

peace
Constraint Violating Yak Guru

420 Posts

Posted - 2013-05-03 : 04:51:08
I meant i need to select the result into temp table.

Where should i apply the SELECT INTO #A ....
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-05-03 : 04:57:05
[code]
;WITH A1(Column1,column2,column3) As
(
SELECT ..
FROM..

)
SELECT * INTO #A
FROM A1
WHERE <condition>
[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -