sql - How to create a Stored Procedure with dynamic Schema -


  Create MySchema. Select MySpName as MyTable Conclusion   

As you can see above, there is a stored procedure in the schema MySchema , I dynamically do this schema I want to use.

As I have many different schemas like MySchema1 , MySchema2 . Suppose I want to execute my above stored procedure in schema MySchema1 , so I want my stored procedure schema MySchema1.MySpName

Any suggestions with.

There is no way to make a process without specifying the schema and any object was created for it SQL Server is bound to schema. This is a security barrier implemented in SQL Server 2005 SQL Server.

All objects in SQL Server should be under a specific schema. Now in your case you have two options.

  1. Make this process in every database in your schema.

  2. Create a process Accept this object name and schema name within any one schema and process.

    Example

      The process of making the process is DB.PROG_N @Satinnam Navaarar (128), @tabnnnn Op note starting as NHA CAR (128); DECLARE @Sql NVARCHAR (max); SET @Sql = N 'SELECT * FROM' + QUOTENAME (@SchemaName) + N '.' + QUOTENAME (@TableName) EXECUTE sp_executesql @sql END   

    This process will now be under default schema, but you have to run the schema name and object name at run time to call object from various schemas. can do.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -