Mabuhay! Hi again! What would be the best sql query for this one;
I need to insert a new row in the table customer. If I'll use the insert into command with values it will arise an error on no null on ID. So I change my code to select max and +1 on ids but what I've got now is id+1 but I've noticed was the IDs still getting the same value like 1073905737 but different Account Number. Is there any cod ethat I forgot to write?
Code:
insert into [DBName].[dbo].[Customer]([ID],[AccountNumber]) values((Select max (id)from [Customer]) +1, '000700005951')
Thanks,
Chris
*This post is locked for comments
Mabuhay Sir Ed,
Thanks for your reply and for reminding those minumum requirements on adding a row in customer table. With the IDs number do i need to manually add + or is there any code that will lookup for the updated ID and ill just add 1 on it so when i insert new one it will just follow the latest ID?
Or is there any conflict if Ill just manually add 1 to the ID i see that time even if theres a branch is in connection and they will just auto on what i added?
depends on your plans for the customer records.
At a minimum you need, ID, HQID, AccountNumber, FirstName, LastName.
Then you need GlobalCustomer =1 if this customer will push down to stores, The default is 0.
FirstName and LastName are technically optional, but then you don't know from the HQ Manager which accountnumber is whose account.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 290,818 Super User 2024 Season 2
Martin Dráb 229,147 Most Valuable Professional
nmaenpaa 101,156