mardi 5 mai 2015

Use a Sequence in a function Sql Server

Im trying to use a sequence inside a sql function but T-Sql dosent allow the use of "New Value for", and "OPENROWSET" dosent allow me to do querys because of the security of the database.

CREATE FUNCTION dbo.newInvoice()
RETURNS varchar
AS
BEGIN
    DECLARE @NumberHold AS bigint
    SELECT @NumberHold = NEXT VALUE FOR dbo.Ten_Seq
    RETURN dbo.sfnSprintf('MyOmnyInvoice[%s]', CAST(@NumberHold as varchar),default);
END

Aucun commentaire:

Enregistrer un commentaire