0 votes
14 views

i use the statement drop trigger if exist TRIGGER in sqlite but sql server doesnt like the if statement. (i guess exist is the offending word). I do this right next to my create trigger statement because i want to drop older triggers with the same name so i can replace it with this new one. How do i do this in SQL server?

by (305 points)   | 14 views

1 Answer

0 votes

You can check for the existence of a specific Trigger like so.

IF EXISTS
(
select name
from sys.objects
where type='TR' and name ='Trigger Name'
)
BEGIN

--Add your Trigger create code here

END
by (305 points)  

Related questions

0 votes
1 answer
+3 votes
0 answers
+3 votes
3 answers
asked May 21, 2020 by athar (3.3k points) | 128 views
+3 votes
0 answers
asked Mar 20, 2020 by Rehan | 68 views
+1 vote
1 answer
asked Jun 13, 2020 by noor (1.1k points) | 13 views
+2 votes
0 answers
0 votes
1 answer
asked Jul 2, 2020 by toheed (1.4k points) | 67 views
+3 votes
1 answer
asked Apr 12, 2020 by athar (3.3k points) | 64 views




Welcome to Meansflow - Where Developers and Students Learn, Share, & Build Careers, where you can ask questions and receive answers from other members of the community.
131 questions
94 answers
44 comments
134 users