September 4, 2013 at 7:16 pm
Hello all,
I am new in the since of posting in the forum I do have some past experience with SQL mostly in v2000/v2005.
What I have, is a need for a table of unique alpha numeric values that I can use for sku numbers and printing simple bar code labels for our products. (I do not need barcoding help as my label software just needs the number).
I will be populating in blocks of 15,000 skus to start and will need to remove any duplicates if they so happen to exist after the initial population.
The alpha part will come from a separate table of values.
This table is as so:
Table = SkuCategories
Table Columns =
(t_id IDENTITY , skuCategory_Name nvarchar(MAX), skuCategory_KeyCode char(10))
Values = (t_id, 'SomeCategory Product', 'SP')
What I need is the ability to run a statement, cursor or whatever method to populate another table with a set number of records with a unique sku number using the 'skuCategory_KeyCode' column value 'SP'
Where "S" is inserted at the beginning and "P" added at the end of a unique 9 digit number.
For instance or a sample of the value I am looking to get is as follows.
sku= "S123412345P"
The sku list table needs the following columns
(id IDENTITY, sku VARCHAR, datecreated (TimeStamp), isUsed BIT default 0)
Thank you and go easy on me as this is my first post!
September 4, 2013 at 9:30 pm
Hi and welcome to the forums. Don't worry I don't bite and usually gentle.
Let me see if I understand what you are looking for. It sounds like what you need is a way to generate 9 digit numbers and stuff an "s" on the front and a "p" on the end? Do these values have to be random or is sequential acceptable?
_______________________________________________________________
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/
September 4, 2013 at 11:01 pm
Hi,
The s and the p are pulled from the table of categories, but yes in sense you are correct.
Sequential would be okay for the 9 digits, how ever in thought how would the numbering begin?
Our plan is to place a sku label on products and no rhyme nor reason to what the number part is, just that when someone looks at the sku or enters it in the catalog they know by the two letters what category it belongs to. And yes there really is no reason why the front and rear on the letters, just thought it was a little more creative.
thanks
September 5, 2013 at 1:25 am
How are your products uniquely identified, Greg?
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
September 5, 2013 at 9:05 am
Hi Chris,
To answer your question there not, as I stated the 9 digit number has no identifiable part as they can be unique random numbers and in any case if there were to be some non unique numbers they can be removed after the initial insert of 15,000 records. I do not believe that per category we will ever have more than the 15,000 initial sku numbers. Each category will have a table of 15,000 sku numbers and as far as the 9 digit number part of the sku being unique across tables, that does not matter as the two letters will make them unique in the overall catalog, and no category will exist with the same two letters. This is not a what if this or that scenario.
Thanks for your reply
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy