Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
NOTE:This item reserved by DO_Number belowDO_Number Item QtyDO_001 BR_001 5DO_002 BR_001 3DO_003 BR_001 4The case is, when i generate new DO_Number belowDO_Number Item QtyDO_004 BR_001 8when DO_004 booked item BR_001is there any query to show the NOTE above, to announce methere are another DO_Number that has booked item BR_001 based by DO_004please help me
bandi
Master Smack Fu Yak Hacker
2242 Posts
Posted - 2012-11-29 : 03:53:04
Write a Insert Trigger
CREATE TRIGGER Tr_InsertON tab FOR INSERT ASBEGIN SELECT 'These items are reserved by DO_number below ' SELECT t.* FROM tab t JOIN inserted i ON t.Item = i.Item AND t.DO_Number != i.DO_NumberEND
--Chandu
chulz90
Starting Member
26 Posts
Posted - 2012-11-29 : 04:13:11
quote:Originally posted by bandi Write a Insert Trigger
CREATE TRIGGER Tr_InsertON tab FOR INSERT ASBEGIN SELECT 'These items are reserved by DO_number below ' SELECT t.* FROM tab t JOIN inserted i ON t.Item = i.Item AND t.DO_Number != i.DO_NumberEND
--Chandu
thank you so much bud.. thank's to reply my post you're so kind
bandi
Master Smack Fu Yak Hacker
2242 Posts
Posted - 2012-11-29 : 04:17:51
quote:Originally posted by chulz90 thank you so much bud.. thank's to reply my post you're so kind
Welcome--Chandu
chulz90
Starting Member
26 Posts
Posted - 2012-11-29 : 04:31:22
quote:Originally posted by bandi
quote:Originally posted by chulz90 thank you so much bud.. thank's to reply my post you're so kind
Welcome--Chandu
oh yaaa, i want to know the function (!) in line 8 ? ? ?
bandi
Master Smack Fu Yak Hacker
2242 Posts
Posted - 2012-11-29 : 04:38:05
JOIN inserted i ON t.Item = i.Item AND t.DO_Number != i.DO_Numberinserted is the referencing table which holds recently inserted data. So we are joining this table with actual table (based on matching item value) and then excluding recently inserted DO_number from the output --Chandu