I stored a procedure called PROC_fetchTableInfo (a simple selection from sys.tables) in a database called
Cust
I would like to use this procedure in another database named
Dept
I tried to execute this sp in this database using the command
EXECUTE Cust.dbo.PROC_fetchTableInfo
but as a result, I get tables from the Cust database. How to make this procedure work in the Dept database?
. Cust.dbo.PROC_fetchTable T, T dbo Cust. , .
Cust.dbo.PROC_fetchTable
T
dbo
, , , : Dept.dbo.PROC_fetxTableInfo. , Dynamic-SQL. DRY , T-SQL - , , C/# mind . Dept.
Dept.dbo.PROC_fetxTableInfo
, Cust.dbo.PROC_fetchTableInfo, Cust. , Dept.
Cust.dbo.PROC_fetchTableInfo
( ) , , sproc.
, "Common" EXEC Common..PROC_fetchTableInfo @databaseName='Dept'
"Common"
EXEC Common..PROC_fetchTableInfo @databaseName='Dept'
( , ). , sp_ .
sp_
use master go CREATE PROCEDURE dbo.sp_sys_tables_select AS SELECT * FROM sys.tables GO EXEC sys.sp_MS_marksystemobject 'dbo.sp_sys_tables_select' GO EXEC tempdb.dbo.sp_sys_tables_select EXEC msdb.dbo.sp_sys_tables_select
Source: https://habr.com/ru/post/1769783/More articles:Как переместить динамический элемент HTML в правой части окна браузера? - jqueryRedirecting verbose output of YUI Compressor to a file - command-promptТип StructureMap запрашивается - structuremapFilter database results without running an additional query - databaseAdd loading graphics to Ajax jQuery UI tabs? - jqueryИсправить все черно-белые курсоры wx на окнах - matplotlibОтчет о доступе не позволит мне ссылаться на поле в VBA, если оно не будет указано в отчете самостоятельно - vbaLoading a large image in parts in a Timage component - image-processingDelete a unique constant in a table column without knowing the name of the constraint - sqlExamples of OpenNETCF.Net.Networkinformation - requesting Wi-Fi information - c #All Articles