Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
sthita2010
Starting Member
2 Posts |
Posted - 2011-02-19 : 13:47:26
|
I am using SQL server 2005.I wrote a sql trigger but its not working. plz help me .Please refer below for this below code.my Trigger code looks like this--DECLARE @a VARCHAR(100);DECLARE @b VARCHAR(100);SET @a=(SELECT top 1 from Table1 where Autono=8);//where autonumber is primery keySET @b=(SELECT top 1 from Table2 where no=@a);IF @a <> ' 'BEGIN IF @b=' ' BEGIN INSERT into table3(username,salary) values(@a,'Not available'); ENDENDHere in this above code if i will comment this two if statements its inserting but if i have this two if statements its not inserting in the table.Please reply soonRegardssthita |
|
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts |
Posted - 2011-02-19 : 18:12:03
|
What is the trigger supposed to do?Odd to see a trigger that doesn't reference either inserted or deleted tables...--Gail ShawSQL Server MVP |
 |
|
sthita2010
Starting Member
2 Posts |
Posted - 2011-02-19 : 23:21:47
|
Hey hi... Actually in my scenario after insert some values to a table this trigger is going to fire. I have other insert which are working and inserting with there respective table in my same trigger.But the above scenario where i am having IF condition its not inserting in the respective table and if i am removing the IF else then its inserting.Waiting for your replyRegardssthita |
 |
|
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts |
Posted - 2011-02-20 : 03:59:58
|
What, exactly, is the trigger supposed to do?Post the entire trigger code, from CREATE TRIGGER to GO.--Gail ShawSQL Server MVP |
 |
|
|
|
|