ahmed salah

ahmed salah

  • 1.1k
  • 663
  • 42.1k

How to handle sticks on column country1 and country2 columns ?

May 22 2022 11:55 PM

I work on sql server 2017 i have table data as below

i need to make design for data to be best practise and prevent repeating data

my issue here on column countries1 and countries2 columns have data separated sticks so how to handle that

so are making design for countries table or what

 create table #countriesData
 (
 company int,
 [Year] int,
 rev  int,
 countries1 varchar(500),
 countries2 varchar(500)
 )
 insert into #countriesData(company,[Year],rev,countries1,countries2)
 values
 (12011,2010,121,'Egypt|France|America','India|France|America'),
 (12011,2011,121,'Egypt|Canda|America','India|Indonisya|America'),
 (12011,2012,121,'China|Canda|America','Pakistan|Indonisya|America'),
 (12099,2010,121,'SaudiArabia|France|America','Pakistan|sryia|America'),
 (12099,2011,121,'Egypt|Canda|German','Pakistan|Saudia|America'),
 (12099,2012,121, 'China|Italy|America','Holanda|Saudia|America')

my key is company and year and rev and not repeated

so How to handle sticks on column countries


Answers (5)