Skip to main content

Posts

Showing posts with the label Triggers

Restrict SP_ (Naming convention) with DDL Trigger

Sometimes naming convention also impact the performance problem in SQL SERVER. Whenever we creating the stored procedures we are giving the name just like SP_Get_Customer. SP_ it first checks the Master Database system procedures. All the system procedures stored in Master Database. In this article we do not allow SP_ whenever stored procedure creating by using DDL Trigger. --Create Student Table create table Student (                               id int identity ( 1 , 1 ) ,                 Name varchar ( 100 ) ) --Create DDL Trigger on Database create   trigger Restrict_Sp_NameConvenction on database for create_Procedure as begin declare @EventData XML = EVENTDATA (), @ObjectName Nvarchar ( 100 ); select   ...

Database changes with Audit Table

In Recent I faced the problem whenever we need to move the DB Changes to Production environment we have some table in the Development environment .we have added some columns to table in Development. we need to change definitions in production environment also .At this time we are some little bit of problem facing . Today I come up with the solution we need to create the DDL trigger on Database level. Whenever we are moving the DB Changes to Production environment we can cross check audit table.   --Create Student Table create table Student (                               id int identity ( 1 , 1 ) ,                 Name varchar ( 100 ) ) --Create Audit Table   create table Audit   (   EventType nvarchar ( max ), ...