Monday, November 9, 2009

Trigger FOR DELETE Operation

when we want to create a trigger for delete operation on any table we can do it as shown belowand by useing "FROM deleted" as we did in our example ("SELECT stor_id FROM deleted") we can access the ID of record which just deleted and trigger got fired.CREATE TABLE storesmaster( stor_id char(4) NOT NULL, stor_name varchar(40) NULL, stor_address varchar(40) NULL, city varchar(20) NULL, ) GOinsert storesmaster values('1','B','567...

How to find nth highest salary from Employee table in SQL Server?

SELECT TOP 1 salary FROM (SELECT DISTINCT TOP n salary FROM employee ORDER BY salary DESC) a ORDER BY sal...

What is a Subquery ?

A Subquery is a normal T-SQL query that is nested inside another query. They are created using parentheses when you have a SELECT statement that serve as the basis for the either part of the data or the condition in another query.Subqueries are generally used to fill one of couple of needs -1. Break a query up into a series of a logical steps.2. Provide a listing to be the target of a WHERE clause together with [IN|ESISTS|ANY|ALL].3. TO provide a lookup driven by each individual record in a parent...

What is the DEADLOCK ?

A deadlock is a situation in which two transactions conflict with each other and the only resolution is to cancel one transacti...

How to find out column names and their datatypes in a given table using a query in SQL Server?

Using the table tablename, write the query as follows -Select * from information_schema.columns where table_name = tablen...
 

About

Site Info

Information Source

SQL Server Copyright © 2009 Community is Developed by Dot Net Developer WebSite

/* tracking code by yahoo login */