Execute varible value on remote server database

  • Hi,

    i am working on a store procedure and within that procedure i have one varible that contain the structure of create procedure and i want to execute that varible on other server database remaining within that current procedure. is there any command that will execute that varible on remote pc like execute [servername].[dbo] .. etc

    Thanks and looking forward.

    -MALIK

  • server.master.sys.sp_executesql

    Here is an example

    declare @sql nvarchar(2000)

    set @sql = 'create procedure test as select * from sysdatabases'

    exec [liked server].master.sys.sp_executesql @sql

    Kenneth

    Kenneth FisherI was once offered a wizards hat but it got in the way of my dunce cap.--------------------------------------------------------------------------------For better, quicker answers on T-SQL questions, click on the following... http://www.sqlservercentral.com/articles/Best+Practices/61537/[/url]For better answers on performance questions, click on the following... http://www.sqlservercentral.com/articles/SQLServerCentral/66909/[/url]Link to my Blog Post --> www.SQLStudies.com[/url]

  • Thanks for the reply, but after executing the script you send i m getting this error message.. do u hv any idea

    Msg 7411, Level 16, State 1, Procedure MODIFIEDPROCEDURE, Line 85

    Server 'SQLSEVERNAME' is not configured for RPC.

  • Thanks i have solved the problem...

    -MALIK

  • Sorry I should have mentioned you have to go into the advanced tab and change that.

    Glad you found it though 🙂

    Kenneth

    Kenneth FisherI was once offered a wizards hat but it got in the way of my dunce cap.--------------------------------------------------------------------------------For better, quicker answers on T-SQL questions, click on the following... http://www.sqlservercentral.com/articles/Best+Practices/61537/[/url]For better answers on performance questions, click on the following... http://www.sqlservercentral.com/articles/SQLServerCentral/66909/[/url]Link to my Blog Post --> www.SQLStudies.com[/url]

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

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