What is Common Table Expression?

Posted by Amatya under Sql Server on 9/6/2017 | Points: 10 | Views : 692 | Status : [Member] | Replies : 5
Hi friends,
I was going to the below mentioned link, but i was unable to know where and for what purpose Common table expression is used for. i have never used it so please guide me so i can make use of CTE

http://techfunda.com/howto/203/create-a-cte-common-table-expression

Thanks
Amatya

Feel free to share informations.
mail Id ' adityagupta200@gmail.com
Thanks



Responses

Posted by: Raja on: 9/7/2017 [Member] Starter | Points: 25

Up
0
Down
This is like a temporary table variable however it can be only used just after its creation. In case of Temporary table variable, you can use it any number of times if it is created.

It is very useful to hold some data temporarily so that it can be used in another query.

Try to use as explained in the linked article and you will come to know easily.

The best way to learn is to use it!

Thanks

Regards,
Raja, USA

Amatya, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Annagrey on: 9/20/2017 [Member] Starter | Points: 25

Up
0
Down
The website is looking bit flashy and it http://aussieessays.org/ catches the visitors eyes. Design is pretty simple and a good user friendly interface.

Amatya, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sandeepmhatre on: 12/27/2017 [Member] Starter | Points: 25

Up
0
Down
Hi,

please follow below link to know about cte
http://sandeepmhatre.blogspot.in/2013/03/common-table-expressions.html



Sandeep M,
Software Developer
Follow me on :
http://sandeepmhatre.blogspot.in

Amatya, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ummayashri on: 3/20/2018 [Member] Starter | Points: 25

Up
0
Down
A common table expression (CTE) can be thought of as a temporary result set that is defined within the execution scope of a single SELECT, INSERT, UPDATE, DELETE, or CREATE VIEW statement. A CTE is similar to a derived table in that it is not stored as an object and lasts only for the duration of the query.

With expression_name (columnname1, columnname2)
(
Cte query defination
)

Select columnname from expression_name

https://www.besanttechnologies.com/dot-net-training-in-bangalore

Amatya, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kirthiga on: 5/17/2018 [Member] Starter | Points: 25

Up
0
Down
Declare @StartDay datetime, @EndDay datetime
Set @StartDay='2018-01-01'
Set @EndDay='2018-12-31'

;with cte(Date) as
(
select @StartDay
union all
select Date+1 from cte where Date < @EndDay
)
select Date,DATENAME(W,Date)Day from cte option (MAXRECURSION 400)


Amatya, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response