My question is simple! How to delete a temporary stored procedure if exists? This is due to the fact that while I create a temporary SP in a script, it throws an error, for example: "There is already an object with the name" #sp_name "in the database, while I run it a second time. I do not want to show this message to users Please help me. Your solution is highly appereciated!
Temporary procs are discarded in the same way as permanent procs are discarded. See code below:
-- Create test temp. proc CREATE PROC #tempMyProc as Begin print 'Temp proc' END GO -- Drop the above proc IF OBJECT_ID('tempdb..#tempMyProc') IS NOT NULL BEGIN DROP PROC #tempMyProc END
IF EXISTS (SELECT * FROM sys.procedures WHERE name = 'baz') DROP PROCEDURE baz
Source: https://habr.com/ru/post/891948/More articles:Does BeginSend Container adapters do not support iterators - c ++IOS: write a line in a txt file from an array - stringDisable artifact publishing when build fails in TeamCity - continuous-integrationWrite the child entry and show zero if it is empty - c #Deny access, but allow robots, i.e. Google, sitemap.xml - web-crawlerDoes a multithreaded task not use a processor? - c #Why is void f (...) not allowed in C? - chow to align the grid in the center - extjsInfoWindow modern rectangle on maps.google.com - google-mapsAll Articles