Creating Trigger in SQL Server Table

SQL Trigger
Trigger is a action which will perform when the table gets insert, update or delete. We can choose the options on what the trigger should get invoked and create the syntax as below

CREATE Trigger triggername
ON tblname
FOR INSERT,UPDATE,DELETE -- We can add or remove the criteria here
AS
BEGIN

-- Action steps needs to carried out should be given here.

END

Creating Trigger in SQL Server Table was last modified: November 15th, 2017 by Justin Antony

How to find trace or log information in sql server ?

For tracking the database for any incidents like droping any objects and event monitoring.

Starting the Trace
EXEC SP_Configure ‘default trace enabled’,1
RECONFIGURE

Stopping the Trace
EXEC SP_configure ‘default trace enabled’,1
RECONFIGURE

To find the trace information for any sql server table

select * from sys.traces where id =1

How to find trace or log information in sql server ? was last modified: October 14th, 2017 by Justin Antony

Query to search for particular column from sql database

Search particular column sql database

You can search for a particular column that present in the list of database tables in sql server.

SELECT
SCHEMA_NAME(SCHEMA_ID) + '.' + TBL.NAME AS TableName,
COL.NAME AS ColumnName
FROM SYS.TABLES AS TBL
INNER JOIN SYS.COLUMNS COL
ON TBL.OBJECT_ID = COL.OBJECT_ID
WHERE COL.NAME LIKE '%ENTER COLUMN NAME%'
ORDER BY 1

 

 

Query to search for particular column from sql database was last modified: October 10th, 2017 by Justin Antony

What is SSIS event logging?

SSIS event logging
To log all the events that will be helpful for troubleshooting the package.

What are the different SSIS log providers?
SSIS log provider for Text files
SSIS log provider for Windows Event Log
SSIS log provider for XML files
SSIS log provider for SQL Profiler
SSIS log provider for SQL Server (Data will be stored in msdb..sysdtslog90/msdb..sysssislog table)

What is SSIS event logging? was last modified: October 1st, 2017 by Justin Antony

What’s the difference between DELETE and TRUNCATE TABLE statement?

DELETE TRUNCATE TABLE difference sql server
DELETE TABLE : Delete is done on row by row basis and it logs the transaction which is slow.
TRUNCATE TABLE : Deletes all the rows at a time which makes it faster.
TRUNCATE TABLE can be rolled back.

What’s the difference between DELETE and TRUNCATE TABLE statement? was last modified: October 1st, 2017 by Justin Antony

Define candidate key, composite key , alternate key ?.

candidate key composite key alternate key sql server
A candidate key is one that can identify each row of a table uniquely.
A candidate key becomes the primary key of the table.
A primary key formed by combining at least two or more columns is called composite key.
If a table has more than one candidate key then one become the primary key and the rest are called as alternate keys.

Define candidate key, composite key , alternate key ?. was last modified: October 1st, 2017 by Justin Antony