Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

t sql if exists multiple conditions

IF EXISTS(SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'X' AND COLUMN_NAME = 'Y') 
AND EXISTS(SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'Z' AND COLUMN_NAME = 'A')

BEGIN
    UPDATE [dbo].[X] 
        SET Y= (SELECT inst.[A] FROM [dbo].[Z] s WHERE s.[B] = [dbo].[x].[B]);
END    
GO
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #sql #exists #multiple #conditions
ADD COMMENT
Topic
Name
6+1 =