I know that SQL Server Stored Procedure Stored in Folder which is inside Programmability. But I want to know Stored Procedures Object where it is stored in physical system.
In resource database:
SQL Server system objects, such as sys.objects, are physically
persisted in the Resource database, but they logically appear in the
sys schema of every database.
They're all read only and you cannot access the resource database directly, so is all academic. Why do you want to know?
General metadata about a database objects is available in the Object Catalog Views.
Related
I have a configurations database with a lot of stored procedures and then I have a large number of databases, all are part of one system and on the same database server.
When the stored procedures in the config database are executing, they often query other databases as well and it is possible to do so because the configuration and all the other database are on the same database server.
But with time, as the data is growing, customers are growing, databases are growing, this one database server is slowing down. So now we want to take some of our databases and put them on a different database server but we are unable to do so because these databases and the configuration database are tightly coupled to each other because many of the stored procedures in the config database query other databases as well.
Is there some way I can execute a stored procedure present in config database / Server A, but this stored procedure is also querying database 2 on Server B?
If not then what could be the best approach to decouple all the other databases from the configurations database? I know getting rid of the stored procedures by implementing an ORM or something could be an option but that would be very time taking as we 1000+ stored procedures.
Let's say your configure database is Server A and all your user databases are on Server A and your SP are using 3 part naming to query multiple databases.
Now you want to migration one of the databases (DB1) to Servers B. Now DB1 does not exist on Server A, it is now on Server B. You can then Create a place holder DB on Server A called DB1. Then you will create a linked server to Server B and in the Place holder DB1, you will create alias which uses the linked server object with the same table name. This way, no changes is required on your thousands of SP and its configuration.
However, Linked Server may introduce performance problems as joining and indexing is less efficient.
I am tasked with creating a stored procedure from a script I wrote which will update tables with data.
Since I run this script against a dev database and a live database, we have always manually changed the USE DATABASE in the script before running.
I am looking for a way to use USE DATABASE within a stored procedure.
Is this possible without having to create two stored procedures of the same script for each database (dev versus live)?
Assuming you mean MS SQL Server. You cannot use USE ... within a stored procedure, but you can directly reference a different database with fully qualified object notation.
database.schema.objectname
Example:
dev_mydb.dbo.MyTable
Do note though that if you need that database name to be variable then you will need to use dynamic SQL to set the dbname.
I need to share a few stored procedures into a single logic subset. In Oracle, I can create a "package" or class.
Is there a way do something similar in SQL Server 2012?
I don't want stay this procedures in main storage, I already have some hundreds of it.
Consider using different database schema (create your own) to logically separate your database objects (stored procedures). Packages don't exist in MS SQL.
I'm using SQL Server 2012 AlwaysOn listener and I want to use a connection with ApplicationIntent=ReadOnly parameter for calling some stored procedures, and this is my question: stored procedures which insert data into temp table can use connection with ApplicationIntent=ReadOnly ?
According to Readable Secondary Replicas
Note
Though you cannot write data to secondary databases, you can write to
read-write databases on the server instance that hosts the secondary
replica, including user databases and system databases such as tempdb.
So the answer is your stored procedures will work.
I'm trying to move SQL Server objects i.e.,tables,views,stored procedures,user defined functions from one database to another using Transfer SQL server objects Task in SSIS.
Tables,views are properly transferred into the destination database with the same schema name as in source database . However,some of the stored procedures and user defined functions are changed to one of the schemas in the destination database upon completing the transfer.
Any help is appreciated.
Thanks.