| | |
problem with trigger
Please support our MS SQL advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Nov 2006
Posts: 6
Reputation:
Solved Threads: 0
I have a table with a primarykey ID and a unique key for ID_EMP and OSID
When I insert I want to populate the OSID column whth the next int value related to id_emp
My trigger works but is returning the error message:
Warning: Null value is eliminated by an aggregate or other SET operation.
CREATETRIGGER os_osid
ON ordemdeservico
FORINSERT
AS
BEGIN
DECLARE @osid int, @id int
SELECT @osid = CASE WHEN MAX(ordemdeservico.osid) IS NULL THEN 1 ELSE MAX(ordemdeservico.osid) + 1 END
FROM inserted
LEFT JOIN ordemdeservico ON ordemdeservico.id_emp = inserted.id_emp
WHERE ordemdeservico.id_emp = inserted.id_emp
SELECT @id = inserted.id
FROM inserted
UPDATE ordemdeservico
SET ordemdeservico.osid = @osid
WHERE ordemdeservico.id = @id
END
When I insert I want to populate the OSID column whth the next int value related to id_emp
My trigger works but is returning the error message:
Warning: Null value is eliminated by an aggregate or other SET operation.
CREATETRIGGER os_osid
ON ordemdeservico
FORINSERT
AS
BEGIN
DECLARE @osid int, @id int
SELECT @osid = CASE WHEN MAX(ordemdeservico.osid) IS NULL THEN 1 ELSE MAX(ordemdeservico.osid) + 1 END
FROM inserted
LEFT JOIN ordemdeservico ON ordemdeservico.id_emp = inserted.id_emp
WHERE ordemdeservico.id_emp = inserted.id_emp
SELECT @id = inserted.id
FROM inserted
UPDATE ordemdeservico
SET ordemdeservico.osid = @osid
WHERE ordemdeservico.id = @id
END
![]() |
Similar Threads
- Problem with Windows Update and WinXP (Web Browsers)
- Router/Warcraft III/CS 1.6 problem (Networking Hardware Configuration)
- Click event >> window appears? (Python)
- nvidia geforce 5600 graphics problem (Monitors, Displays and Video Cards)
- Windows XP keeps restarting since a new video card (Windows NT / 2000 / XP)
- Random screen saver problem is killing me (OS X)
- Redhat Linux 6.2 - ipop3d problem? (*nix Software)
- Connection Problems (Networking Hardware Configuration)
Other Threads in the MS SQL Forum
- Previous Thread: Howto | mssql seach and replace?
- Next Thread: New line Character in column alias
| Thread Tools | Search this Thread |





