इस क्वेरी को प्रक्रिया के रूप में उपयोग करें।
CREATE PROC ADD_CHECK
AS
BEGIN
DECLARE @COLUMN VARCHAR(50)
DECLARE @QUERY VARCHAR(255)
DECLARE @QUERY1 VARCHAR(255)
SET @COLUMN= (SELECT TOP 1 NAME FROM TABLE1 WHERE ID=(SELECT MAX (ID) FROM TABLE1))
IF EXISTS(SELECT 1 FROM TABLE1 WHERE [email protected])
BEGIN
SET @QUERY = 'ALTER TABLE TABLE2 ADD ' + @COLUMN + ' VARCHAR (50)'
SET @QUERY1 = 'ALTER TABLE TABLE2 ADD ' + @COLUMN + '_COMPLETEDDATE VARCHAR (50)'
EXEC(@QUERY)
END
END