Click here to Skip to main content
15,896,269 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have designing in my web page .my database table the id is allow null value i have set ok.i had store the value in table.but i want Id values not allow null value .how to change in my table
Posted
Comments
Prerak Patel 23-May-11 5:47am    
Try to rephrase you question. Not allowing null for ID field is not a big task I guess.

In Enterprise manager, it is very easy, just remove check mark from "Allow Nulls".

Try following statements one by one,
SQL
UPDATE [Table] SET [Column]=0 WHERE [Column] IS NULL
ALTER TABLE [Table] ALTER COLUMN [Column] INTEGER NOT NULL
 
Share this answer
 
v2
Right click on the table and select 'Modify'. Un-check the 'Allow Nulls' checkbox on the appropriate column and save. The table should either be empty or ensure that the column does not contain any null values before you proceed.
 
Share this answer
 
Assuming you are using SQL Server, do you have SQL Server Management Studio Express installed? If not install it. Then use it to connect to your server / database and modify your table - untick the Allow Nulls box for your ID field and save. If you are using Linq, you then need to remove / re-add the table to your data context so that your code picks up the change.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900