0

I want to count rows table with condition is today so I add this to a columns in table. With this column I can show order in my business (today). But when many request insert to db at the same time the value count can be same. So how I can get value count not be same when insert same time. Ex this my code:

DECLARE @countNum int
SELECT SET @countNum = COUNT(*) FROM Table
INSERT INTO Table(Id, MyWantText) VALUES(NEWID(), 'This-identity-'+@countNum)

Hope for help!

love prince
  • 149
  • 1
  • 7
  • Are you looking for [SEQUENCE](https://learn.microsoft.com/en-us/sql/t-sql/statements/create-sequence-transact-sql?view=sql-server-ver16)? – D-Shih Sep 22 '22 at 08:35

0 Answers0