How do I set a variable to the result of select query without using a stored procedure?
I want to do something like: OOdate DATETIME
SET OOdate =
-- Sql Server 2005 Management studio
use Master go DECLARE @MyVar bigint SET @myvar = (SELECT count(*) FROM spt_values); SELECT @myvar Result: 2346 (in my db)
use Master go DECLARE @MyVar bigint SET @myvar = (SELECT count(*) FROM spt_values); SELECT @myvar
-- Note: @myvar = @Myvar