SQL Server 2005 Setting a variable to the result of a select query

前端 未结 6 999
面向向阳花
面向向阳花 2021-02-05 00:31

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 =          


        
6条回答
  •  难免孤独
    2021-02-05 00:54

    This will work for original question asked:

    DECLARE @Result INT;
    SELECT @Result = COUNT(*)
    FROM  TableName
    WHERE Condition
    

提交回复
热议问题