T-Sql syntax for concatenating variables

  • Hello all,

    I need to concatenate external arguments to an execute statement. Need the right syntax

    e.g

    declare @server varchar (30)

    declare @db varchar(30)

    exec [@server].[@db].[dbo].spu_procedure @remoteserver = @localServer output

    this statement gives me errors.

    Pls help

     

     

     

     

  • Use Dymanic SQL Statement.

  • pls how do i use dynamic sql statement

  • exec ('[' + @server + '].[' + @db + '].[dbo].spu_procedure ' + @remoteserver + ' = ' + @localServer + ' output')

  • Thanks

Viewing 5 posts - 1 through 4 (of 4 total)

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