sp_executesql issue

  • Hello:

    This is the message I am getting when I build a string with SQL commands and execute that string with sp_executesql. I have also tried EXEC(). With EXEC, I can't have GO in the string that I build. So that is ruled out.

    Why I am getting this error message,

    Server: Msg 2812, Level 16, State 62, Line 329

    Could not find stored procedure 'master..sp_ExecuteSQL'.

    I have removed 'master..' before sp_ExecuteSQL and tried, that doesn't work either.

    Is there another way that I can get the string with SQL commands executed.

    -R

  • Can we see the while code?

  • Permissions on that proc are set to 'public', so it should work. Can you see it in the master database?

    This worked fine when I tested it locally:

    declare @sql nvarchar(2000)

    set @sql = N'select * from sysusers; exec sp_who;'

    exec master..sp_executesql @sql

     

     

     

    ----------------------------------------------------The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood... Theodore RooseveltThe Scary DBAAuthor of: SQL Server 2017 Query Performance Tuning, 5th Edition and SQL Server Execution Plans, 3rd EditionProduct Evangelist for Red Gate Software

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply