what is the use of triggers and indexes ?
how to use? with example.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satyapriya NayakPosted May 22, 2012, 11:32 PM
Please refer the below links
http://publib.boulder.ibm.com/infocenter/idshelp/v10/index.jsp?topic=/com.ibm.sqlt.doc/sqltmst316.htm
Why to use triggers.
http://searchsqlserver.techtarget.com/generic/0,295582,sid87_gci1186123,00.html
Thanks
Jignesh TrivediPosted May 22, 2012, 11:29 PM
A trigger is a database object that is attached to a table. In many aspects it is similar to a stored procedure.
In other word it is special kind of stored procedure.
Example:
CREATE TABLE Table1 (ID int IDENTITY, Name varchar(10))
go
CREATE TRIGGER tr_Table1_INSERT
ON Table1
FOR INSERT
AS
PRINT GETDATE()
go
INSERT Source (Name) VALUES ('Test Name')
I only use trigger when I need to perform a certain action as a result of DML (INSERT, UPDATE or DELETE) and ad hoc SQL is used. I implement most of my data manipulation code via stored procedures and when you do this the trigger functionality can be moved into the procedure.
An index can be created in a table to find data more quickly and efficiently.
CREATE INDEX index_name
ON table_name (column_name)
Please refer
http://www.simple-talk.com/sql/learn-sql-server/sql-server-index-basics/
hope this will help you.