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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 duplicate data for unique fields with diferent nam

Author  Topic 

praisephs
Starting Member

1 Post

Posted - 2013-10-25 : 11:42:48
Hi All,
Pls, kindly help me out with this:
I'm designing an app for stock keeping. In my DB, I have a field called "ItemSerialNo" and I made it unique(but not the table's primary key). On my front end, I have a text box for Item Serial No and a combo box loaded with the item brands and also a save button. I know that if I try to save a serial no already existing in my DB, the app won't allow me because of the unique property of the field named "ItemSerialNo". But I want to be able to save a serial no already existing in my DB but with a different brand name.
For example, I want to be able to save information like:
1. ITEM SERIAL NO = 12345
BRAND NAME = AA
2. ITEM SERIAL NO = 12345
BRAND NAME = BB.
Pls, a quick response would be appreciated.

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-10-25 : 11:51:26
If you are trying to UPDATE, then use the UPDATE statement rather than INSERT.
UPDATE YourTable SET
BrandName = 'BB'
WHERE
ItemSerialNo = 12345;
That of course means that there will be no row with ItemSerialNo=12345 and BrandName=AA in the database anymore.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-10-25 : 22:43:20
As per your requirement you should be having unique constraint on ([ITEM SERIAL NO],[BRAND NAME])

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -