Hi,
In SQL Server, one of the field, we set ID as primary key of the table. To make sure that field is unique there are 2 ways that I can approach:
(1) Set Identity as Yes, Identity Seed and Identity Increment as well, so we call it as Autonumber (same case in Access DB).
(2) We create a function to produce unique Id:
'---- Auto Number Increment ----
Function AutoNumInc(TableName, IncRec)
Set RSAutoNumInc = Server.CreateObject("ADODB.Recordset"
RSAutoNumInc.Open "SELECT Max("& IncRec &" AS MaxRec FROM "& TableName, Conn,3, 1, 0
If isNull(RSAutoNumInc("MaxRec") Then
AutoNumInc = 1
Else
AutoNumInc = CInt(RSAutoNumInc("MaxRec") + 1
End If
RSAutoNumInc.Close
Set RSAutoNumInc = Nothing
End Function
Which one you think is the best way if we're going to create centralize database?
Thanks you,
Martin
In SQL Server, one of the field, we set ID as primary key of the table. To make sure that field is unique there are 2 ways that I can approach:
(1) Set Identity as Yes, Identity Seed and Identity Increment as well, so we call it as Autonumber (same case in Access DB).
(2) We create a function to produce unique Id:
'---- Auto Number Increment ----
Function AutoNumInc(TableName, IncRec)
Set RSAutoNumInc = Server.CreateObject("ADODB.Recordset"
RSAutoNumInc.Open "SELECT Max("& IncRec &" AS MaxRec FROM "& TableName, Conn,3, 1, 0
If isNull(RSAutoNumInc("MaxRec") Then
AutoNumInc = 1
Else
AutoNumInc = CInt(RSAutoNumInc("MaxRec") + 1
End If
RSAutoNumInc.Close
Set RSAutoNumInc = Nothing
End Function
Which one you think is the best way if we're going to create centralize database?
Thanks you,
Martin