I'm looking for a way to return a bit representing whether 2 ints are equal. When I try the following I get "Incorrect syntax near '='." What am I missing? I'm using SQL Server 2005.
DECLARE @Table1Count AS INT
DECLARE @Table2Count AS INT
SELECT @Table1Count = COUNT(*) FROM Table1
SELECT @Table2Count = COUNT(*) FROM Table2
PRINT @Table1Count = @Table2Count
Thanks.
IF @Table1Count = @Table2Count
PRINT 1
ELSE
PRINT 0
alternately:
PRINT CASE WHEN @Table1Count = @Table2Count THEN 1 ELSE 0 END
DECLARE @Table1Count AS INT
DECLARE @Table2Count AS INT
SELECT @Table1Count = COUNT(*) FROM Table1
SELECT @Table2Count = COUNT(*) FROM Table2
PRINT case when @Table1Count = @Table2Count then '1' else '0' end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With