Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to populate PK automatically from Stored Procedure
Message
De
13/10/2002 12:23:31
 
 
À
26/09/2002 23:40:10
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Divers
Thread ID:
00704506
Message ID:
00710737
Vues:
13
Hi,

I'am new to SQL and .net.

I need to generate and retreive an unique Transaction_id (int field) for different offices; each office would start off with say 1000000001 for Office One and Office Two would start off with 2000000001; etc. The field would be in the Office Table, one row for each office.

Not sure how to update a row in a table with an int field and add +1 to it and return it to VB .net. I understand that ADO.Net is disjoined. In VFP I would simply retrieve the record, lock it, and if locked then update the field with id+1 and I would have the number I needed.

What would I need to do to accomplish this in VB .net project? I need detail because I'am not very versed in SQL and Vb.net. I learning more every day.

============================================================================
>>Hi,
>>
>>In SQL Server, is it possible to define the default of a field to be the return value of a stored procedure? For example how can I say that the default value of field CustomerPK is SP_MyNewId().
>>
>>TIA,
>>
>>Alex
>
>If you use a GUID as your PK's you can use the NewID() function as the default value. Make sure your data type is Uniqueidentifier. This is the best key type to use with distributed data.
>
>Yes, Mike is correct, you can use a User Defined Function as a default value in SQL 2000.
>
>BOb
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform