Friday, December 26, 2008

SQL Triggers Order of Execution

DML Triggers:
There can be only one First and one Last trigger for each statement on a single table.
If a First trigger is already defined on the table, database, or server, you cannot designate a new trigger as First for the same table, database, or server for the same statement_type. This restriction also applies Last triggers.
Replication automatically generates a first trigger for any table that is included in an immediate updating or queued updating subscription. Replication requires that its trigger be the first trigger. Replication raises an error when you try to include a table with a first trigger in an immediate updating or queued updating subscription. If you try to make a trigger a first trigger after a table has been included in a subscription, sp_settriggerorder returns an error. If you use ALTER TRIGGER on the replication trigger, or use sp_settriggerorder to change the replication trigger to a Last or None trigger, the subscription does not function correctly.



DDL Triggers:
If a DDL trigger with database scope and a DDL trigger with server scope exist on the same event, you can specify that both triggers be a First trigger or a Last trigger. However, server-scoped triggers always fire first. In general, the order of execution of DDL triggers that exist on the same event is as follows:
1. The server-level trigger marked First.
2. Other server-level triggers.
3. The server-level trigger marked Last.
4. The database-level trigger marked First.
5. Other database-level triggers.
6. The database-level trigger marked Last.



General Trigger Considerations:
If an ALTER TRIGGER statement changes a first or last trigger, the First or Last attribute originally set on the trigger is dropped, and the value is replaced by None. The order value must be reset by using sp_settriggerorder.
If the same trigger must be designated as the first or last order for more than one statement type, sp_settriggerorder must be executed for each statement type. Also, the trigger must be first defined for a statement type before it can be designated as the First or Last trigger to fire for that statement type.



Example:


See sample script below:


--CONNECTING master DATABASE
USE master
go
--BY DEFAULT TRIGGERS ARE FIRED IN THE ORDER THEY ARE CREATED
set nocount on
go
--CREATED A TEMPORARY TABLE
create table dbo.customer (customerid int identity primary key)
go
--FIRST TRIGGER
create trigger dbo.tr_customer_1 on dbo.customer
for insert
as
set nocount on
print 'firing original trigger 1'
go
--SECOND TRIGGER
create trigger dbo.tr_customer_2 on dbo.customer
for insert
as
set nocount on
print 'firing original trigger 2'
go
--THIRD TRIGGER
create trigger dbo.tr_customer_3 on dbo.customer
for insert
as
set nocount on
print 'firing original trigger 3'
go
print 'Inserting row with default order of triggers'
go
--EXECUTED A SIMPLE INSERT QUERY
insert into dbo.customer default values
go

/*CHANGE TRIGGER ORDER*/
exec sp_settriggerorder @triggername = 'tr_customer_1',
@order = 'first',
@stmttype = 'insert',
@namespace = null

exec sp_settriggerorder @triggername = 'tr_customer_2',
@order = 'last',
@stmttype = 'insert',
@namespace = null

exec sp_settriggerorder @triggername = 'tr_customer_3',
@order = 'none',
@stmttype = 'insert',
@namespace = null
go
print 'Inserting row with modified order of triggers'
go
--AGAIN EXECUTED A SAMPLE QUERY
insert into dbo.customer default values
go
drop table dbo.customer
go

Monday, December 15, 2008

War Technology

Liquid armour, sonic bandages, rail guns and more
Mankind has been trying to hurt his fellow man since the dawn of time, and technology makes the job much easier.

Modern technology means 'increased lethality' and scarier weapons - but it can also keep soldiers out of harm's way, patch them up when they're hurt and one day, even erase traumatic memories.

These fourteen technologies may sound like the stuff of sci-fi, but they're rapidly becoming reality.

1. Exoskeletons
Wouldn't it be great if you could give ordinary soldiers robot strength and stamina? Exoskeletons do just that, and as this video shows, they're not very far away. They're also capable of working without a person inside them. Everybody panic!

2. Smart uniforms
We can't make soldiers invisible just yet, but smart fabrics can make them much harder to see - and almost invisible to night vision goggles, heat sensors and radar kit. 

3. Liquid armour
Armour is handy, but it's heavy and inflexible - so scientists have developed liquid armour, which is designed to offer the best of both worlds. There are two kinds of liquid armour: Shear Thickening Fluid (STF), which hardens on impact, and Magnetorheological (MR) fluid, which is essentially iron particles suspended in liquid. Add a magnetic field and MR fluid becomes solid in fractions of a second. Of the two, STF liquid armour is the current favourite: MR fluid armour is still a good few years away.

4. Bendy guns
One potentially fatal problem with the good old-fashioned gun is that you need to see what you're shooting at - so when you pop your head round a corner, the enemy might just pop it off your shoulders. Enter Cornershot, an Israeli system designed for SWAT teams and special forces. It's a simple enough idea: a gun that can be bent at right angles, with a sight that follows the barrel so the operator can see what he or she is shooting at.

5. Sonic bandages
One of the biggest preventable causes of battlefield deaths is from blood loss, so the Deep Bleeder Acoustic Coagulation (DBAC) programme is working on 'sonic bandages' that cauterise wounds with a focused blast of ultrasonic energy.

6. Electronic guns
Metal Storm combines electronic ignition and stacked projectiles to devastating effect - or "increased lethality", as the brochure puts it. Its light weight means that Metal Storm guns tend to have lots and lots of barrels firing simultaneously. It makes a machine gun look like a pea shooter.

7. Rail guns
Rail guns use magnetic fields to blast projectiles at incredible speeds: the US Navy has tested one that fires its load at seven times the speed of sound.

8. Robot bombers
Earlier this week, unmanned aerial vehicles (UAVs) fired three Hellfire missiles at a house on the Afghan border, killing fugitive Rashid Rauf. That's just a taste of what's on the horizon, because today's UAVs are titchy compared to projects such as Taranis, which includes building full-size, unmanned fighter jets.

9. Brain erasers
For many soldiers, the trauma of war doesn't end when the fighting does - and post-traumatic stress disorder (PTSD) can make their civilian lives a misery. A Men In Black-style brain eraser would be a big help, so it's no surprise that the military is funding research into whether such devices are possible. Scientist have already found a way to erase mice's memories, so such tech could well be possible.

10. See-through planes
Clearly inspired by Wonder Woman, the MoD wants pilots to be able to see right through their aircraft. Sadly that doesn't mean making planes out of glass with scantily clad lovelies flying them; it means a heads-up display inside the pilot's helmet that projects images from outside, enabling the pilot to 'see' through the metal. The helmets are currently in development for the F-35 Joint Strike Fighter.

11. Invisible tanks 
As the old joke almost put it: What's green and invisible? That tank. Last year, the MoD revealed that it was testing invisibility systems for tanks and even troops. It's a simple enough idea - cameras film the tank's surroundings and then project it onto the tank - but it'll be a few years before it's battlefield ready. A proper invisibility cloak is probably decades away.

12. Pain beams
Want a non-lethal but exceptionally painful energy weapon? Then get thee to Raytheon, whose Silent Guardian uses a focused beam of microwave energy to heat up the skin and force enemies to take cover. As Ars Technica notes, rather brilliantly, this is one area where a tinfoil hat really could defend you.

13. HAARP 
Depending on whom you believe, the High-frequency Active Auroral Research Programme is either a system for better global communications, a space weapon for battling UFOs, an earthquake creator or a mind control ray. The first explanation comes from military men who can't see a piece of cheese without wondering how to kill people with it; the others from the tinfoil hat brigade and Muse's Matt Bellamy. Who to trust? 

14. Terminators 
We've got exoskeletons. We've got guns. So why not go the next step into Terminator territory and develop robot brains that would enable the exoskeletons to chase us around with their guns? That's exactly what DARPA's SyNAPSE (Systems of Neuromorphic Adaptive Plastic Scalable Electronics) electronic brain programme seems designed to do. SyNAPSE? SKYNET, more like.

Long Lasting Laptop Battries

A laptop battery that can last for 30 years without single charge, "Amazing" isn't it. Development of this amazing and unique Technology is being funded by the U.S. Air Force Research Laboratory. This amazing battery runs on betavoltaic power cells which are constructed from semiconductors and use radioisotopes as the energy source. As the radioactive material decays it emits beta particles that transform into electric power capable of fueling an electrical device like a laptop for years. laptop users now can use their batteries for as long as they wont not replacement needed.

The word Nuclear may raise some questions but these betavoltaic batteries cant be named as Nuclear ones, they neither use fission/fusion or chemical processes to produce energy and so do not produce any radioactive or hazardous waste.

Betavoltaics Batteries generate power when an electron strikes a particular interface between two layers of material. The Process uses beta electron emissions that occur when a neutron decays into a proton which causes a forward bias in the semiconductor. This makes the betavoltaic cell a forward bias diode of sorts, similar in some respects to a photovoltaic (solar) cell. Electrons scatter out of their normal orbits in the semiconductor and into the circuit creating a usable electric current. All this Technology Talks is difficult to understand so in simple words these batteries are safe for laptop users

These batteries can be quite small and thin, a porous silicon material is used to collect the hydrogen isotope tritium which is generated in the process. The reaction is non-thermal which means laptops and other small devices like mobile phones will run much cooler than with traditional lithium-ion power batteries. The reason the battery lasts so long is that neutron beta-decay into protons is the world’s most concentrated source of electricity, truly demonstrating Einstein’s theory E=MC2.

Another advantage of these batteries are that if they eventually run out of power they are totally inert and non-toxic, so environmentalists need not fear these high tech scientific wonder batteries. If further research produce good results we might find these batteries in two to three years

Monday, December 1, 2008

Visual Studio 2003 Interface Not Registered Error

When you build a Setup project in Microsoft Visual Studio .NET, you may receive the following error message:

"Could not find file. Interface not registered."

CAUSE
This problem occurs if the Ole32.dll file that is located in the %Windir%\System32 folder is not registered correctly in the Microsoft Windows registry.

RESOLUTION
To resolve this problem, register the Ole32.dll file. To do this, follow these steps:
1. Click Start, and then click Run. The Run dialog box appears.
2. In the Open box, type the following command, and then click OK:
Regsvr32.exe %Windir%\System32\Ole32.dll
You receive the following message in the RegSvr32 dialog box:
DllRegisterServer in C:\WINDOWS\System32\ole32.dll succeeded.
3. In the RegSvr32 dialog box, click OK.
4. Start Visual Studio .NET, and then rebuild your Setup project.