QueenKirsty
Registered User.
- Local time
- Today, 01:54
- Joined
- Mar 13, 2009
- Messages
- 31
Please can someone provide me with a solution to the following:
I have a table (Equipment) that holds details about items of equipment. The interesting columns of this table are:
EquipmentID (PK - integer)
MSerialNumber (nvarchar - allows Nulls).
I would like to have a trigger on the table so that when a record is added to the table or when the field MSerialNumber is updated it checks to see if that serial number already exists in the table. If it does I would like the update / insert to be cancelled and an error message displayed.
I have an additional issue that I would like to ignore all punctuation marks, spaces and preceding zeros in the MSerialNumber field when comparing them.
E.G.s
000000N124F6 matches N124F6
lp-240 matches lp240
00LPZ-R560 matches LPZR560
Commonly, the punctuation is only either spaces or hyphens.
All assistance gratefully appreciated.
I have a table (Equipment) that holds details about items of equipment. The interesting columns of this table are:
EquipmentID (PK - integer)
MSerialNumber (nvarchar - allows Nulls).
I would like to have a trigger on the table so that when a record is added to the table or when the field MSerialNumber is updated it checks to see if that serial number already exists in the table. If it does I would like the update / insert to be cancelled and an error message displayed.
I have an additional issue that I would like to ignore all punctuation marks, spaces and preceding zeros in the MSerialNumber field when comparing them.
E.G.s
000000N124F6 matches N124F6
lp-240 matches lp240
00LPZ-R560 matches LPZR560
Commonly, the punctuation is only either spaces or hyphens.
All assistance gratefully appreciated.