•
•
•
•
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 373,936 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,491 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:
Views: 2672 | Replies: 2
![]() |
•
•
Join Date: Sep 2006
Posts: 104
Reputation:
Rep Power: 2
Solved Threads: 0
I have to add a not null column in a table.
I am using
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?
?
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
You can't, simply when you add a column all rows before this adding have this column = null, so you can remove all rows and add a non-nullable column.
B.Sc Computer Science, Helwan University
Microsoft Student Partner
Personal blog http://ramymahrous.blogspot.com/
Arabic technical blog http://fci-h-ar.blogspot.com/
English technical blog http://fci-h.blogspot.com/
Microsoft Student Partner
Personal blog http://ramymahrous.blogspot.com/
Arabic technical blog http://fci-h-ar.blogspot.com/
English technical blog http://fci-h.blogspot.com/
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb MS SQL Marketplace
•
•
•
•
ad ad server ad serving advertising ajax architecture asp backup beta business centro crash daniweb database dell developer development doubleclick enterprise google hacker hyper-v internet linux longhorn mail management studio 2005 microsoft mmorpg msdn news novell office open qmail red hat rhel security server server 2008 smtp software source sql survey suse vista vmware windows windows server
- Open In New Window Php (PHP)
Other Threads in the MS SQL Forum
- Previous Thread: retrieval of unique data
- Next Thread: Info needed regarding SQL server 2005


Linear Mode