Searching for a schema for a stored procedure other than tables (error?)

If you run the following on sql server:

CREATE SCHEMA [cp]
GO

CREATE TABLE [cp].[TestIt](
    [ID] [int] NULL
) ON [PRIMARY]
GO

CREATE PROCEDURE cp.ProcSub
AS
BEGIN
    Print 'Proc Sub'
END
GO

CREATE PROCEDURE cp.ProcMain
AS
BEGIN
    Print 'Proc Main'
    EXEC ProcSub
END
GO

CREATE PROCEDURE cp.ProcMain2
AS
BEGIN
    Print 'Proc Main2'
    SELECT * FROM TestIt
END
GO

exec cp.ProcMain2
GO

exec cp.ProcMain
GO

You will receive an error message

Could not find stored procedure "ProcSub"

This makes it impossible to divide procedures into a circuit without hard coding the circuit in the execution call. Whether it is by design or error, since the selection in the tables is first considered in the procedure diagram.

If someone has a job, I would be interested to hear it, although the idea is that I can give the developer two stored procedures that call each other and can put any circuit that they like in their own database, that they can be launched with the goal of being a utility that looks at the objects of another given circuit in the same database.

, , , , , .

+4
1

, ​​ .

, sql , dbo ( ). .

:

SQL Server 2005, . ​​ DEFAULT_SCHEMA CREATE USER ALTER USER. DEFAULT_SCHEMA undefined, dbo .

https://technet.microsoft.com/en-us/library/ms190387%28v=sql.105%29.aspx

+2

All Articles