July 22, 2008 at 9:31 am
I created a small table with multiple columns. I intended to make one of the columns "not null". I would like to use the alter table command to make that change but I can't seem to find the correct syntax. Here is what I've tried:
alter table tablename alter column columnname not null;
SQL complains that it doesn't understand 'not null' with this syntax. I've tried enclosing it in quotes, parenthesis, square brackets, but it likes none of those.
Any suggestions would be greatly appreciated.
July 22, 2008 at 9:42 am
You need to include the data type before the not null.
Alter table dbo.table
Alter Column column_name Int Not Null
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
July 22, 2008 at 10:05 am
Thanks, such a simple answer. I have a real problem finding good examples of such things either on the internet or in the SQL books online.
July 22, 2008 at 12:10 pm
Rodney
You can open your table in enterprize manager, make your changes, but instead of hitting the save button, there is another button that looks like a scroll, that will show you the script for the changes you just made.
Greg
_________________________________________________________________________________________________
The glass is at one half capacity: nothing more, nothing less.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply