开发者

Duplicating Data

开发者 https://www.devze.com 2023-02-09 19:41 出处:网络
looking at dupli开发者_JAVA百科cating data to include a type A and type B select * from [dbo].[dayStats]

looking at dupli开发者_JAVA百科cating data to include a type A and type B

select *
    from [dbo].[dayStats]
    where status in ('IDmon', 'IDtue', 'IDwed', 'IDthu', 'IDfri')
    order by status

currently have around 3000 records.

i need to duplicate each of these records so they include a A and B

for example:

IDmon
IDtue ...

becomes

IDmonA, IDmonB
IDtueA, IDtueB
...

no IDmon / IDtue records to remain

all the other fields are to be duplicated as normal

really struggling to think how i would create such a query / stored procedure


Not really sure if you're after this?

select
  status & 'A',
  status & 'B',
  other_col_1,
  other_col_2
from
  [dbo].[dayStats]
where status in ('IDmon', 'IDtue', 'IDwed', 'IDthu', 'IDfri')
0

精彩评论

暂无评论...
验证码 换一张
取 消