Question: I have 2 tables. I need to check before insertion in one table if the value exist in other table.

Answer: 
IF NOT EXISTS ( SELECT \* FROM TableA WHERE Col1 = @Value)
INSERT INTO TableB(Col1) SELECT @Value
Using an [INSERT trigger](http://www.google.com/search?q=SQL+Server+insert+trigger) perhaps?

I'm not very sure about the syntax.

```
CREATE TRIGGER InsertTableTrigger ON Table1 FOR INSERT
 AS
  BEGIN
    IF EXISTS ( SELECT 1 FROM Inserted i JOIN Table1 t ON i.key = t.key )
    BEGIN
        RAISERROR('Transaction Failed.',16,1)
        ROLLBACK TRAN "insert on Table1"
    END
  END
 GO

```

Inserted is used to access the inserting values.