Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Whats wrong with this 1

Status
Not open for further replies.

Kdawg22

Programmer
Feb 10, 2004
4
US
CREATE TABLE vp_blocks(

id int( 11 ) NOT NULL auto_increment,
title varchar( 50 ) NOT NULL default '',
tag varchar( 50 ) NOT NULL default '',
location varchar( 10 ) NOT NULL default '',
ORDER int( 11 ) NOT NULL default '0',
TYPE varchar( 20 ) NOT NULL default '',
html text NOT NULL ,
FILE varchar( 250 ) NOT NULL default '',
PRIMARY KEY ( id )
) TYPE = MYISAM

I keep getting this error when I try to run that code

You have an error in your SQL syntax near 'ORDER int( 11 ) NOT NULL default '0', TYPE varchar( 20 ) NOT NULL defaul' at line 1
 
If this is for SQL Server then your issue is the auto_increment. ON SQL Server use identity (1,1) you can have the seed and increment be any value you want.

"Shoot Me! Shoot Me NOW!!!"
- Daffy Duck
 
Change to
CREATE TABLE vp_blocks(
id int identity(1,1) NOT NULL PRIMARY KEY ,
title varchar( 50 ) NOT NULL default '',
tag varchar( 50 ) NOT NULL default '',
location varchar( 10 ) NOT NULL default '',
[ORDER] int NOT NULL default '0',
TYPE varchar( 20 ) NOT NULL default '',
HTML:
 text NOT NULL ,
[FILE] varchar( 250 ) NOT NULL default ''
)

1.You cant define the length for INT, it's default to be 4 bytes
2.Primary key could be defined along with the column definition
3.Some field name that you have for this table are reserved by SQL Server, should try to avoid, otherwise put it within square bracket
4.There is no auto_increment in SQL Server, you have to use identity instead
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top