Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Normalising Data
Message
De
26/03/2012 09:27:54
 
 
À
26/03/2012 09:23:24
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2008
Divers
Thread ID:
01539359
Message ID:
01539364
Vues:
26
Then do it into a temp table. Concept's the same.

>That sounds disgusting :) I've never heard that word used like this before, LOL.
>
>I'm doing this in SQL Server Management Studio, not in VFP so I don't think I can use INTO CURSOR.
>
>
>>Just kinda spitballing here - if you want a unique ID per group, I'd prolly do this:
>>
>>
>>Select group, count(*) from BenefitCodeImported group by 1 into cursor CntGroups
>>
>>INSERT INTO BenefitCodeGroups 
>>SELECT DISTINCT NEWID(), Group 
>>FROM CntGroups
>>
>>
>>
>>>Hi,
>>>
>>>I've been given a spreadsheet to import into a database and need to normalise the data a bit. The source data when imported looks like this:
>>>
>>>
Group   Code  description
>>>AAA     001    Desc 1
>>>AAA     002    Desc 2
>>>BBB     003    Desc 3
>>>BBB     004    Desc 4
>>>
>>>(Of course the actual data makes more sense than those values I've put in.)
>>>
>>>I need to separate the Groups out into one table with a primary key and and the Code, Description and a Foreign Key value (pointing back to the Group).
>>>
>>>I use uniqueidentifiers as keys so was trying this:
>>>
>>>INSERT INTO BenefitCodeGroups
>>>SELECT DISTINCT NEWID(), Group
>>>FROM BenefitCodesImported
>>>
>>>but of course that doesn't work as I'll get a record for each distinct combination of NEWID() and Group.
>>>
>>>Who can help wake my brain up on a Monday morning?
"You don't manage people. You manage things - people you lead" Adm. Grace Hopper
Pflugerville, between a Rock and a Weird Place
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform