Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

Assigning max value + 1 to a column

$
0
0
HiI need something like this pseudo code; [code="sql"]UPDATE OrdersSET InvoiceNo = MAX(InvoiceNo)FROM Orders INNER JOIN SetupAccountTypes ON Orders.AccountTypeID = SetupAccountTypes.IDWHERE (SetupAccountTypes.AccountType = N'COD') AND (Orders.DeliveryDate >= CONVERT(DATETIME, '2016-01-01 00:00:00', 102)) AND (Orders.DeliveryDate <= CONVERT(DATETIME, '2016-01-31 00:00:00', 102))[/code]That is, a bunch of rows selected under the given WHERE criteria get assigned invoice numbers incrementally.How do I achieve this please in T-SQL or otherwise?ThanksRegards

Viewing all articles
Browse latest Browse all 3145

Trending Articles