[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
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)
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
Re: convert my sql to sql server