Talk:Transact-SQL

message: From the page previously at Transact SQL (now a redirect), copied here in case it's useful:
:Transact-SQL enhancements (or extensions) include control-of-flow language, stored procedures, triggers, defaults, rules, error handling and set options.
—Simon 20:03, 15 August 2005 (UTC)
thread_title:  Text preserved from "Transact SQL" 

message: "Control-of-flow Language" is awkward, but that's what MSDN and Books Online use.  Let's keep it consistent with the official docs. -- Mikeblas 05:43, 7 January 2006 (UTC)
replies: text: the above CASE examples are not flow control, and furthermore are standard    SQL99. it's a good thing they are not on the main pageJasen betts (talk) 08:28, 12 February 2011 (UTC)

text: There's articles on functions and stored procs; I don't see why we can't provide mention of them here and links to the other articles.  The most notable difference between functions and stored procs is that functions are evaluated per-row, while a stored proc is exeucted once. (I've recently clarified this in the user defined function article.) Your use of CASE isn't controlling flow. --Mikeblas 21:34, 21 June 2006 (UTC)
thread_title:  "control of flow" 

message: ”Some believe that "In order to make it more powerful" is not quite the real intention of Transact-SQL to exist. The reason would be Vendor lock-in.
Oh, bullshit.  —Preceding unsigned comment added by 18.26.4.40 (talk) 18:04, 14 October 2008 (UTC)
thread_title: Reason?

message: Under section "Flow control", it says at the end "An example of a WHILE loop is given below.", but no such example is given. Is it safe to delete that or is someone working on an example? 138.80.0.10 (talk) 15:36, 9 April 2010 (UTC)
thread_title:  No "while" example given 

message: The example DATEPART code is kind of ugly. How about this:
IF DATENAME(WEEKDAY,CURRENT_TIMESTAMP) IN ('Saturday','Sunday')
    PRINT 'Weekend.'
ELSE
    PRINT 'Weekday.'
This is much more readable that the current version using DATEPART(dw,DATE()) twice. And since DATE() is a non-deterministic function, there's an ambiguity as to whether the two invocations of it should return the same value or not.
:I don't think your example works in all locales. -- Mikeblas 01:27, 29 June 2006 (UTC)
replies: text: I believe a pretty robust and locale independent piece of T-SQL to alert the user to the status of the current date as a weekend date is:
if datename(weekday,current_timestamp) in (datename(weekday,'1900-01-06'),datename(weekday,'1900-01-07')) 
    print case serverproperty('LCID')
               when 1033 then 'It is the weekend.'
               when 1031 then 'Es ist das Wochenende.'
               -- add French, Spanish, etc. to match userbase
               else raiserror('Unknown locale for message.',11,1)
          end
else
    print case serverproperty('LCID')
               when 1033 then 'It is a weekday.'
               when 1031 then 'Es ist ein Wochentag.'
               else raiserror('Unknown locale for message.',11,1)
          end
This only calls the non-deterministic function current_timestamp once so there is no ambiguity about the return value and specifies the weekend dates in an unambiguous and pre-compilable format. Output is modified according to server locale and comparisons are not collation specific. (It's also a joke.) --Farmhouse121 04:06, 30 June 2006 (UTC)

text: OTOH, this is is an encyclopedia, and it should reflect a global view. Its articles are translated to different languages and read by people all around the globe; if such a user reads a code sample, it should work where they live.  If that means we need to pick a better example, then I'm all for it. -- Mikeblas 11:50, 30 June 2006 (UTC)

text: Maybe the best alternative is to get rid of datepart(/*args*/) and its locality, and pick a better example. -- Mikeblas 19:33, 5 July 2006 (UTC)

text: The current code assumes (without saying so) that Sunday is configured as the first day of the week. This is a per-server setting and can vary. 82.113.133.21 (talk) 09:38, 11 April 2012 (UTC)
thread_title: datepart

message: Shouldn't the title of this article be T-SQL like the title of SQL is SQL but not Structured Query Language? --Stefán Örvarr Sigmundsson (talk) 16:08, 16 April 2008 (UTC)
thread_title:  Article title 

message: How can you execute a delete statement with no from clause?
Is that for deleting the entire database or something?
Seems like there's an obvious answer, but I can't think of it. --207.235.73.130 (talk) 14:16, 23 September 2011 (UTC)
replies: text: +1, Changes to DELETE and UPDATE statements section need an explanation. I've never seen a DELETE without a FROM. And MySQL have the possibility to delete on multiple tables since 4.0 (2001-2003). Lacrymocéphale 16:26, 30 September 2012 (UTC)

text: I don't see anything there about a DELETE without a FROM clause, either now or in the version as of your comment.  But I'm puzzled by "both the DELETE and UPDATE statements allow a FROM clause to be added".  Since DELETE needs a FROM clause anyway, this can only mean a DELETE statement can accept two FROM clauses.  But the DELETE example there has only one FROM clause, so what's it on about? — Smjg (talk) 21:39, 26 July 2019 (UTC)
thread_title:  no from clause? 

message: Some dates would be nice, when was it released, versions etc..
--86.14.120.74 (talk) 17:15, 21 April 2012 (UTC)
replies: text: I agree - at the moment, there's no history information at all.  There ought to be, especially as it has a long history.  I get the impression that T-SQL was created at a time when standard SQL statements were executed only one at a time, thus there was no pre-existing concept of an SQL script.  Thus there was a subsequent divergence between T-SQL, which just juxtaposed statements to be executed in sequence with no delimiter, and standard SQL which introduced the semicolon as a statement terminator to support such scripting.  Nowadays the two are slowly coming back together.  It would be good if we could find some sourced info to put into the article about this.  Maybe I'll try and find some when I've a bit more time. — Smjg (talk) 11:24, 18 November 2022 (UTC)
thread_title: Dates?