Problem with column name

  • Hello,

    In my application I'm adding table to new database according to the old one

    in one of the table there are column which name is DATABASE and when I try to add it I'm getting exception ;

    query:

    CREATE TABLE EMPW_SETTINGS (DATABASE varchar (30) ,ORIGREC int ,PASSWORD varchar (30) ,PDFEXPORT char (1) ,PDFFOLDER varchar (1024) ,PDFPRINTER varchar (30) ,SIGNOFFREASON varchar (50) ,UPLOAD_FLAG char (2) ,USERNAME varchar (30) ,USESIGNOFF char (1) )

    throw exception:

    {"Incorrect syntax near the keyword 'DATABASE'."}

    the problem is clear,but i cant change the name of the column because there is application based on that database, also maybe there is FK to this column

    any suggestion?:Whistling:

    Thanks

    Rachamim

  • Since DATABASE is a keyword, it needs to be enclosed in square brackets....

    CREATE TABLE EMPW_SETTINGS ([DATABASE] varchar (30) ,ORIGREC int ,PASSWORD varchar (30) ,PDFEXPORT char (1) ,PDFFOLDER varchar (1024) ,PDFPRINTER varchar (30) ,SIGNOFFREASON varchar (50) ,UPLOAD_FLAG char (2) ,USERNAME varchar (30) ,USESIGNOFF char (1) )

    --Ramesh


  • Thank Ramesh 🙂

    Is there any store procedure

    which I can retraive all the keyword in sql server

    Rachamim

  • I guess there isn't any procedure to retrieve such list, but you can check BOL for the complete list of reserved keywords....

    --Ramesh


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

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