Noob question about a SQL Query

xenon
Member Posts: 30
Hi all.
I think this is a fairly basic query but I mainly concern myself with general admin (backups etc) from the management studio.
Basically, I want to select a load of items from the Sales Price Table which are Customer Prices and have Expired. When I find them I want to set a custom field (Blocked Pending Price Check) on the corresponding item on the Item Table
My script to select the items in question is simple enough (and gives the desired result):
select [Item No_] from [MyCompany$Sales Price]
where [Ending Date] < '04/02/2015 00:00:00.000' and [Sales Type] = 0
and [Sales Code] = 'CustomerA'
This gives a list of all items that I want to set the flag on but I'm guessing I need to assign the above results to some sort of variable (let's call it 'A') such that I can do something along the lines of:
update [MyCompany$Item]
set [Blocked Pending Price Check] = 1 where No_ = A
Any help appreciated! [-o<
I think this is a fairly basic query but I mainly concern myself with general admin (backups etc) from the management studio.
Basically, I want to select a load of items from the Sales Price Table which are Customer Prices and have Expired. When I find them I want to set a custom field (Blocked Pending Price Check) on the corresponding item on the Item Table
My script to select the items in question is simple enough (and gives the desired result):
select [Item No_] from [MyCompany$Sales Price]
where [Ending Date] < '04/02/2015 00:00:00.000' and [Sales Type] = 0
and [Sales Code] = 'CustomerA'
This gives a list of all items that I want to set the flag on but I'm guessing I need to assign the above results to some sort of variable (let's call it 'A') such that I can do something along the lines of:
update [MyCompany$Item]
set [Blocked Pending Price Check] = 1 where No_ = A
Any help appreciated! [-o<
0
Comments
-
update [MyCompany$Item] set [Blocked Pending Price Check] = 1 where No_ in ( select [Item No_] from [MyCompany$Sales Price] where [Ending Date] < '04/02/2015 00:00:00.000' and [Sales Type] = 0 and [Sales Code] = 'CustomerA' )
0 -
Many thanks - perfect.
=D>0 -
Also - one other question
Can I use an argument like TODAY() in Excel so that rather than typing the date longhand as in:
where
[Ending Date] < '04/02/2015 00:00:00.000'
Can I somehow say where [Ending Date] < "TODAY" so that I can run this at any time (or even scheduled) without having to edit the query?0 -
I've worked it out:
where [Ending Date] < (getdate())....
Thanks.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions