Friday, October 10, 2014

How to run the tables & Store procedure from one database to another database using SQL Server

How to run the tables & Store procedure from one database to another database using SQL Server


For Execution the Table


EXEC sys.sp_dropserver @server = 'VCNSQL90.sample.com', @droplogins = 'droplogins';

EXEC master.dbo.sp_addlinkedserver @server = N'VCNSQL90.webhost4life.com', @srvproduct=N'VCNSQL90. sample.com', @provider=N'SQLNCLI', @datasrc=N'VCNSQL90. sample.com'

 /* For security reasons the linked server remote logins password is changed with ######## */

EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'VCNSQL90. sample.com',@useself=N'False',@locallogin=NULL,@rmtuser=N'sa',@rmtpassword='**********'

GO

exec sp_serveroption @server='VCNSQL90. sample.com', @optname='rpc', @optvalue='true'

exec sp_serveroption @server='VCNSQL90. sample.com', @optname='rpc out', @optvalue='true'

SELECT * FROM ['VCNSQL90. sample.com].smartfleetproduct.dbo.DataSendingDetails



For Executing the Storeprocedure



EXEC sys.sp_dropserver @server = 'VCNSQL90.sample.com', @droplogins = 'droplogins';

EXEC master.dbo.sp_addlinkedserver @server = N'VCNSQL90.webhost4life.com', @srvproduct=N'VCNSQL90. sample.com', @provider=N'SQLNCLI', @datasrc=N'VCNSQL90. sample.com'

 /* For security reasons the linked server remote logins password is changed with ######## */

EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'VCNSQL90. sample.com',@useself=N'False',@locallogin=NULL,@rmtuser=N'sa',@rmtpassword='**********'

GO

exec sp_serveroption @server='VCNSQL90. sample.com', @optname='rpc', @optvalue='true'

exec sp_serveroption @server='VCNSQL90. sample.com', @optname='rpc out', @optvalue='true'

EXECUTE ['VCNSQL90. sample.com].smartfleetproduct.dbo.AlertAll






No comments:

Post a Comment