Symbianize Forum

Most of our features and services are available only to members, so we encourage you to login or register a new account. Registration is free, fast and simple. You only need to provide a valid email. Being a member you'll gain access to all member forums and features, post a message to ask question or provide answer, and share or find resources related to mobile phones, tablets, computers, game consoles, and multimedia.

All that and more, so what are you waiting for, click the register button and join us now! Ito ang website na ginawa ng pinoy para sa pinoy!

[help] mssql query

sinner231_100

Proficient
Advanced Member
Messages
298
Reaction score
3
Points
28
mga sir/madam patulong po ulit about sa sql statement...
bale ganito po yung table ko.


View attachment 209599

gusto ko po sanang mangyari sa barcode na column eh maicombine yung category, subcategory tas magiincrement yung last six digit base sa
category and subcategory through UPDATE STATEMENT....


maraming salamat po sa tutulong....
 

Attachments

  • barcode.PNG
    barcode.PNG
    21.7 KB · Views: 17
Last edited:
mga sir/madam patulong po ulit about sa sql statement...
bale ganito po yung table ko.


View attachment 1019779

gusto ko po sanang mangyari sa barcode na column eh maicombine yung category, subcategory tas magiincrement yung last six digit base sa
category and subcategory through UPDATE STATEMENT....


maraming salamat po sa tutulong....


Code:
create table testable(id nvarchar(3),cat nvarchar(6),subcat nvarchar(6),barcod nvarchar(18))
insert into testable
select 'c01','000100','0010',null
union all
select 'c02','000100','0010',null
union all
select 'c03','000200','0020',null

declare @table as table (ID nvarchar(3),barcod nvarchar(18))
insert into @table 
select id,  cat  + subcat + right(REPLICATE('0',6) + cast(row_number () over (partition by cat,subcat order by cat,subcat) as nvarchar(4)),6)
from testable

update testable
set barcod = (select barcod from @table where id = testable.id)

select *
from testable

drop table testable
 
Back
Top Bottom