dbo.People

Modify to suit – I just saved a few minutes of your time. You’re welcome!

IF NOT EXISTS ( SELECT *
                FROM   sys.objects
                WHERE  object_id = OBJECT_ID(N'dbo.People')
                       AND type in (N'U')
)
BEGIN
  CREATE TABLE dbo.People (
     ID BIGINT PRIMARY KEY IDENTITY(1,1),
     Salutation NVARCHAR(30) , -- Mr, Mrs, Dr, Miss, etc.
     Title NVARCHAR(100) , --
     FirstName1 NVARCHAR(50) ,
     FirstName2 NVARCHAR(50) ,
     MiddleName1 NVARCHAR(50) ,
     MiddleName2 NVARCHAR(50) ,
     MiddleInitial CHAR(1) ,
     LastName1 NVARCHAR(100) ,
     LastName2 NVARCHAR(100) ,
     Suffix NVARCHAR(30) );
END
GO
Advertisements

Find all triggers in a SQL Server database

Use the following small script to find all hidden triggers in a SQL Server database.  Pretty much all competent developers using SQL agree that using triggers is a bad practice, but few know how to find them before they have wasted a lot of development and testing time not understanding why things aren’t working the way they want them to (because of triggers doing behind the scenes work, undesirably).

Trigger_the_horse
Trigger the horse, with Roy Rogers.
-- Finds all "hidden" triggers in a database. Using triggers is not a best practice.
USE <database_name>;
GO
SELECT  name AS [TriggerName]
FROM    sys.objects
WHERE   OBJECTPROPERTY(object_id, 'IsTrigger') <> 0;