User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MS SQL section within the Web Development category of DaniWeb, a massive community of 426,486 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,253 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MS SQL advertiser: Programming Forums

How to add not null column in SQL Server 2005

Join Date: Sep 2006
Posts: 104
Reputation: bhavna_816 is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
bhavna_816 bhavna_816 is offline Offline
Junior Poster

How to add not null column in SQL Server 2005

  #1  
Apr 7th, 2008
I have to add a not null column in a table.
I am using

IF NOT EXISTS(SELECT * FROM information_schema.columns WHERE column_name = 'xyz' 
AND table_name = 'abc') 	
BEGIN
	ALTER TABLE abc	WITH NOCHECK ADD xyz MONEY NOT NULL
END

It gives me error
ALTER TABLE only allows columns to be added that can contain nulls, or have a DEFAULT definition specified, or the column being added is an identity or timestamp column, or alternatively if none of the previous conditions are satisfied the table must be empty to allow addition of this column. Column 'xyz' cannot be added to non-empty table 'abc' because it does not satisfy these conditions.

can anybody have any idea, what's wrong with my SP?


?
Last edited by peter_budo : Apr 7th, 2008 at 5:25 am. Reason: Keep It Organized - please use [code] tags
AddThis Social Bookmark Button
Reply With Quote  
All times are GMT -4. The time now is 4:48 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC