• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 384
  • Last Modified:

how so I get the uniqueidentifier after insert in SQLEXPRESS?

I need to create a batch number for entering a set of records.  I have a batch table that stores the unique batch number and other information about the batch.  When the user clicks "New" to create a new batch, I use the Insert command to add the record.  But then I need the uniqueidentifier that was created for the batch number.  What is the SQL syntax for this?

Thanks in advance!
1 Solution
DECLARE @GUID uniqueidentifier

and return the value of @GUID as output parameter
Agent909Author Commented:
This isn't going to work.  I was thinking that a primary key, as in MS Access, can be an auto-generated number that makes each record unique in the table.  I guess the uniqueidentifier does that, but it's much too large for my purposes.  The situation I have is where I have a Batch table that needs a primary key to identify the batch uniquely.  For example, I'd like to add a new batch record, and have the first batch number be '1', the second batch be number '2', etc.  Is this a number I will have to keep track of and increment by one for each new batch myself?  There must be a way that SQLEXPRESS can do this for me.  Do you have any suggestions?  Thanks, and sorry I didn't understand more about what I was asking in the first place.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now