T-SQL OPENQUERY a MySQL - Inserire ID
-
26-09-2019 - |
Domanda
Sto usando OPENQUERY a fare un inserto da MSSQL 2005 al MySQL. Come faccio a ottenere l'ultimo ID inserito sul db MySQL indietro nella mia procedura MSSQL?
Soluzione
Con il seguente lavoro intorno posso in grado di risolvere il mio problema In seguito la funzione di ottenere il valore identity
CREATE FUNCTION GetIdentity ( @tablename varchar(50) )
RETURNS varchar(50)
AS
BEGIN
-- Return the result of the function
RETURN (select cast(IDENT_CURRENT(@tablename) as varchar(50)))
END
GO
SELECT id FROM OPENQUERY(IMDECONP38, 'select Customer.dbo.GetIdentity (''CustomerMaster'') as id')
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow