4

I have a little problem, but I'm sure it s not really complicated.

It's just hard to find the key word to describe the problem and find a solution

I want to update a column in a table using parameters from this table for a query on an other table.

Example : I have Header + 2 lines

IDSOURCE, IDCIBLE, IDENTIFIANT, TABLE_CIBLE, NOM_ATTRIBUT, NOM_CHAMP_IDENTTIFIANT, NOM_CIBLE 
--------------------------------------------------------------------------------------------    
DMT_1000, DMT_1000, 1000, [dictionnaire].[dbo].[TABLE_CHAMPS_DATAMART], NOM_CHAMP_DMT, IDENTIFIANT_CHAMP_DATAMART, NULL 
DMT_1001, DMT_1001, 1001, [dictionnaire].[dbo].[TABLE_CHAMPS_DATAMART], NOM_CHAMP_DMT, IDENTIFIANT_CHAMP_DATAMART, NULL

And I want to update the last column of each line with something like :

UPDATE
    Table
SET
    Table.NOM_CIBLE = SELECT table.NOM_ATTRIBUT FROM table.TABLE_CIBLE WHERE table.NOM_CHAMP_IDENTTIFIANT = table.IDCIBLE
FROM
    Table

Don't know if it s clear.

Thanks for your help.

huMpty duMpty
  • 14,346
  • 14
  • 60
  • 99
Hystic
  • 145
  • 5

1 Answers1

0

This sounds like situation where you could use a cursor. Check out this StackOverflow question How to update a column fetched by a cursor

Community
  • 1
  • 1
Wynter
  • 73
  • 1
  • 6