SQL Server – Output comes in handy

I was looking for a single query that will snag a field, update it and return the new value.  I stumbled across the OUTPUT clause.
Dim Sql As String = “Update ArControl Set NextCustomer = Right(’0000000′ + CONVERT(VARCHAR,NextCustomer + 1),7) Output Inserted.NextCustomer Where CtlFlag = ‘CTL’;”
Dim cmd As SqlCommand = New SqlCommand(Sql, cnSyspro)
GetSysproNextCustomer = cmd.ExecuteScalar.ToString
This entry was posted in Uncategorized. Bookmark the permalink.

Comments are closed.