Disable Specific Triggers Based On SYS.SQL_MODULES DEFINITION

sql_server_logo

April 7, 2015 | Posted in SQL Server, Uncategorized

declare @temp table
(table_name varchar(100), trigger_name varchar(100))
insert into @temp
select    object_name(parent_id), name
from    sys.triggers
where    name in
(
select object_name(object_id) from sys.sql_modules where definition like ‘%SEARCH%STRING%’
)
and is_disabled = 0

declare @sql varchar(255)

declare db_cursor cursor for
select ‘ALTER TABLE ‘ + table_name + ‘ DISABLE TRIGGER [' + trigger_name + ']‘ from @temp x

open db_cursor
fetch next from db_cursor into @sql

while @@FETCH_STATUS = 0
begin

exec (@sql);

fetch next from db_cursor into @sql
end

close db_cursor
deallocate db_cursor

Read More →

How to get the ip address of SQL Server using SSMS

sql_server_logo

October 2, 2014 | Posted in Uncategorized

select connectionproperty(‘local_net_address’)

Read More →