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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 make a new table from old table with calculations

Author  Topic 

shalahuddin
Starting Member

7 Posts

Posted - 2010-03-04 : 02:19:53
dear friends!!

I have a table like this:
Old table
-----------------------------------------|
permanent | serial | Nama |
-----------------------------------------|
1274156429509 | 415642950 | jonathan |
1272565562652 | 256556265 | Rina |
1273658925954 | 365892595 | Agustina |
1279262322322 | 926232232 | ryan |
-----------------------------------------|

I want to make a new table with same record in old table at fields permanent and serial, and i want to make new record in the new table with calculations GTIN-8 and GTIN-13. i want to make a new table like this below


new table
----------------------------------------------------------------|
permanent | serial | id_permanent | id_serial |
----------------------------------------------------------------|
1274156429509 | 415642950 | 9094000000178 | 400000017 |
1272565562652 | 256556265 | 9092000000246 | 200000024 |
1273658925954 | 365892595 | 9093000000311 | 300000031 |
1279262322322 | 926232232 | 9099000000482 | 900000048 |
----------------------------------------------------------------|



id_permanent:
digit 1 to digit 3 '909'
digit 4 = digit 4 (permanent)
digit 5 to digit 11 'running number' (0000001,0000002, ...., nnnnnnn(rows of data from old table))
digit 12 = GTIN 8 from digit 5 to digit 11
digit 5 = n * 3
digit 6 = n * 1
digit 7 = n * 3
digit 8 = n * 1
digit 9 = n * 3
digit 10= n * 1
digit 11= n * 3
_________ +
N
digit 12= 10 - (N % 10)
digit13 = GTIN 13 from digit 1 to digit 12
digit 1 = n * 1
digit 2 = n * 3
digit 3 = n * 1
digit 4 = n * 3
digit 5 = n * 1
digit 6 = n * 3
digit 7 = n * 1
digit 8 = n * 3
digit 9 = n * 1
digit 10= n * 3
digit 11= n * 1
digit 12= n * 3
_________ +
N
digit 13= 10 - (N % 10)

id_serial:
digit 1 to digit 9 = digit 4 to digit 12 (id_permanent)


I need a help for this case!! thanx before

namman
Constraint Violating Yak Guru

285 Posts

Posted - 2010-03-04 : 13:48:48
It is like you need help on math not T-SQL ...
Go to Top of Page

DP978
Constraint Violating Yak Guru

269 Posts

Posted - 2010-03-04 : 14:58:47
Is n coming from the same digit of the permanent field?
Go to Top of Page

shalahuddin
Starting Member

7 Posts

Posted - 2010-03-04 : 21:58:42
yeah n coming from the same digit of the permanent field....
Go to Top of Page
   

- Advertisement -