September 3, 2014 at 9:56 pm
Comments posted to this topic are about the item What will this query return?
Thanks,
Shiva N
Database Consultant
September 3, 2014 at 10:41 pm
Thanks for the question dear.
Vimal LohaniSQL DBA | MCP (70-461,70-462)==============================The greatest barrier to success is the fear of failure ** Success is a journey not a destination**Think before you print, SAVE TREES, Protect Mother Nature
September 4, 2014 at 12:15 am
Nice one, thanks for sharing.
Thanks
September 4, 2014 at 12:33 am
Nice one, thanks.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
September 4, 2014 at 1:08 am
When I work with CTE, I get this error when I dont give smicolon, so it was easy to answer
Thanks for the question
September 4, 2014 at 1:14 am
pmadhavapeddi22 (9/4/2014)
When I work with CTE, I get this error when I dont give smicolon, so it was easy to answerThanks for the question
+1
September 4, 2014 at 1:54 am
Thank you for the post, Shiva, good one.
ww; Raghu
--
The first and the hardest SQL statement I have wrote- "select * from customers" - and I was happy and felt smart.
September 4, 2014 at 1:55 am
Carlo Romagnano (9/4/2014)
pmadhavapeddi22 (9/4/2014)
When I work with CTE, I get this error when I dont give smicolon, so it was easy to answerThanks for the question
+1
+1
ww; Raghu
--
The first and the hardest SQL statement I have wrote- "select * from customers" - and I was happy and felt smart.
September 4, 2014 at 3:30 am
I think the explanation need some work.
CTEs doesn't ALWAYS need a semi-colon in front.
This for example works fine:
DECLARE @tmpVariable INT
WITH cte
AS
(
SELECT 1/0 as 'Result'
)
SELECT *
FROM cte
I'd like to know when a CTE needs semi-colon and not... I always though its only after a select from a table, but apparently not
September 4, 2014 at 4:01 am
DrKiller (9/4/2014)
I think the explanation need some work.CTEs doesn't ALWAYS need a semi-colon in front.
This for example works fine:
DECLARE @tmpVariable INT
WITH cte
AS
(
SELECT 1/0 as 'Result'
)
SELECT *
FROM cte
I'd like to know when a CTE needs semi-colon and not... I always though its only after a select from a table, but apparently not
+1, Nice question thou. Thanks for sharing
September 4, 2014 at 4:25 am
twin.devil (9/4/2014)
DrKiller (9/4/2014)
I think the explanation need some work.CTEs doesn't ALWAYS need a semi-colon in front.
This for example works fine:
DECLARE @tmpVariable INT
WITH cte
AS
(
SELECT 1/0 as 'Result'
)
SELECT *
FROM cte
I'd like to know when a CTE needs semi-colon and not... I always though its only after a select from a table, but apparently not
+1, Nice question thou. Thanks for sharing
In the local help it says "When a CTE is used in a statement that is part of a batch, the statement before it must be followed by a semicolon."
but the linked article states this
I know that is not a requirement to terminate every SQL Statement, but it does make it easier to read. However in most cases, other than readability the termination of the previous statement really doesn’t matter. . . In most cases.
I never really tested this much, but in general I just follow the statement highlighted in bold.
ww; Raghu
--
The first and the hardest SQL statement I have wrote- "select * from customers" - and I was happy and felt smart.
September 4, 2014 at 5:00 am
Easy mozo
Thanks & Best Regards,
Hany Helmy
SQL Server Database Consultant
September 4, 2014 at 5:19 am
Hany Helmy (9/4/2014)
Easy mozo
September 4, 2014 at 5:40 am
Thanks for the question.
I'm actually surprised so many people have got this wrong.
I say that because when I started using CTEs I was not accostumed to using the semicolon so I would ALWAYS get this error. I'm sure it happened to a lot of other folks when learning this feature.
---------------
Mel.
September 4, 2014 at 6:48 am
I guess I'm one of the few just getting the msg 8134 when I run this? Running on 2008.
Msg 8134, Level 16, State 1, Line 1
Divide by zero error encountered.
Viewing 15 posts - 1 through 15 (of 34 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy