The SP sp_executesql is a system SP in system database "master"; so you have to add a reference to the system DB in your SSDT project, see
Selecting the Database to Reference
SSSDT Procedure has undresolved reference to object sp_executesql

Configuration: VS Enteprise 2019, 16.8.2, Latest SQL Server Data Tools (SSDT), Windows 10
Issue: including any of the following statements in a stored procedure generates the following warning
SQL71502 Procedure ... has an unresolved reference to object [schema].sp_executesql
Examples:
EXEC @ExecRet = master.sys.sp_executesql @tsql , N'@val VARCHAR(MAX) OUTPUT', @val = @TmpStr OUTPUT;
OR
EXEC @ExecRet = sp_executesql @tsql , N'@val VARCHAR(MAX) OUTPUT', @val = @TmpStr OUTPUT;
2 answers
Sort by: Most helpful
-
Olaf Helper 27,136 Reputation points
2020-11-27T07:16:15.663+00:00 MelissaMa-MSFT 24,131 Reputation points2020-11-27T07:24:40.54+00:00 Hi @Gary Furash ,
Please try to add a database reference to master as below:
- Under the project, right-click References.
- Select Add database reference....
- Select System database.
- Ensure master is selected.
- Press OK.
Reference:Warning SQL71502 - Procedure <name> has an unresolved reference to object <name>
Best regards
Melissa
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.Hot issues November--What can I do if my transaction log is full?
Hot issues November--How to convert Profiler trace into a SQL Server table