I have the following table in SQL Server
:
CREATE TABLE [dbo].[tblTempPo](
[TempPoID] [int] IDENTITY(1,1) NOT NULL,
[guid] AS ([dbo].[GetIdentity]()),
[Qty] [int] NULL,
[MobileBrandID] [int] NULL,
[MobileID] [int] NULL
)
I need to insert
the current row number
to the guid
column every time a new row is added. I tried to use the following function
but it's not working as expected:
ALTER FUNCTION GetIdentity()
RETURNS INT AS
BEGIN
RETURN (SELECT top 1 ROW_NUMBER() OVER(ORDER BY TempPoID asc)FROM tblTempPo)
END