ERIC CRUDELI (3/25/2013)
I got some errors.1 - easilyPatId unknow (easilyPadId come from #temp2)
2 -target table ' DI628SW.NOYAU_PATIENT.noyau. TELEPHONE_PATIENT ' of the clause OUTPUT INTO cannot be next to a relation (primary key, foreign key). Constraint of found reference: ' FK_TELEPHONE_PATIENT_PATIENT '. Note tel_id is primary key and Identity field from [TELEPHONE ]but also a primary key but not identity from [TELEPHONE_PATIENT]
I think there something wrong in Ouput but I don't know where ?
INSERT INTO [DI628SW].[NOYAU_PATIENT].[noyau].[TELEPHONE] (
tel_categorie
,tel_numero
,tel_envoi_sms
,tel_principal
,tel_commentaire
,tel_administratif
,tel_actif
)
OUTPUT INSERTED.tel_id, INSERTED.easilyPatId
into [DI628SW].[NOYAU_PATIENT].[noyau].[TELEPHONE_PATIENT] (tel_id, pat_id)
SELECT
easilyTypeNumTelId,
cnetNumTel,
cnetSMS,
cnetnumeroPrincipal,
cnetCommentaire,
0,
1
FROM #temp2
Hi Eric
You are using four-part naming for your tables and referring to two different servers, DI81SW & DI628SW. Are both of these linked servers? Can you identify which server you are connected to when you are running this code?
Cheers
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden