From SQL Server Management Studio I have connected to an SQL Server database engine. This database engine has a lot of databases. From a store procedure defined in a database I am trying to call a store procedure in another database that it is in another SQL Server database engine. So I have done:
exec [MyDatabaseEngine].[MyDatabase].[MyStoreProcedure] param1, param2
But it is not working.
I do not know if I have explained it correctly. If not, please let me know.
You are missing the schema. The format is [LinkServer].[Database].[Schema].[Object]
You need to have linked server created with credentials access to the other database. More info
https://learn.microsoft.com/en-us/sql/relational-databases/linked-servers/create-linked-servers-sql-server-database-engine
Once you have it, you can run queries on another server
SELECT name FROM [SRVR002\ACCTG].master.sys.databases ;
GO
Related
I am migrating on premises SQL server database to Azure PaaS SQL database using Data Migration Tool. I am not using Data Migration Service Instance mechanism to migrate the database as it would require VPN on the corporate network and I do not see any benefit doing that way in my case.
There is one error which I am stuck on and a bit confused. When migrating a stored procedure which use automation stored procedures, I get the following error:
When I run Alter procedure script directly on Azure SQL database , I get this error;
Reference to database and/or server name in 'MASTER..sp_OACreate' is not supported in this version of SQL Server.A few answers to similar question on stackoverflow suggest that Azure SQL does not support automation stored procedures but the Microsoft link has a green tick against Azure SQL which suggest it does; https://learn.microsoft.com/en-us/sql/relational-databases/stored-procedures/ole-automation-sample-script?view=sql-server-2017.
A snippet of the sp is:
Is it true that automation stored procedures are not supported in Azure SQL and if thats hte case then what is hte workaround apart from rewriting the sp?
SQL Azure prevents you from calling server resources. sp_OACreate attempts to create a reference to an OLE object on the server; that's simply not allowed on Azure SQL Database. So you will need to redesign your solution to move this type of logic in a middle-tier of some kind, such as a Web Role in Windows Azure.
Anyone has the idea how to get this through?
I have a production and a test server. I created a linked server of production on the test server machine. I can do all DML that affects the production server from the test server, but I cannot see the stored procedure object of the production server on the test server.
RPC and RPC Out is already True.
I hope this will help you.
Using sp_HelpText you get entire SP text.
EXEC [ServerName].[DatabaseName].dbo.sp_HelpText 'SPName'
I am trying to publish a SQL Server database using a .dacpac and publish profile to an Azure SQL database. We have been using on premises SQL Server with no problems for quite some time, and now we are evaluating Azure and AWS to see which is best suited for our needs.
We have a SQL Server database project and want to deploy it to Azure SQL database, however it fails to execute the script generated by SSDT. This is because the generated script contains a call to the stored procedure sp_MSforeachtable which does not exist in Azure SQL.
I also have changed the target platform from SQL Server 2016 to Azure SQL V12. I am trying this from Visual Studio 2017's publish profile and from VSTS Release management using Azure SQL database deployment task. An of course by providing the necessary .dacpac and publish.xml files in the task.
I know I can manually add the stored procedure, however it doesn't seem that is what is intended by these publishing/deployment methods. Does anyone have any ideas?
Thanks
sp_MSforeachtable is an undocumented stored procedure in the Master database. This apparently hasn't been ported over to Azure SQL. I believe you'll need to add it manually to the Master database. Once that is done, your DACPAC should work just fine on your own Azure SQL database. I don't see a problem with manually adding sp_MSforeachtable. DACPACs are meant to keep your database in sync, not the Master database.
This feature is not implemented in SQL Database in Azure.
You can find a copy of it at this location: https://gist.github.com/metaskills/893599
Correct, sp_MSforeachtable stored procedure is still missing in Azure SQL, but you can easily create it manually. It is very helpful when you have to rebuild indexes for all tables at once:
exec sp_MSforeachtable #command1="DBCC DBREINDEX ('?', '', 80)"
At work, I'm able to connect to several SQL Server databases which I can write code to query from. I would like to be able to have my own database on my own computer at home so that I can practice writing queries.
So according to https://msdn.microsoft.com/en-us/library/ms186312.aspx, the steps that I should follow is:
Using SQL Server Management Studio
To create a database
In Object Explorer, connect to an instance of the SQL Server Database Engine and then expand that instance.
Right-click Databases, and then click New Database.
So I'm kind of stuck on step one because I don't have any database / servers/ instances (I may be using the wrong terminology here). How do I get one? I would really appreciate it if someone can give me a high leveled overview of how everything is related.
1) Instal SQL server to your local PC, some help you can find here https://learn.microsoft.com/en-us/sql/database-engine/install-windows/install-sql-server-from-the-installation-wizard-setup
2) Connect to your SQL server
3) Clicl "New Query" and exec
create database test
This stmt will create DB with name "test" and default properties
how to insert data from one database table to another database table in sql server 2008 When i am using web database and local Database on my pc. I want to get updated records from web sql server database into local database table through Store Procedure. what i have to do this? Pls help me to resolve this problem.
Check linked server. http://www.jensbits.com/2010/11/10/create-linked-server-sql-server-2008/
after link the web server in to your local server, can access data easily.