I am trying to do a query, but I keep getting the following error:
Must declare the scalar variable "@userId".
But as you can see from the sql below (simplified example), that variable is declared.
declare @userId uniqueidentifier = '76652631-bd15-22b2-1a00-6ae6ee1e101a'
USE MyDatabase
GO
SELECT * FROM [User] where UserId = @userId
Why is this happening?