I would like to add a new column to an existing table (the type of the column is UNIQUEIDENTIFIER DEFAULT NULL), and I want to populate the column with a value grabbed from a subquery like below:
ALTER TABLE [Kohi].[dbo].[CalendarNote] ADD [PlannerId] UNIQUEIDENTIFIER DEFAULT NULL DECLARE @COLLECTION_ID UNIQUEIDENTIFIER SELECT @COLLECTION_ID = [ShiftCollectionId] FROM [Kohi].[dbo].[ShiftCollection] WHERE [Name] = 'XXXXX' UPDATE [Kohi].[dbo].[CalendarNote] SET [PlannerId] = @COLLECTION_ID WHERE [PlannerId] IS NULL
When I run the query, I have got a error saying 'Invalid column name 'PlannerId''. Does anyone know how to get this to work? Thank you!