Need help with SQL Update Statement

BettyN
Lounger
Posts: 36
Joined: 27 Sep 2011, 18:35

Need help with SQL Update Statement

Post by BettyN »

One of our users has requested that we create a job that will automatically close the RMA (return material authorization) lines and RMA header if certain criteria is met.

I have attached a document outlining the criteria. I have been working on a select statement first to make sure the records returned are meeting the criteria and I don't know how to make one of the criteria work, which is for the credit check.

I also attached my select query if needed. How to I add the code for the credit check?

Thanks for the help.
Betty
You do not have the required permissions to view the files attached to this post.

User avatar
Wendell
4StarLounger
Posts: 482
Joined: 24 Jan 2010, 15:02
Location: Colorado, USA

Re: Need help with SQL Update Statement

Post by Wendell »

It depends on what kind of field type RMADetail.iscustomercredit is. If it is a Boolean field, you can use True, if it is a numeric field, you could say Not Null. But we need to know more about where the query is being run - is it in SQL Server or is it in Access - to be really helpful. Also the version of what you are using, ie SQL Server 2012, or Access 2010.
Wendell
You can't see the view if you don't climb the mountain!

BettyN
Lounger
Posts: 36
Joined: 27 Sep 2011, 18:35

Re: Need help with SQL Update Statement

Post by BettyN »

I am using SQL 2014. The RMADetail.IsCustomerCredit field is a bit field.

Thanks.
Betty

User avatar
HansV
Administrator
Posts: 78591
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Need help with SQL Update Statement

Post by HansV »

Does it do what you want if you add

AND (RMADetail.IsCustomerCredit = 0 OR RMADetail.AWBToReceive = 'EV' OR RMADetail.AWBToReceive IS NULL)
Best wishes,
Hans

BettyN
Lounger
Posts: 36
Joined: 27 Sep 2011, 18:35

Re: Need help with SQL Update Statement

Post by BettyN »

I will give this a try, HansV. I'll let you know.

Thanks.
Betty

BettyN
Lounger
Posts: 36
Joined: 27 Sep 2011, 18:35

Re: Need help with SQL Update Statement

Post by BettyN »

Hans,

I had to make one change but it appears to be working. Thank you for the help.
Betty