Solved

SQL Stored procedure

Posted on 2015-01-17
2
73 Views
Last Modified: 2015-01-18
I have created a SQL Stored procedure in DatabaseA and it need to refer some tables stored in DatabaseB on the same server. What's the best way to reference those tables ?

Tks
0
Comment
Question by:AXISHK
2 Comments
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 300 total points
ID: 40555175
you can prefix with the database name:

select * from DatabaseB.dbo.tableName
0
 
LVL 10

Assisted Solution

by:HuaMinChen
HuaMinChen earned 200 total points
ID: 40556111
Hi,
Try
insert tab1 (...)
select ...
from DatabaseB.dbo.table2

Open in new window


to refer to the table on other DB
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question