I created a database in Sql Server 2000, unless I made atleast one field in the table as "Unique", I could not insert data into table. But no-where in the documentation , books or Sql server online I could get a text saying we need atleast one Unique Key per table.
If anyone has expertise please confirm this.
Regards
[Sham]

Dani AI

Generated

Short answer: No — SQL Server 2000 does not force every table to have a UNIQUE or PRIMARY KEY. is correct. A table without any unique constraint is perfectly legal; inserts fail only when some other rule, constraint, permission or client limitation prevents the operation. See Microsoft documentation on primary keys and unique constraints for background: .

Diagnose by isolating server vs client behavior. Run an explicit INSERT in Query Analyzer (or osql) and capture the exact error text. Inspect the table DDL and constraints — ’s idea to generate the CREATE script is exactly the right next step. Helpful server-side checks:

EXEC sp_help 'dbo.YourTable';
EXEC sp_helpconstraint 'dbo.YourTable';
SELECT name FROM sysobjects WHERE xtype='TR' AND parent_obj = OBJECT_ID('dbo.YourTable');

If the INSERT works in Query Analyzer but fails when using Enterprise Manager, an ODBC driver, or an ADO Recordset, it’s likely a client-side limitation: many GUI editors and some cursor/lock types require a unique key to build updatable recordsets. Adding a primary key or unique index fixes that for the client, and is good practice for row identity (see ).

If the INSERT fails in Query Analyzer too, look for server-side causes: NOT NULL columns without default values, CHECK or FOREIGN KEY violations, triggers that roll back inserts, permission or database read-only issues. Capturing the exact server error and the table DDL (use Generate SQL or the sp_help output above) is the reliable way to identify the true cause. ’s prompt to confirm whether a row insert (not DDL) was intended is also important when interpreting the failure.

Recommended Answers

All 4 Replies

are you sure that you inserted it correctly? defenitely there is no rule like that in sql server 2000

are you sure that you inserted it correctly? defenitely there is no rule like that in sql server 2000

Yes I tried several ways, thr' ODBC, thr' ADO recordset, directly using Enterprise Manger etc, I could not insert record anyways.

I could not get anywhere in the Microsoft's help etc but still getting this problem.

Regards
[Sham]

Are you inserting a table or a record? If you are trying to insert a record the table amy have been created with an requirement of one or more of the fields.

In cases like this I find that having a look at the SQL code generated for the table will often turn up some remarkable facts about the table / column in question.

To get this code go into enterprise manager, open the relevant database, open the table list, right click on the table name, choice ALL TASKS, then Generate SQL. The code script generated will be that which would recreate the table and any constraints imposed upon that table or its columns.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.