Drop Table

Support Forum for database administrators and web based access to important newsgroups related to databases
Register on Database Support Forum Edit your profileCalendarFind other Database Support forum membersFrequently Asked QuestionsSearch this forum -> 
For Database admins: Free Database-related Magazines Now Free shipping to Texas


Post New Thread










Thread
Author

Check constraint - SQL problem
Hi,

I am new to database development and am writing a database as part of a
university course

I have created a table as below called CableWire - the table is created ok.

CREATE TABLE CableWire
(CableWireID CHAR(7),
BSstandard  CHAR(16),
Colour VARCHAR(16),
Material  VARCHAR(16),
MetresInStock INTEGER,
PRIMARY KEY (CableWireID));

However when I try to alter the table by adding a CHECK constraint:

ALTER TABLE CableWire
ADD CHECK (MetresInStock >= 0);

I get a pop-up box: "Line: 21
SQLSTATE = 37000
[Microsoft][ODBC dBase Driver] Syntax error in field definition, Con
tinue?"

(line 21 equated to the 2nd of those 2 lines). The syntax seems perfectly
acceptable to me.  Any help appreciated.

Regards,

Mary



Report this thread to moderator Post Follow-up to this message
Old Post
Mary Walker
07-23-05 12:23 PM


Re: Check constraint - SQL problem
Hello, Mary

The syntax is perfectly acceptable in Microsoft SQL Server 2000, but
are you using SQL Server or dBase ? The error message indicates that
the ODBC dBase driver is involved. If you want this to run on dBase,
perhaps you should try your question on another newsgroup.

Razvan


Report this thread to moderator Post Follow-up to this message
Old Post
Razvan Socol
07-23-05 12:23 PM


Re: Check constraint - SQL problem
Some minor commetns about the design and some questions.

1) Why is every non-key column NULL-able?

2) I don't know the wirte business, so who defines the cablewire_id
codes?  I know the ISO stuff for machine screws, etc.

3) Likewise, what is the BS Standard.  My first guess was British
Standards, since you spelled color wrong :)

4) Don' t you use Pantone or Land color numbers?  Can you give me an
example of CHAR(16) color name?   I assume that it is a name, not a
code, but since you did not follow ISO-11179 rules, I don't know.

CREATE TABLE CableWire
(cablewire_id CHAR(7) NOT NULL PRIMARY KEY,
bs_standard  CHAR(16  NOT NULL),
colour_name VARCHAR(16)  NOT NULL,
material_type VARCHAR(16)  NOT NULL,
stock_level INTEGER DEFAULT 0  NOT NULL
CHECK (stock_level >= 0));

Otherwise, your syntax was fine.


Report this thread to moderator Post Follow-up to this message
Old Post
--CELKO--
07-24-05 08:23 AM


Re: Check constraint - SQL problem
Hi Mary,
I have just created table and added check constraint using alter
statement without any error on SQL SERVER 2000. Could you send more
detail about environment where you encountered this error.
Ash
http://www.astragalaxy.com


Report this thread to moderator Post Follow-up to this message
Old Post
Ash
07-24-05 02:31 PM


Sponsored Links





Last Thread Next Thread
Post New Thread

Microsoft SQL Server forum archive

Show a Printable Version Email This Page to Someone! Receive updates to this thread
Microsoft SQL Server
Access database support
PostgreSQL Replication
SQL Server ODBC
FoxPro Support
PostgreSQL pgAdmin
SQL Server Clustering
MySQL ODBC
Web Applications with dBASE
SQL Server CE
MySQL++
Sybase Database Support
MS SQL Full Text Search
PostgreSQL Administration
SQL Anywhere support
DB2 UDB Database
Paradox Database Support
Filemaker Database
Berkley DB
SQL 2000/2000i database
ASE Database
Forum Jump:
All times are GMT. The time now is 11:15 AM.

 
Mobile devices forum | Database support forum archive




Copyrights DropTable.com Database Support Forum 2004 - 2006