Before posting this question, I have tried so many things but that was not helpful for me.
I want to rename the column of table at sql server 2005, following query I have run at sql server2005:
1) ALTER TABLE Details RENAME COLUMN
AccountID TO UID; but it gives me the
error: Incorrect syntax near the
keyword ‘COLUMN’.2)I have added one new column in the
table by query: ALTER TABLE Details
ADD BID uniqueidentifier; and then I
want to set the coulmn property to not
null .
How can i do that?
Thanks in advance
AS
Use
sp_Rename 'TableName.Column', 'NewColumnName', 'COLUMN'.In order to do your second part of the question, you’ll need to do:
If you don’t want to specify a default value, you’ll have to first create the column with
NULL. Once the column is created, you can then populate with your desired values and then re-alter the column toNOT NULL.