|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Friday, May 17, 2013 10:28 AM
Points: 2,
Visits: 54
|
|
Although the overall technical correctness of this article is good there is a glaring error in the narrative. There is no such thing as a "single quote" mark. There is an apostrophe mark and there is a quotation mark. A single quote looks thusly " and a double quote looks this way "". What the article’s author refers to as a "single quote" is in reality an apostrophe mark ' and what is referred to as a "double quote" is actually a quotation mark.
I bring this up because the difference is really quite significant. Calling an apostrophe a "single quote" is, putting it simply, quite wrong. It would be like calling a “V” a single “W” and calling a “W” a “double W”.
When looking up "quotation marks" in the Oxford Online Dictionary, http://oxforddictionaries.com/words/punctuation, I see no punctuation mark labeled as "single quote". Nor is there a mention of a "double quote".
Yes, I'm tilting windmills. But one must try occasionally, mustn't one?
Thanks for the soapbox.
|
|
|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Thursday, May 09, 2013 8:31 AM
Points: 3,367,
Visits: 1,563
|
|
Nemeaux (1/3/2013) Although the overall technical correctness of this article is good there is a glaring error in the narrative. There is no such thing as a "single quote" mark. There is an apostrophe mark and there is a quotation mark. A single quote looks thusly " and a double quote looks this way "". What the article’s author refers to as a "single quote" is in reality an apostrophe mark ' and what is referred to as a "double quote" is actually a quotation mark.
I bring this up because the difference is really quite significant. Calling an apostrophe a "single quote" is, putting it simply, quite wrong. It would be like calling a “V” a single “W” and calling a “W” a “double W”.
When looking up "quotation marks" in the Oxford Online Dictionary, http://oxforddictionaries.com/words/punctuation, I see no punctuation mark labeled as "single quote". Nor is there a mention of a "double quote".
Yes, I'm tilting windmills. But one must try occasionally, mustn't one?
Thanks for the soapbox.
Actually I appreciate the feedback. One of my biggest problems with writing, be it a blog entry, a QotD or an article like this one is that I have a tendency to use "common usage" phrases. I forget that these can be very difficult for someone who isn't fluent in English or for that matter learned it using different idioms than I'm used to.
In my own defense though you will find them described as single and double quotation marks in BOL. I checked when I was writing the article .
Kenneth Fisher I strive to live in a world where a chicken can cross the road without being questioned about its motives. -------------------------------------------------------------------------------- For better, quicker answers on T-SQL questions, click on the following... http://www.sqlservercentral.com/articles/Best+Practices/61537/ For better answers on performance questions, click on the following... http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Link to my Blog Post --> www.SQLStudies.com
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Friday, May 17, 2013 10:28 AM
Points: 2,
Visits: 54
|
|
Ah, if only we could now get BOL to see the light!
In any case, good article...keep up the good writing!
Dave
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Yesterday @ 9:31 AM
Points: 1,039,
Visits: 1,356
|
|
roger.plowman (1/3/2013) This issue is yet another example of why SQL is one of the worst-designed languages of all time from a syntactic POV.
Would it have killed the designers to create two string delimiters that could be interchanged (ala BASIC) and reserved square brackets for field/table delimiting? So that when you have a string which contains both delimiters as literals, you have double the problem? Syntactically, having two delimiters that mean the same thing is a problem, not a solution.
And while we're at it to use #'s to delimit dates/times (ala MS Access)? "ala MS Access" == NO. Besides, there's plenty of good documentation on date formatting in SQL, and simply changing 's to #s wouldn't give you any better conversion rate.
Oh, and use a dedicated "escape" character instead of doubling the escaped character? Sheesh! On this one, I agree with you -- in principle at least. From a syntax standpoint, it makes sense to have a specific escape character, like regular expressions do, for example. But what happens when you need to include the escape character as a literal? Double the escaped character, again.
In the case of T-SQL and string literals, the only character which would ever need to be escaped is '. So the options were:
a) create an escape character (let's say \) and then use that character to escape every literal ' and \ (i.e, have possible two escape clauses: \' and \\), or
b) use ' as the escape character for itself and have one possible escape clause ('').
So they again opted for the simpler solution.
|
|
|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Thursday, May 09, 2013 8:31 AM
Points: 3,367,
Visits: 1,563
|
|
sknox (1/3/2013)
roger.plowman (1/3/2013) This issue is yet another example of why SQL is one of the worst-designed languages of all time from a syntactic POV.
Would it have killed the designers to create two string delimiters that could be interchanged (ala BASIC) and reserved square brackets for field/table delimiting?So that when you have a string which contains both delimiters as literals, you have double the problem? Syntactically, having two delimiters that mean the same thing is a problem, not a solution. And while we're at it to use #'s to delimit dates/times (ala MS Access)? "ala MS Access" == NO. Besides, there's plenty of good documentation on date formatting in SQL, and simply changing 's to #s wouldn't give you any better conversion rate. Oh, and use a dedicated "escape" character instead of doubling the escaped character? Sheesh! On this one, I agree with you -- in principle at least. From a syntax standpoint, it makes sense to have a specific escape character, like regular expressions do, for example. But what happens when you need to include the escape character as a literal? Double the escaped character, again. In the case of T-SQL and string literals, the only character which would ever need to be escaped is '. So the options were: a) create an escape character (let's say \) and then use that character to escape every literal ' and \ (i.e, have possible two escape clauses: \' and \\), or b) use ' as the escape character for itself and have one possible escape clause (''). So they again opted for the simpler solution.
I do see one benefit for using an escape character that isn't your delimiter. '\\' is quite a bit easier to follow than ''''. Or for that mater '\\\\' is much easier than ''''''. On the whole though I agree with you. A character had to be picked as an escape character and regardless of what character it was we were going to have some level of problems with it.
Kenneth Fisher I strive to live in a world where a chicken can cross the road without being questioned about its motives. -------------------------------------------------------------------------------- For better, quicker answers on T-SQL questions, click on the following... http://www.sqlservercentral.com/articles/Best+Practices/61537/ For better answers on performance questions, click on the following... http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Link to my Blog Post --> www.SQLStudies.com
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Monday, April 29, 2013 2:49 PM
Points: 50,
Visits: 78
|
|
nice article. thanks.
DECLARE @topsql NVARCHAR(200)
SET @topsql = 'DECLARE @quotedvar nvarchar(100) ' + CHAR(13) + 'DECLARE @sql nvarchar(1000) ' + CHAR(13) + 'SET @quotedvar = ''O''''Neil''' + CHAR(13) + 'SET @sql = ''PRINT '''''' +REPLACE(@quotedvar,'''''''','''''''''''') + ''''''''' + CHAR(13) + 'PRINT @sql ' + CHAR(13) + 'EXEC sp_executesql @sql '
PRINT @topsql PRINT '-------'
EXEC sp_executesql @topsql
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Friday, March 15, 2013 11:48 AM
Points: 1,
Visits: 19
|
|
What about something simpler:
declare @q nvarchar(50), @sql nvarchar(100)
set @q = '''o''''neil'''
set @sql = 'print ' + @q + '' print @sql
EXEC sp_executesql @sql
___________________________________
print 'o''neil' o'neil
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Today @ 2:10 PM
Points: 2,117,
Visits: 2,211
|
|
Nemeaux (1/3/2013) Although the overall technical correctness of this article is good there is a glaring error in the narrative. There is no such thing as a "single quote" mark. There is an apostrophe mark and there is a quotation mark. A single quote looks thusly " and a double quote looks this way "". What the article’s author refers to as a "single quote" is in reality an apostrophe mark ' and what is referred to as a "double quote" is actually a quotation mark.
I bring this up because the difference is really quite significant. Calling an apostrophe a "single quote" is, putting it simply, quite wrong. It would be like calling a “V” a single “W” and calling a “W” a “double W”.
When looking up "quotation marks" in the Oxford Online Dictionary, http://oxforddictionaries.com/words/punctuation, I see no punctuation mark labeled as "single quote". Nor is there a mention of a "double quote".
Yes, I'm tilting windmills. But one must try occasionally, mustn't one?
Thanks for the soapbox.
For your consideration:
http://english.stackexchange.com/questions/36046/apostrophe-vs-single-quote
Also here: http://en.wikipedia.org/wiki/Quotation_mark
SQL uses what seems to be called typewriter quotation marks, or dumb or straight quotes. I think there is a semantic difference between apostrophes and single quotation marks. For example, many Penguin books use single quotation marks to set off dialogue. In that case, though, the "open quote" is in one direction and the "close quote" is in the inverted direction. So although you may be technically correct (I'm not yet sure that you are), it seems to be the case -- excepting the symmetrical straight or dumb quotes -- that while all apostrophes look like single (close) quotation marks, not all single quotation marks look like apostrophes. See also: http://www.ergonis.com/products/tips/punctuation-apostrophes-quotation-marks.php
That typographical distinction doesn't exist in SQL, which uses a "dumb" quotation mark (for lack of a better term) rather than a "smart" one. So you may indeed be titling at windmills, although I happen to find those same windmills very interesting and am grateful that you contributed your comments to this discussion.
- webrunner
------------------- "The chemistry must be respected." - Walter White
"A SQL query walks into a bar and sees two tables. He walks up to them and says 'Can I join you?'" Ref.: http://tkyte.blogspot.com/2009/02/sql-joke.html
|
|
|
|
|
SSCrazy Eights
        
Group: General Forum Members
Last Login: Today @ 2:52 PM
Points: 8,605,
Visits: 8,246
|
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Yesterday @ 7:19 AM
Points: 283,
Visits: 1,239
|
|
The standard ASCII character set is a holdover from the early days of teletype, band printers, computers and manual typewriters. (How many of you have ever seen a band printer? They were incredibly fast.)
If one wants to get nitpicky, typographers have always used the form of characters that was added to the standard ASCII to create the Extended Character set. Even in the days of lead type, most font sets--whether manual or automated linotype--included these typographical characters.
From the standard character set:
This is an apostrophe: ' (ASCII 39) This is a quotation mark: " (ASCII 34)
From the extended characters set:
This is a left single quotation mark: ‘ (ASCII 145) This is a right single quotation mark: ’ (ASCII 146)
This is a left double quotation mark: “ (ASCII 147) This is a right double quotation mark: ” (ASCII 148)
ASCII 39 and ASCII 34--in typography--would be used to represent minutes and seconds when displaying latitude or longitude or as an abbreviation for feet and inches.
Oh, and since I used the double-hyphen above rather than a true em dash that is cause to differentiate there as well.
This is a hyphen: - (ASCII 45) used as a minus symbol, for compound words, or to break a word between lines.
This is an en dash: – (ASCII 150) used to represent a range such as 1952–1987.
This is an em dash: — (ASCII 151) used as a text separator. This symbol would properly be used in place of the double-hyphen—like this—rather than the double-hyphen typical of computers and typewriters.
And one final typographical note: the ellipsis is typically typed using three periods. But the proper method to display an ellipsis would be to use ASCII char 133: …
For anyone who really cares about proper typography The Chicago Manual of Style is the editor's Bible.
|
|
|
|