I am new to T-SQL and wanted to know why the following works and does not raise and error:
I have :
DECLARE @aVARCHAR(200), @b VARCHAR(100)
SET @a = (Some complicated SELECT Statement)
SET @b = 'ALTER TABLE abc DROP CONSTRAINT ' + @a; <-------- expected it to contain string.
Exec(@b);
The first set has a complex select statement which returns NO rows.
I then expected @b to have the string 'ALTER TABLE abc DROP CONSTRAINT ' BUT it is empty when debugging. This is what I found confusing. Why is this happening?
I am using SQL Server Express 2008.