Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Create table

Author  Topic 

chxxangie
Starting Member

16 Posts

Posted - 2008-06-17 : 22:41:44
let say i have table A. have several columns like:-
div_no,pro_no,vd_no,itm_no,qty,dte....
the point is these column (div_no,pro_no,vd_no,itm_no) cannot have same data.
so, when creating table, how to set the query?
create table dataware:p_mpsg
(div_no CHAR(2) Not Null,
pro_no CHAR(9) Not Null,
vd_no CHAR(9) Not Null,
itm_no CHAR(20) Not Null,
qty INTERGER Not Null,
dte DATE Not Null)


sample record (not acceptale):
01,PRO1,VD1,ITM1,10,11-11-1111
01,PRO1,VD1,ITM1,20,22-12-2222

sample record (acceptale):
01,PRO1,VD1,ITM1,10,11-11-1111
01,PRO1,VD2,ITM1,20,22-12-2222

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2008-06-17 : 22:44:06
you need a primary key on the first 4 columns.


elsasoft.org
Go to Top of Page

chxxangie
Starting Member

16 Posts

Posted - 2008-06-17 : 23:23:03
create table dataware:p_mpsg
(div_no CHAR(2) Not Null PRIMARY KEY,
pro_no CHAR(9) Not Null PRIMARY KEY,
vd_no CHAR(9) Not Null PRIMARY KEY,
itm_no CHAR(20) Not Null PRIMARY KEY,
qty INTERGER Not Null,
dte DATE Not Null)

like that??? error occurr...
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-18 : 01:11:26
quote:
Originally posted by chxxangie

create table dataware:p_mpsg
(div_no CHAR(2) Not Null,
pro_no CHAR(9) Not Null,
vd_no CHAR(9) Not Null,
itm_no CHAR(20) Not Null,
qty INTERGER Not Null,
dte DATE Not Null,
CONSTRAINT PK_yourconstraintname
PRIMARY KEY(div_no,pro_no,vd_no,itm_no))


like that??? error occurr...



Nope create a composite primary key on three columns as above.Also if columns contain numeric data only please decalre them as integer rather than char

Go to Top of Page

chxxangie
Starting Member

16 Posts

Posted - 2008-06-18 : 20:55:46
i try above code...
Error: A syntax error has occurred. (State:37000, Native Code: FFFFFF37)
Go to Top of Page

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2008-06-18 : 22:16:26
what database server are you using? I don't think it's SQL Server 2005. maybe 2000?

a table name of dataware:p_mpsg is rather strange too.


elsasoft.org
Go to Top of Page
   

- Advertisement -