|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hello All,
I'm new to T-SQL and need some help with creating a trigger or code of some sort which will search to find if an invoice # being entered already exist in the database and if it does, a message displays saying: "Cannot insert duplicate invoice number, please re-enter correct invoice number." but if none exist, the invoice # is entered. Thanks for any help I can get on this....... ![]() |
|
#2
|
|||
|
|||
|
Do an SQL Select statement Where invoice number equals the value entered by user, if recordset count = 0 then invoice number not in database. Put code in the BeforeUpdate event of the text box (sorry, I am thinking Access, if T-SQL has such event).
Last edited by June7 : July 30th, 2009 at 08:27 PM. |
|
#3
|
|||
|
|||
|
Re: Transact-SQL - Need help with duplicate checking and message
Hi,
I hope that the below SQL query will be very useful for you... Code:
if exists(select * from test2 where invoicenumber = 3)
begin
print 'Cannot insert duplicate invoice number, please
re-enter correct invoice number.'
end
else
begin
insert into test2 values ('3')
end
Note: The Value '3' is a invoice number. Thanks& Regards SakthiMeenakshi.S |
![]() |
| Viewing: ASP Free Forums > Database > SQL Development > Transact-SQL - Need help with duplicate checking and message |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|