question

venkatreddy avatar image
venkatreddy asked

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..

sql-server-2005t-sqldatabase
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Matt Whitfield avatar image
Matt Whitfield answered

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]
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Kev Riley avatar image
Kev Riley answered

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

2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

venkatreddy avatar image venkatreddy commented ·
+1,thanks Kev...
0 Likes 0 ·
Matt Whitfield avatar image Matt Whitfield ♦♦ commented ·
+1 because your comment was worth rep :)
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.