Re: need information for "Before Select" Trigger



Lucky (tushar.n.patel@xxxxxxxxx) writes:
Currently i'm facing a bit odd situation. i cant modify my code so i
have to make changes in SQL Server.

the problem is, i've modified one table by adding new column and now i
want only those row which has not null value in that column whenever
the select statement gets fire. i mean in every select statement only
those rows should be returned which has NOT NULL value in the newly
added column.

for this i've created one view and tried to run the application but the
i'm facing some problem as my application is developed in .net 2.0,
i've used lots of .net functionalities and now i cant make any changes
in Code.

another solution i think is triggers. if i can fire a trigger before
any select statements, my problem can be solved instantly but i'm
afraid i can not write andy "before select" trigger.

There are no BEFORE SELECT triggers. (In fact, there are no BEFORE triggers
at all in SQL Server.)

The way to handle this would be define a view, which includs a filter on
this column.

However, personally, I would not add a view for such a simple condition,
but rather add it as needed.

If you real problem is that this table is referred to in lots of places
(lots => more than 20), and you want this column to take effect every
where, you could renamed the table, and then create a view with that
carries on the original name of the table.




--
Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
.



Relevant Pages

  • Re: UPDATE query gives Incorrect Syntax error
    ... Books Online for SQL Server 2005 athttp://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books ... ... No - no triggers on the table. ... Is it possible that a previous query has somehow become trapped and is ...
    (comp.databases.ms-sqlserver)
  • Re: New to SQL server
    ... it is called triggers. ... ANYTHING THAT YOU CAN DO IN JET IS BABY TALK COMPARED TO WHAT WE CAN DO ... anything that you can do in JET that I can't do in SQL Server ... self-referencing FKs and inline constraints. ...
    (microsoft.public.access.adp.sqlserver)
  • Re: need information for "Before Select" Trigger
    ... As i've added "Enforced Constraints" ... There are no BEFORE SELECT triggers. ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)
  • Re: Encrypting SQL objects
    ... objects, i.e. Stored procs, Views, triggers. ... engine must be able to read the source code at run to be able to compile ... And if SQL Server has access to it, ...
    (microsoft.public.sqlserver.security)
  • Re: SQL Server Express versus Access (In the World Series of Love)
    ... As far as the triggers are concerned, the first case is something to avoid ... have their usefulness, for updateability, but Jet has already updateability ... OF triggers to achieve the same, say, over view, so, advantage to Jet. ... MS SQL Server may have a horse shoe maker right out of the box, ...
    (microsoft.public.access.modulesdaovba)

Loading