May 19, 2011 at 12:03 pm
brent 82845 (5/19/2011)The Primary key for the main table is (Supplier, Terminal, Branded, Product, Eff_Date, Eff_Time)
You can see in the data that Supplier2 sent a second price change for the same date and time that breaks the primary key.
I think your real problem is you are fighting a bad design. It totally makes sense that a supplier might send a second entry for a product because it was either entered incorrectly or somebody changed their mind about the price on xxx date. Also, you really should use datetime fields instead of two separate varchar fields.
If you can provide some ddl and some sample data (in the form of insert statements) I am certain that many people around here are willing and able to help.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
Viewing post 1 (of 2 total)
You must be logged in to reply to this topic. Login to reply