what is the use of triggers and indexes ?
how to use? with example.
How to create indexes?
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Jignesh TrivediRank #16 · 50.3K reputationPosted May 22, 2012, 7:29 PM EDT
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.
Satyapriya NayakRank #47 · 31.5K reputationPosted May 22, 2012, 7:32 PM EDT
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