I created a table with three columns in it:
UserId, password and username. However, I want to add in a fourth column for the GUID.
I'm incredibly new to SQL so I apologize if the problem turns out to be plain and clear.
IF NOT EXISTS (SELECT *
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = 'dbo'
AND TABLE_NAME = 'Users'
AND COLUMN_NAME = 'userGuid')
Begin
CREATE TABLE [Users](
[UserId] [int] IDENTITY(1,1) NOT NULL,
[username] [varchar](50) NOT NULL UNIQUE,
[password] [varchar](50) NOT NULL
/*userGuid uniqueidentifier NULL*/
)
ALTER TABLE Users Add userGuid uniqueidentifier NULL
ENDSomeone suggested I try adding in a 'Commit Statement'.
I placed the commit statement in between the 'ALTER TABLE Users' statement and the 'END' Statement.
I execute both across my table, flip over to the DESIGN view, still nothing. I have my three columns but not the fourth.
This relates to an error I'm getting in VS: 'Invalid Column name 'userGuid'', but I won't get into that because I'm almost certain that the issue is that I don't actually have a userGuid column.