Re: Newbie creating table question
From: Aaron [SQL Server MVP] (ten.xoc_at_dnartreb.noraa)
Date: 08/09/04
- Next message: jez123456: "Re: Trigger - Urgent"
- Previous message: Przemo: "Re: how to design such a query"
- In reply to: Paul in Harrow: "Newbie creating table question"
- Next in thread: Paul in Harrow: "Re: Newbie creating table question"
- Reply: Paul in Harrow: "Re: Newbie creating table question"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 9 Aug 2004 09:45:53 -0400
(a) drop the tbl prefix, it is superfluous and just makes it harder to type
and find.
(b) check the CREATE TABLE syntax in Books Online. Constraints need a name,
and you must tell it what kind of constraint it is. e.g.
[CurStatus] [varchar] CONSTRAINT
checkCurStatus
CHECK
(
CurStatus IN
(
'On Course',
'Not Attending',
'Got Job',
'Completed Course'
)
),
(c) what kind of value is "Got Job"? Do you really want to store these
strings for every ? I would prefer a lookup table where this representation
is a TINYINT. Less redundancy, and much easier to change "Got Job" to
something more English-like. ;-)
-- http://www.aspfaq.com/ (Reverse address to reply.) "Paul in Harrow" <PaulinHarrow@discussions.microsoft.com> wrote in message news:E7987DC1-D56D-4915-BD82-E1B68F735F8B@microsoft.com... > Back again > I'm trying to create a table the correct way (not using the Enterprise > Manager) and I'm having problems. Here's my script: > CREATE TABLE [dbo].[tblAdditionalInfo] ( > [LDUserName] [varchar] (35) NOT NULL Primary Key , > [FirstName] [varchar] (15) NOT NULL , > [MiddleName] [varchar] (15) NOT NULL , > [NINumber] [varchar] (10) NULL , > [Jobcentre] [varchar] (15) NULL , > [CurStatus] [varchar] CONSTRAINT( 'On Course' , 'Not Attending' , 'Got Job' > , 'Completed Course' ) , > [DatedChange] [smalldatetime] NULL default getdate(), > [AsylumSeekerYN] [varchar] (3) NULL CONSTRAINT ('Yes' , 'No' ) , > [StudentLocation] [varchar] (15) Null CONSTRAINT ('College' , 'Home Learner' > ) , > [SpecialNeedsYN] [varchar] (3) NULL CONSTRAINT ('Yes' , 'No' ) , > [IsActive] [varchar] (10) NULL CONSTRAINT ('Active' , 'Inactive' ) , > [LogBookNo] [varchar] (13) Null , > [DateIssued] [smalldatetime] NULL , > [Scheme] [varchar] (25) NULL) > GO > > I'm getting "Server: Msg 170, Level 15, State 1, Line 7 > Line 7: Incorrect syntax near '('." > > Help please! > (Not all the fields with Constraints will be entered at any one time thats > why they are NULL) > Thanks > > Paul > (proberly try to run before he can walk) >
- Next message: jez123456: "Re: Trigger - Urgent"
- Previous message: Przemo: "Re: how to design such a query"
- In reply to: Paul in Harrow: "Newbie creating table question"
- Next in thread: Paul in Harrow: "Re: Newbie creating table question"
- Reply: Paul in Harrow: "Re: Newbie creating table question"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|