populate one variable with the results from anothe

  • Is it possible to populate one variable with the results from another?

    Example: SET @DBBACKUP = (EXEC @CMD_MDATE).

    I have already populated @CMD_mdate, and would like to use its results in another variable.

    Thank you

    Stacey W. A. Gregerson


    Stacey W. A. Gregerson

  • Hi Stacey,

    quote:


    Example: SET @DBBACKUP = (EXEC @CMD_MDATE).


    you mean something like

    declare @a datetime

    declare @b-2 datetime

    set @a = getdate()

    set @b-2 = @a

    print @b-2

    or is @CMD_MDATE some T-SQL (SELECT, blah,blah...) command?

    Cheers,

    Frank

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • IS THIS IS WHAT U R LOOKING FOR....

    DECLARE

    @SQLINDEXTABLENAME VARCHAR (200),

    @SQL_STMT NVARCHAR(4000)

    SET @SQL_STMT ='SELECT @SQLINDEXTABLENAME = NAME FROM SYSOBJECTS WHERE ID = 5;

    '

    EXEC SP_EXECUTESQL @SQL_STMT, N'@SQLINDEXTABLENAME VARCHAR(200) OUTPUT', @SQLINDEXTABLENAME OUTPUT

    PRINT @SQLINDEXTABLENAME

    Cheers..Prakash

    Prakash

    Prakash Heda
    Lead DBA Team - www.sqlfeatures.com
    Video sessions on Performance Tuning and SQL 2012 HA

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply