Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sql Merge and Output command
Message
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01564461
Message ID:
01564822
Vues:
35
>Hi Naomi Thanks for replying.
>So if I have
>Source table as: FLDS_1 FLDS_2 FLDS_3
>Destination Table as: FLDD_1 FLDD_2 FLDD_3
>
>The names of the fields I require in the Output Into table are:
>
> FLDS_1 FLDS_2 FLDS_3
> FLDD_1 FLDD_2 FLDD_3
>
>I.E. A L L the fields from both the input and output tables with exactly the same names ???
>
>Regards,
>Gerard
>
If object_id('tempdb..#Output',N'U') IS NOT NULL drop table #Output

create table #Output (Action varchar(100), FLDS_1 int, FLDS_2 int, FLDS_3 varchar(10),
FLDD_1 int, FLDD_2 int, FLDD_3 varchar(10)) -- use correct types

MERGE DestinationTable as Target
USING SourceTable as source
ON ...
WHEN ...

OUTPUT $Action, Source.FLDS_1, Source.FLDS_2, Source.FLDS_3,
Inserted.FLDD_1, Inserted.FLDD_2, Inserted.FLDD_3 INTO #Output
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform