Quotes in sql script file

  • Hi all,

    I generated a script file for few tables of my database, and I am not unable to execute those scripts, as there are single quotes in few of the columns of those table in the script.

    How can i remove the single quotes from the sql script, Can any one give me any idea about that.

     

    - Manish

  • If those quotes are in column names then use [] for column names.

    If they are in data you scripted then duplicate quotes when you are scripting data.

    Like this:

    select REPLACE(ColName, '''', '''''')

    _____________
    Code for TallyGenerator

  • Who are you and what have you done with the real Serqiy?  The real Serqiy I know would have said something about going back and fixing the database so there are no quotes in column names.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Don't forget to hunt down and torture the person that used quotes in column names.

    No, I'm not the real Sergiy in disguise.


    My blog: SQL Soldier[/url]
    SQL Server Best Practices:
    SQL Server Best Practices
    Twitter: @SQLSoldier
    My book: Pro SQL Server 2008 Mirroring[/url]
    Microsoft Certified Master: SQL Server, Data Platform MVP
    Database Engineer at BlueMountain Capital Management[/url]

  • Yeah... that's what I mean Stuff like that...

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 5 posts - 1 through 4 (of 4 total)

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