SQL Server administration and T-SQL development, Web Programming with ASP.NET, HTML5 and Javascript, Windows Phone 8 app development, SAP Smartforms and ABAP Programming, Windows 7, Visual Studio and MS Office software
Development resources, articles, tutorials, code samples, tools and downloads for ASP.Net, SQL Server, Reporting Services, T-SQL, Windows, AWS, SAP HANA and ABAP


Could not find stored procedure 'sp_executeSQL'.

SQL developers may experience Could not find stored procedure 'sp_executeSQL'. error when executing sp_executeSQL procedure on a SQL Server database with case sensitive collation. If the SQL command is written not exactly as the database objects created, such error will happen frequently on case sentitive collation SQL databases.

Here is the case I first time experienced the SQL error when I execute a very simple SQL command:
Msg 2812, Level 16, State 62, Line 5
Could not find stored procedure 'sp_executeSQL'.

exec sp_executeSQL N'select 1'
Code

Could not find stored procedure sp_executeSQL

And when I check the database collation using following SQL statement, I see that the database is created with a case sensitive collation.

SELECT Convert(varchar, DatabasePropertyEx(DB_Name(),'collation'))
Code

I can see that the database collation is configured as "Turkish_CS_AS" Turkish Case Sensitive, Accent Sensitive which is causing the SQL Engine to throw error related with not found sp_executeSQL system stored procedure.

check database collation on SQL Server using T-SQL

Fortunately, although the error is odd, the correction is simple. Just write the SQL codes for the database object names in the correct case as they are created.

For example, instead of using sp_executeSQL, code using sp_executesql which will be successfully executed.



SQL Server

SQL Server 2019 Installation
download SQL Server 2019
download SQL Server 2017
download SQL Server 2016
download SQL Server 2014
download SQL Server 2012
MacOS ve SQL Server 2019


Copyright © 2004 - 2021 Eralper YILMAZ. All rights reserved.