Options

Creating SQL tables based on distinct values in current table

cnfuzzdcnfuzzd Member Posts: 208
Hello All

I have a table that looks like this:

dbo.Onhands

Store Item Qty UPC <Other Fields>
1 XX
1 XX
2 XX
2 XX
3 XX
4 XX
4 XX
4 XX

What I want to do is create a separate table for each store number with the same structure. Is there anyway to do this in T-SQL?

Thanks!

John
__________________________________________

Work In Progress: BSCI, Sharepoint

Comments

  • Options
    RobertKaucherRobertKaucher Member Posts: 4,299 ■■■■■■■■■■
    John, you can do this, but may I first ask what you are trying to accomplish? This may not be the best way to go about doing it. Also, which version of SQL Server are you using?
  • Options
    cnfuzzdcnfuzzd Member Posts: 208
    Hi Robert

    I need to create running totals based on store number, and possibly based on another column. I know that creating multiple tables is not ideal, but my understanding is that the running totals ability in SQL 2008 are limited to an accurate total, where the individual lines may be incorrect. Hence my thought of breaking the table up into sub tables. I am very new to this, so feel free to make suggestions.

    Thanks!

    John
    __________________________________________

    Work In Progress: BSCI, Sharepoint
Sign In or Register to comment.