hy, i have 2 database. DB1 & DB2.
i create SP in DB1. in the SP, i want to access table "TBL" in DB2.
how can i create that SP??

CREATE PROCEDURE test 

AS
BEGIN
??????????
END;

Thx,

The syntax

SELECT * FROM [DATABASENAME].[SCHEMA].[TABLE]

So let's say you're in the Northwind database and you wanted to query a table in the Pubs database, you would do the following:

SELECT * FROM Pubs.dbo.Authors

thx,

its work!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.