SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 with condition
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

peace
Constraint Violating Yak Guru

389 Posts

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

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

bandi
Flowing Fount of Yak Knowledge

India
2202 Posts

Posted - 05/03/2013 :  04:37:45  Show Profile  Reply with Quote
;WITH A1(Column1,column2,column3) As
(
   -- Your SELECT statement
)
SELECT 
FROM A1
WHERE <condition>


--
Chandu
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52309 Posts

Posted - 05/03/2013 :  04:43:23  Show Profile  Reply with Quote
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

389 Posts

Posted - 05/03/2013 :  04:51:08  Show Profile  Reply with Quote
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

India
52309 Posts

Posted - 05/03/2013 :  04:57:05  Show Profile  Reply with Quote

;WITH A1(Column1,column2,column3) As
(
SELECT ..
FROM..

)
SELECT * INTO #A
FROM A1
WHERE <condition>


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000