Create SQL function:
USE DavidTest;
GO
IF OBJECT_ID ('dbo.fn_isUserActive') IS NOT NULL
DROP FUNCTION dbo.fn_isUserActive;
GO
CREATE FUNCTION dbo.fn_isUserActive (@userID int)
RETURNS int
WITH EXECUTE AS CALLER
AS
BEGIN
DECLARE @userStatus int;
DECLARE @isActive int;
SELECT @userStatus = ID FROM DavidTest.dbo.DavidUser WHERE ID=@userID ;
if(@userStatus is not null AND @userStatus = 3)
BEGIN
SET @isActive = 1;
END
ELSE
SET @isActive = 0;
RETURN @isActive;
END;
GO
Using the function:
SELECT dbo.fn_isUserActive(3);
SELECT * FROM dbo.DavidUser u where dbo.fn_isUserActive(u.ID) > 0;
SSIS: Can not execute dataflow in Visual Studio <->
// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.