SQL Server 2016 Developer — duplicate (do not use) SQL Server 2016 Enterprise — duplicate (do not use) SQL Server 2016 Enterprise Core — duplicate (do not use) SQL Server 2016 Standard — duplicate (do not use) More…Less
Symptoms
Consider the following scenario:
-
You use Transactional Replication publication environment in the following SQL Server versions:
-
-
Version before Cumulative Update 3 (CU3) for SQL Server 2016 Service Pack 2 (SP2)
-
Version before Cumulative Update 6 (CU6) for SQL Server 2017
-
-
You configure this server as a distributor and create a distribution database.
-
You add this server or another server as a publisher to this distributor server, but don’t create publication.
-
Later, you upgrade SQL Server to Cumulative Update 3 for SQL Server 2016 SP2 or later versions, or you upgrade SQL Server to Cumulative Update 6 for SQL Server 2017 or later versions.
In this scenario, when you remove publisher server from distributor, you may receive error messages that resemble the following:
Msg 2812, Level 16, State 62, Procedure sp_dropdistpublisher, Line LineNumber
Could not find stored procedure.
When you enable database for publication, you may receive error messages that resemble the following:
Msg 20028, Level 16, State 1, Procedure ProcedureName, Line LineNumber
The Distributor has not been installed correctly. Could not enable database for publishing.
The replication option ‘publish’ of database ‘DatabaseName‘ has been set to false.
Status
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the «Applies to» section.
Resolution
This issue is fixed in the following cumulative updates for SQL Server:
-
Cumulative Update 14 for SQL Server 2017
-
Cumulative Update 6 for SQL Server 2016 SP2
About cumulative updates for SQL Server:
Each new cumulative update for SQL Server contains all the hotfixes and all the security fixes that were included with the previous cumulative update. Check out the latest cumulative updates for SQL Server:
-
Latest cumulative update for SQL Server 2017
-
Latest cumulative update for SQL Server 2016
References
Learn about the terminology that Microsoft uses to describe software updates.
Need more help?
Want more options?
Explore subscription benefits, browse training courses, learn how to secure your device, and more.
Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.
-
September 24, 2010 at 12:37 pm
#238776
I am able to run the stored procedure in management studio.
when i create a dataset in BIDS, the metadata came up, but when i execute the stored procedure in a dataset, its giving me the following error.
«Could not find stored procedure. SQL Server error 2812»
Thanks for your help guys.
Satish
-
Luke L
SSC-Dedicated
Points: 35547
Make sure the user you are using to connect to the database has permissions to that stored procedure. Also, depending on the version of SQL you are using make sure that you’re using the correct owner/schema to call the stored procedure if it’s needed.
I.E. in 2000 and the owner is not DBO or the user callign the procedure you must specify the owner Exec owninguser.myprocedure
in 2005+ make sure you are specifying the schema if it’s not in the default schema of the user attempting to execute the procedure.
-Luke.
To help us help you read this[/url]For better help with performance problems please read this[/url]
-
SatishAyyar
SSCrazy
Points: 2825
All the permissions are good.Thanks for the reply.
I found the soultion. Its really crazy, I do not know why and how but it worked.
I droped the procedure and recreated and it worked like that.
Thanks
Satish
-
Luke L
SSC-Dedicated
Points: 35547
Were you the one that originally created the procedure? IF not, and this is a SQL 2000 instance, you were not the owner, therefor you would have needed to specify the owner. Since you dropped and recreated the procedure, you are now the owner and do not need to specify the owner, but other users will need to.
-Luke.
To help us help you read this[/url]For better help with performance problems please read this[/url]
-
SatishAyyar
SSCrazy
Points: 2825
I created the sp first and then I gave exec permissions to other person. so the other person got the error which I pasted. we tried and tried but worked only after I recreated the proc. I was the one who created the proc the first time and the second time also.
-
SatishAyyar
SSCrazy
Points: 2825
-
Luke L
SSC-Dedicated
Points: 35547
satishseth143 (9/24/2010)
Its SQL2008
Thanks for finally posting the version number. Sorry I assumed this was 2000 as that’s what the largest majority of articles I could find on this error number were dealing with. Glad you got it sorted.
-Luke.
To help us help you read this[/url]For better help with performance problems please read this[/url]
Viewing 7 posts — 1 through 6 (of 6 total)
- Remove From My Forums
-
Question
-
I had an error free transactional replication running between MSSQL 2000 (pub) and MSSQL 2008 R2 (sub). Because schema changes were disabled, I needed to delete the subscription and publication to add a new column to one of the replicated tables. I recreated
the publication and added the subscriber. The snapshot was recreated. Now when the distribution agent runs it fails with error 2812. The Distribution DB is on the 2008 R2 box and the subscribers are pull subscriptions.I ran a trace on the subscriber and found that the replcmd that was failing is ‘exec sp_MSins_z2t_Activity;2’. NOTE the ‘;2’.
I review the snapshot data and the replcmd script has CREATE PROCEDURE sp_MSins_z2t_Activity *without* ‘;2’. Hence the subscriber database as sp_MSins_z2t_Activity.
I deleted and recreated the pub/sub a couple of times with a *new* INS/DEL/UPD cmds and still get a ‘;2’ when the distribution agent runs. I understand the use of the ‘;2’, but it unnecessary.
So how can I fix this??
SteveB.
- Remove From My Forums
-
Question
-
The error below occur when I am setting up the pull transactionnal replication on SQLSERVER 2016. But if we change the replication to push replication it works.
My SQLSERVER VERSION IS 2016 SP1.
Could not find stored procedure ‘sys.sp_MSaddreplsymmetrickey’. Changed database context to ‘CoBRAClientData’. (.Net SqlClient Data Provider).
Please advise
Answers
-
The only solution for that is doing this.
1. Drop the encrypted key in the subscribers DB ,
2. Set up pull replication then it will work
3. Recreate the encrypted key.
Another workaround is to use Push replication instead of Pull.
Microsoft have to solve this issue as it happens with pull replication.
-
Marked as answer by
Tuesday, April 11, 2017 5:38 PM
-
Edited by
thotho Mabiku
Wednesday, May 3, 2017 4:16 PM
-
Marked as answer by
-
This is the solution:
Do <g class=»gr_ gr_14 gr-alert gr_gramm gr_inline_cards gr_run_anim Style multiReplace» data-gr-id=»14″ id=»14″>this :</g>
1. Drop the symmetric key and the certificate in the subscriber DB,s follow.
DROP
SYMMETRIC
KEY YourRSISEcureKeyGO
DROP
CERTIFICATE YourEncryptCertGO
IF
EXISTS
(
SELECT
*
FROM
sys.symmetric_keys
WHERE
name
=
N’Thenameofyoursymkey’
)
DROP
MASTER
KEYGO
2. Set up pull replication then it will work
3. recreate or restore the encrypted key after the replication is set up.
CREATE CERTIFICATE EncryptionCert
FROM FILE = ‘yourPath\yourEncryptCert.key’
WITH PRIVATE KEY ( FILE = ‘YourPath\YourEncryptionCertPrivateKey.key’,
DECRYPTION BY PASSWORD = ‘xxxxxxxx’ )
GOCREATE SYMMETRIC KEY RSISecureKey
WITH KEY_SOURCE = ‘<g class=»gr_ gr_24 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling» data-gr-id=»24″ id=»24″>yyyyyyyyyy</g>,
IDENTITY_VALUE = ‘<g class=»gr_ gr_25 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling» data-gr-id=»25″ id=»25″>zzzzzzzzzzzzzs</g>’,
ALGORITHM = AES_256
ENCRYPTION BY CERTIFICATE yourEncryptCert
GO4) Another workaround is to use Push replication instead of Pull.
-
Marked as answer by
thotho Mabiku
Tuesday, April 11, 2017 5:38 PM -
Edited by
thotho Mabiku
Wednesday, May 3, 2017 4:29 PM
-
Marked as answer by
In this SQL Server tutorial, we will discuss how to solve the “Could not find stored procedure in SQL Server” error. Additionally, we will also try to resolve some of the related errors which are given below.
- Could not find stored procedure in sql server
- Could not find stored procedure ”. (microsoft sql server error 2812)
- Could not find stored procedure ‘go’ sql server
- Could not find stored procedure ‘sp_dboption’ sql server
- Could not find stored procedure ‘sp_msforeachtable’ sql server
The error “Could not find stored procedure in SQL server” usually occurs when the SQL Server is unable to locate the specified procedure. The example related to this error is shown in the image below.
So, in this section, we will discuss some of the solutions that can help to overcome this error.
- SQL Server stored procedure case statement
Fix-1: Refresh IntelliSense
If we are using SQL Server Management Studio, as a first solution, we can try to refresh the IntelliSense local cache.
- For this implementation, click on the Edit option from the menu bar.
- After this select “IntelliSense” and then, click on “Refresh Local Cache“. Alternatively, we can also use the “Ctrl + Shift + R” shortcut for the same.
Fix-2: Check the Existence of the stored procedure
This error usually occurs when SQL Server is unable to find the specified stored procedure in the database. So, as a precaution, we can check the existence of that stored procedure in the database.
Now, this process is very easy, while using SQL Server Management Studio.
- For this, first, expand the database directory that you want to check.
- After this, expand the “Programmability” directory. And then, right-click on “Stored Procedures” and click on “Refresh” to refresh the Object Explorer.
- Next, expand the “Stored Procedures” directory now, if the procedure exists in that database then, it will be visible under “Stored Procedures“.
- Alter Stored Procedure in SQL Server
Fix-3: Permission to execute the procedure
Now, there can be one more reason behind this error while executing. The reason could be that we are using a role that does not have permission to execute the procedure.
In that case, we need to grant the EXECUTE permission to the role on that procedure.
For this implementation, we can use the following syntax.
GRANT EXECUTE ON OBJECT::dbo.YourProc TO YourRole;
Here is a simple example related to the above syntax. In the example, we are granting the EXECUTE permission of the “dbo.MaleStudents” stored procedure to the “DBA” role.
GRANT EXECUTE ON OBJECT:: dbo.MaleStudents TO DBA
Also, Read: Could not open a connection to sql server
Could not find stored procedure ‘go’ sql server
Now, in this section, we will discuss one more related error on “Could not find stored procedure“. This error states “Could not find stored procedure ‘GO’“. It simply means that the SQL Server could found the stored procedure with the name “GO“.
Now, the main reason behind this error could be the misuse of the “GO” statement.
In SQL Server, GO is a command which indicates the SQL Server utilities to send the current Transact-SQL batch to the SQL Server instance. All statements entered since the last GO are included in the current batch.
So, we should always use the GO command to specify the Transact-SQL batch for execution. And if we use this command in between at some wrong place then, this error may be encountered.
Read: SQL Server find text in stored procedure
Could not find stored procedure ‘sp_dboption’ sql server
In this section, we will learn how to resolve “could not find stored procedure ‘sp_dboption‘”. This error usually occurs when we try to execute the ‘sp_dboption‘ stored procedure.
In SQL Server, sp_dboption is a system stored procedure that is used to display or modify database options. But, this procedure is removed from SQL Server 2012 or later versions.
So, if we try to use this stored procedure in SQL Server 2012 or later editions then, we might get this error.
But, don’t worry there is an alternative for this stored procedure in SQL Server. So, instead of using sp_dboption, we can use the “ALTER DATABASE” command to modify a database. Moreover, we can also use the “sp_replicationdboption” stored procedure if we want to modify the database options associated with replication.
Here is an alternative example for sp_dboption in SQL Server.
ALTER DATABASE [MockData] SET AUTO_SHRINK ON
ALTER DATABASE [MockData] SET RECOVERY SIMPLE
In the above example, we have enabled the simple recovery mode for the MockData database. And, we have also enabled the auto shrink option that will shrink the data and log files for this database.
Read: Full-text search in SQL Server
Could not find stored procedure ‘sp_msforeachtable’ sql server
In this section, we will discuss how to resolve the “Could not find stored procedure ‘sp_msforeachtable‘” error. This error occurs only when the SQL Server is unable to find the ‘sp_msforeachtable‘ stored procedure. The complete error message is shown in the image below.
The sp_msforeachtable is a system stored procedure in SQL Server which executes the given statement for each table in the database. And the statement to execute is passed as a parameter to this procedure.
This is a system stored procedure so, it can execute from any database in SQL Server. So, this error usually occurs when your database collation is case-sensitive.
Because the exact name of this stored procedure is “sp_MSforeachtable” whereas we are using “sp_msforeachtable” at the time of execution.
So, the solution to overcome this is error is either by using the exact stored procedure name at the time of execution.
Or check and change the collation for your database from SQL_Latin1_General_CP1_CS_AS to SQL_Latin1_General_CP1_CI_AS. Where CS represents case-sensitive and CI represents case-insensitive.
Here are some of the steps that we can use to check and change the database collation property.
Fix-1: Use the correct procedure name
As discussed, the simple solution to overcome this error is by using the exact procedure name. The example for this implementation is shown below.
Use [sqlserverguides]
exec sp_MSforeachtable 'print "?"'
The above example simply returns the name of all the tables that are in the sqlserverguides database. The output for this is shown below.
Fix-2: Change the database collation
First, run the following query to check the collation for your database.
SELECT Name AS [Database Name],
collation_name as [Collation Name]
FROM sys.databases
If the collation for your database is set to the case-sensitive then, you need to change the collation property to case-insensitive.
ALTER DATABASE database
COLLATE SQL_Latin1_General_CP1_CI_AS
In the above query, we simply need to specify the name of the database for which we want to change that collation. The example for this is shown in the image below.
You may also like to read the following articles on SQL Server.
- What is a stored procedure in sql server
- SQL Server stored procedure modified date
- Try catch in SQL Server stored procedure
- Rename stored procedure in SQL Server
- SQL Server stored procedure parameters
- Stored procedure in SQL Server for insert and update
- Unable to retrieve data for this section of the report
In this tutorial, we have discussed how to solve the “Could not find stored procedure in SQL Server” error. Additionally, we also explained how to resolve some of the related errors which are given below.
- Could not find stored procedure in sql server
- Could not find stored procedure ”. (microsoft sql server error 2812)
- Could not find stored procedure ‘go’ sql server
- Could not find stored procedure ‘sp_dboption’ sql server
- Could not find stored procedure ‘sp_msforeachtable’ sql server
I am Bijay having more than 15 years of experience in the Software Industry. During this time, I have worked on MariaDB and used it in a lot of projects. Most of our readers are from the United States, Canada, United Kingdom, Australia, New Zealand, etc.
Want to learn MariaDB? Check out all the articles and tutorials that I wrote on MariaDB. Also, I am a Microsoft MVP.