Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 1234»»»

T-SQL Syntax Expand / Collapse
Author
Message
Posted Thursday, August 16, 2012 9:33 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, November 7, 2014 11:31 PM
Points: 20, Visits: 266
Comments posted to this topic are about the item T-SQL Syntax


Post #1346324
Posted Thursday, August 16, 2012 9:48 PM


Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Thursday, September 18, 2014 2:30 AM
Points: 595, Visits: 219
Good question, very difficult to answer.

But
"An Input argument to a Procedure or Function"
can be split into
"An Input argument to a Procedure" and
"An Input argument to a Function".

So we could get the total of 9. isn't it?
Post #1346326
Posted Thursday, August 16, 2012 10:40 PM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Today @ 12:08 PM
Points: 17,967, Visits: 15,975
Tough question - thanks



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Post #1346330
Posted Thursday, August 16, 2012 10:42 PM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Today @ 3:16 PM
Points: 994, Visits: 2,227
Indeed, very difficult and controversial question.
Counted Function and Procedure as different constructs but missed EXEC and RECEIVE.
Oh well, as soon as we learn something…

Also, what about UPDATE/INSERT/DELETE @tablevar ?
Post #1346331
Posted Friday, August 17, 2012 12:12 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 11:18 AM
Points: 13,545, Visits: 11,359
Great question, but way too difficult for a Friday
Didn't even think about RECEIVE.




How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?

Member of LinkedIn. My blog at LessThanDot.

MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1346340
Posted Friday, August 17, 2012 12:25 AM


SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, November 19, 2014 5:39 PM
Points: 286, Visits: 582
rVadim (8/16/2012)

....missed EXEC and RECEIVE.


Also, what about UPDATE/INSERT/DELETE @tablevar ?


I missed RECEIVE too. I have to say not a lot of work has gone on in our office this afternoon while we debated why DML against a table variable shouldn't be valid!!


Clare
_________________________________________________________________________________________________________________
Measure twice; cut once (and have a good saw)

Hey, just a thought.....did you check Books Online yet?
Post #1346346
Posted Friday, August 17, 2012 1:23 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, November 7, 2014 11:31 PM
Points: 20, Visits: 266
My newsletter has not even rolled in yet, but thought I would say Hi! Glad to see people found it interesting. It just popped into my head while researching BOL one day.

Jamsheer - An input argument in either case just seems to be the same thing to me.

rVadim - I think you did find another variation, e.g. INSERT @tablevar VALUES (1, 2). Congratulations.

Hope everyone had fun.



Post #1346364
Posted Friday, August 17, 2012 3:02 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 1:19 AM
Points: 2,592, Visits: 2,446
Maybe, you miss the UPDATE clause:

declare @mykey int

update top 1 mytable set
@mykey = mykey
where status = 0

print @mykey

Post #1346405
Posted Friday, August 17, 2012 3:21 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Today @ 2:51 AM
Points: 3,076, Visits: 3,194
Carlo Romagnano (8/17/2012)
Maybe, you miss the UPDATE clause:

declare @mykey int

update top 1 mytable set
@mykey = mykey
where status = 0

print @mykey



Hi, this is covered in the question itself: ...says "without using SET nor SELECT"
IgorMi




Igor Micev,
SQL Server developer at Seavus
www.seavus.com
Post #1346415
Posted Friday, August 17, 2012 3:23 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 1:49 PM
Points: 6,098, Visits: 8,364
I appreciate the amount of research that went into this question and I think it has a good educational value, but I don't think a QotD is the right form for this education - at least not a QotD in this specific form. That is because the education here is just in reading the answer, not in trying to find it yourself. It is simply nigh on impossible to find a complete list, because that would require one to know EVERYTHING in the T-SQL syntax, or to read BOL entirely. Without putting in that effort (which is far too much to be worth it), you can only get this right by having a lucky guess.

Not to mock the author, but to prove my point that the T-SQL language is simply too complex to get away with ANY question of the "how many" kind, here are three constructs that are missing in the answer explanation:

1. UPDATE tablename SET @variablename = columnname = expression;
2. EXEC sp_executesql (this one is debatable; one could argue that this is covered by the "Output argument to a Procedure" in the answer, or you could argue that the dynamic naturre of sp_executesql makes this a distinct construct);
3. The default value assignment in a procedure definition: CREATE PROC MyProc @MyVar int = 12 AS ...

And I wouldn't be surprised at all if other people can extend this list even more.

EDIT: Posts by Carlo and IgorMi came in while I was writing, hence the duplication of the UPDATE consntruct. I read the QotD as excepting the SELECT and SET statements, not the UPDATE statement which includes a SET clause. (And I think the author had this in mind, given that he describes the OUTPUT INTO clause as "could count this 4 times" - if the SET clause is forbidden, the OUTPUT INTO can only be counted 3 times, because an UPDATE without SET is invalid)


Because I wanted to see the answers and weigh in on the discussion, I decided to take an "educated guess" at the question. I applied human psychology to eliminate the lowest and highest value from the answer options, then made a random pick from the remaining options. And I got lucky, so I now have another point to brag about to anyone who wants to hear (i.e., nobody).

Again, I do appreciate the effort that has gone in the question and the educational value from the explanation. I just think that this information was more suited for a short article, blog post, or similar. Or for a completely different form of question.



Hugo Kornelis, SQL Server MVP
Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
Post #1346419
« Prev Topic | Next Topic »

Add to briefcase 1234»»»

Permissions Expand / Collapse