x

how to invoke objects in another server databse?

how to invoke in objects(tables,stored procs,views etc..) in anathor server database from my current server database.THANKS IN ADVANCE..

more ▼

asked Apr 14, 2010 at 04:15 AM in Default

avatar image

venkatreddy
562 29 31 36

(comments are locked)
10|1200 characters needed characters left

2 answers: sort voted first

SQL Server supports 4 part object naming:

[<server>].[<database>].[<schema>].[<object>]

So, you can call things in other servers (linked servers) or databases just by including the relevant identifier.

For example, calling a procedure in another database on the same server:

EXEC [OtherDB].[MySchema].[MyProc]
more ▼

answered Apr 14, 2010 at 04:19 AM

avatar image

Matt Whitfield ♦♦
29.5k 62 66 88

(comments are locked)
10|1200 characters needed characters left

You could use Linked Servers and then reference the objects by:

server.database.schema.object

For more ad-hoc requests, you can also use OPENROWSET and OPENDATASOURCE

more ▼

answered Apr 14, 2010 at 04:22 AM

avatar image

Kev Riley ♦♦
64k 48 61 81

+1,thanks Kev...

Apr 14, 2010 at 04:41 AM venkatreddy
  • because your comment was worth rep :)

Apr 14, 2010 at 06:33 AM Matt Whitfield ♦♦
(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x2018
x1066
x273

asked: Apr 14, 2010 at 04:15 AM

Seen: 1280 times

Last Updated: Apr 14, 2010 at 04:23 AM

Copyright 2016 Redgate Software. Privacy Policy