March 11, 2008 at 1:55 pm
Bare with me, my knowledge of SQL Server is next to nothing as you can see by the famous AdventureWorks database I am working on. 🙂
Originally what I was trying to do is use the ALTER statement to add a primary key to a table that didn't have one. I first added CountryID column to the Country table with the ALTER statement but didn't specify the nulls. Apparently you can't add a Primary key unless NOT NULL is specified.
So I tried to modify the column with the graphic modify option and when I change the NULL or change the datatype nothing gets update. I tried hitting refresh on the database..nothing. I'm obviously missing something here. So does the modify option work? How do you get it to update the tables?
March 11, 2008 at 2:29 pm
There should be a save option. T-SQL is always cleaner 🙂
alter table Countries
drop column CountryID
go
alter table Countries
add CountryID int IDENTITY(1,1) PRIMARY KEY NOT NULL
go
Tommy
Follow @sqlscribeMarch 11, 2008 at 2:41 pm
I did try the save option but I was getting someone kind of transport error? It was weird but it wouldn't let me save it.
Thanks that code did work..though the Countries part was a bit off(Its Country 😉
Also when I executed the code and refreshed the database the object explorer didn't update the changes until I hit refresh like 3 times. Is that normal?
March 11, 2008 at 3:08 pm
NP 🙂
Seems to happen to me every so often although I must admit I don't use the UI that much 🙂
Tommy
Follow @sqlscribeViewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply