Results 1 to 4 of 4

Thread: [RESOLVED] convert my sql to sql server

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2007
    Posts
    270

    Resolved [RESOLVED] convert my sql to sql server

    i have my sql table
    CREATE TABLE 'chat' (
    'id' INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
    'from' VARCHAR(255) NOT NULL DEFAULT '',
    'to' VARCHAR(255) NOT NULL DEFAULT '',
    'message' TEXT NOT NULL,
    'sent' DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
    'recd' INTEGER UNSIGNED NOT NULL DEFAULT 0,
    PRIMARY KEY ('id')
    )
    ENGINE = InnoDB;

    i need to convert in sql server ,i write following script but has some problem

    CREATE TABLE chat ('id' int , 'from' varchar(255),'to' varchar(255),'message' text,'sent' datetime,'recd' int)

    is there any problem in this

  2. #2
    PowerPoster abhijit's Avatar
    Join Date
    Jun 1999
    Location
    Chit Chat Forum.
    Posts
    3,228

    Re: convert my sql to sql server

    You don't need to put single quotes around your column names in SQL Server.
    So your script should read like
    Code:
    create table chat ("id" int, "from" varchar(255), "message" text, "sent" datetime, "recd" int)
    OR
    create table chat (id int, from varchar(255), message text, sent datetime, recd int)
    Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
    save a blobFileStreamDataTable To Text Filemy blog

  3. #3
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: convert my sql to sql server

    In addition to abhijit's response

    From and To are reserved/keywords and shouldn't be used as column names. If you must use those names surround them within [] (you will need to do that in every sql statement where they are used as well).

    If you have SQL Server 2005 or greater, don't use the obsolete Text datatype - use varchar(MAX)

    The earliest datetime that can be stored in SQL Server is Jan 1 1753 12:00AM. A default of 0 would be Jan 1 1900 12:00AM.

    Declare an "auto increment" column using

    id int identity(1,1) not null

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2007
    Posts
    270

    Re: convert my sql to sql server

    thanks ,Solved

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width