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 Clause

Author  Topic 

musclebreast
Yak Posting Veteran

77 Posts

Posted - 2012-08-09 : 07:27:56
Hi,

I'm struggling to create a simple with clause and hope you can help me:

;With testtable(test)
AS
(
(select '30/03/'

union all

select '30/06/'), tester(test))

select * from tester


Can somebody explain me what i have to use after the "with" . I read the official description but somehow I don't get it.

Kind regards,

Lara

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2012-08-09 : 07:36:11
[code];WITH testtable(test)
AS (
select '30/03/'

union all

select '30/06/'
), other(yak)
AS (
select 'a/' + test from testtable
)
select yak from other;[/code]


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-08-09 : 09:57:31
quote:
Originally posted by musclebreast

Hi,

I'm struggling to create a simple with clause and hope you can help me:

;With testtable(test)
AS
(
(select '30/03/'

union all

select '30/06/'), tester(test))

select * from tester


Can somebody explain me what i have to use after the "with" . I read the official description but somehow I don't get it.

Kind regards,

Lara


can i ask what you're trying to achieve here? is it just for illustration as i dont see real need of using CTE here

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -