I'm stuck at a point with my queries.
I have a table with some project, first I'd like to check if All of my projects are in my table and store the result in a variable
So I have something like:
SELECT [ProjectID]
FROM [DB].[dbo].[Project]
EXCEPT
SELECT [ProjecID]
FROM [DB].[dbo].[CurrentProject]
WHERE ResourceId = (SELECT ResourceId
FROM [DB].[dbo].[Timesheets]
WHERE @TimesheetUID = TimesheetId)
If I try to use
DECLARE @STOREVAR UNIQUEIDENTIFIER
@STOREVAR = SELECT [ProjectID]
FROM [DB].[dbo].[Project]
EXCEPT
SELECT [ProjecID]
FROM [DB].[dbo].[CurrentProject]
WHERE ResourceId = (SELECT ResourceId
FROM [DB].[dbo].[Timesheets]
WHERE @TimesheetUID = TimesheetId)
I need to store in my variable because after that, I have to do a IF with @storevar
It's not working, have you any idea of how could I do that?
select @StoreVar = ProjectId from ...? That will work if you are certain the the query will never return more than one value. Tip: "It's not working" isn't much to go on. If you read that would you ask "How does it fail?" "I get an error." "Are you at liberty to disclose it?" "Yes" ...