t sql if exists multiple conditions

The solution for “t sql if exists multiple conditions” can be found here. The following code will assist you in solving the problem.

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

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

0
inline scripts encapsulated in