Quotes, Apostrophes, and strings

  • Query Analyzer seems to be able to tell the difference between the apostrophe and the opening and closing quotes. It doesn't give me an error when i check the syntax and it has everything in red that is supposed to be in red.

    Should i trust this observation or should i change this somehow? I guess use double quotes.

    Here is a sample of the code with apostrophes for possession. I placed questionable words in red.

    -- EMPLOYEES TABLE ---------------------------------------------------

    EXEC sp_addextendedproperty

    'MS_Description', 'Primary key', 'User', 'dbo', 'table', 'Employees', 'column', 'EmpID'

    EXEC sp_addextendedproperty

    'MS_Description', 'Employee’s first name', 'User', 'dbo', 'table', 'Employees', 'column', 'FirstName'

    EXEC sp_addextendedproperty

    'MS_Description', 'Employee’s last name', 'User', 'dbo', 'table', 'Employees', 'column', 'LastName'

    EXEC sp_addextendedproperty

    'MS_Description', 'Employee’s badge number or number on check stub for salaried employees without badge numbers', 'User', 'dbo', 'table', 'Employees', 'column', 'BadgeNumber'

  • Someone said it might be the difference in the quote mark. It is a different font not a different quote mark. Actually it is supposed to be the same font! I don't know why the quote marks are different. I've never heard of such. I thought a quote was a quote. But when i switch them in Query Analyzer, it seems to not like it.

    Should i change the single quote apostrophe?

    If i change them all to the same type then do i use double quotes?

    Thanks!

  • >> If i change them all to the same type then do i use double quotes?  <<

    YES use  '' (two single)  not "

    ex:

    EXEC sp_addextendedproperty

    'MS_Description', 'Employee''s first name', 'User', 'dbo', 'table', 'Employees', 'column', 'FirstName'


    * Noel

  •  

    EXEC sp_addextendedproperty

    'MS_Description', "Employee's first name", 'User', 'dbo', 'table', 'Employees', 'column', 'FirstName'

    So this doesn't work? I used two double quotes on both sides with on single inside. I certainly wasn't thinking, two single quotes in the place of the one single quote. To me that is like a string without an concatenation symbol. Why does two single quotes work?

     and why didn't my books forewarn me? 

    Why does this have to be more difficult than it needs to be. LOL!!!

    Thanks!

  • the double quotes are used also in place of identifyers like [] if you have a column with an special caracter in it or is a reserved word you use the

    quoted identifiers feature (which by default is on )

    therefor "order details" will be interpreted as an Identifier

    now if qouted identifiers is off (which you will have to set with:

    SET QUOTED_IDENTIFIER  OFF)

    then "orders details" will be interpreted as string

    cheers!

     


    * Noel

  • Thanks Noel, you always provide helpful information. I'll do some research on this SET QUOTED_IDENTIFIER statement.

     

    Thanks!

  • Happy to Help

     


    * Noel

  • Congrats on the 2K mark Noeld .

  • Aren't you supposed to be on vacation?

     


    * Noel

  • Yes... but I still reply to my private messages and I saw you hit the mark... so off I go again .

  • It really does not means that much to me ... but Hey Thanks anyways

     


    * Noel

Viewing 11 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic. Login to reply