I'm trying to use a sequence inside a T-SQL function but T-SQL doesn't allow the use of Next Value for, and OPENROWSET doesn't allow me to do queries 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
Openrowset? Please clarify.