Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

whats wrong with this statement for sql server to create a table?

CREATE TABLE Pub_Pool_Leauge

(

Pub_No int(10),

Pub_Name char(50),

Address_line1 nchar(50),

Address_line2 nchar(50),

Address_line3 nchar(50),

Address_line4 nchar(50),

Post_code nchar(12),

Phone_number nchar(12),

E-mail nchar(70)

)

Update:

doesn't matter figured it out could't use a -

5 Answers

Relevance
  • 9 years ago
    Favorite Answer

    SQL Server accepts the usage of '-' Hyphen in the column names, but has to be wrapped in the delimiter Double Quotation Marks (") or Square Brackets ([ ]).

    This wrapping is needed because the normal specification for column naming conventions doesn't contain the usage of Hyphen.

    So, to make your create table script work -

    CREATE TABLE Pub_Pool_Leauge

    (

    "E-mail" nchar(70)

    )

    OR

    CREATE TABLE Pub_Pool_Leauge

    (

    [E-mail] nchar(70)

    )

    Be aware of the fact that, every time a reference happens to this column it has to be enclosed in these delimiters.

    SELECT [E-mail] FROM Pub_Pool_Leauge;

    SELECT "E-mail" FROM Pub_Pool_Leauge;

    -- In 'thoughts'...

    Lonely Rogue.

    https://twitter.com/#!/LonelyRogue

  • 9 years ago

    Use

    "E-mail" nchar(70)

    instead of

    E-mail nchar(70)

  • 5 years ago

    EDIT: i'm sorry, I made a mistake This one ought to artwork mysql_query(' CREATE table `watchlist`( `username` VARCHAR(16) no longer NULL, `offence` textual content no longer NULL, `punishment` textual content no longer NULL, popular KEY (`username`) ) ') or die (mysql_error());

  • Anonymous
    9 years ago

    1. You shouldn't be using - for e-mail rather use underscore as e_mail

    2. if it is MS Sql server you shouldn't be using length for int ,because in it the length is dynamically associated as needed.

  • How do you think about the answers? You can sign in to vote the answer.
  • 9 years ago

    You can't use a (-) sign because it thinks it's a minus operator.

Still have questions? Get your answers by asking now.