First of all: this is not a kind of a IDENTITY() field.
In QlikView, it is used to generate a number based on parameters send to function. See its documentation here: https://help.qlik.com/en-US/qlikview/November2017/Subsystems/Client/Content/Scripting/CounterFunctions/autonumber.htm
In short, you send a parameter to it and it returns an integer that will identify the same arguments for the rest of script. If you send...
AutoNumber('Name 900') -> returns 1
AutoNumber('Name 300') -> returns 2
AutoNumber('Name 001') -> returns 3
AutoNumber('Name 900') -> returns 1 ... again
and because the parameter is already in the intern list of AutoNumber
I tried to build some like that in SQL Server, but is not possible use SELECTs inside scalar functions.
My need is to get something like...
INSERT INTO FacSales (SumaryID, InvoiceID, InvoiceDate
, ProductID, SaleValue, CustomerID, VendorID)
SELECT AutoNumber(sale.VendorID, sale.CustomerID, sale.ProductID)
, sale.InvoiceID
, sale.SaleDate
, details.ProductID
, etc, etc, etc.
Is there, inside SQL Server, a "native" function that perform this? Or, is there a way to build this using a procedure/function?
Thanks.