Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Friday, May 3, 2024 
 
slxdeveloper.com Community Forums  
   
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
 Data & Imports Forums - T-SQL & Queries
Forum to discuss general T-SQL questions and help with queries related to SalesLogix data. View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to T-SQL & Queries | New ThreadView:  Search:  
 Author  Thread: Is there a better way to write UPDATE Batch query
Veronka Capone
Posts: 113
 
Is there a better way to write UPDATE Batch queryYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 17 Feb 09 10:48 AM
I need to update 2 fields on ESI_Equipment. Right now my query looks like this:

UPDATE ESI_Equipment
SET Renewal_Type = (SELECT
CASE WHEN IsPrintSuccess = 1 THEN 'Print' ELSE '' END +
CASE WHEN IsEmailSuccess = 1 THEN ', Email' ELSE '' END +
CASE WHEN IsFaxSuccess = 1 THEN ', Fax' ELSE '' END +
CASE WHEN IsEdit = 1 THEN ', Custom' ELSE '' END
FROM tbl_ProcessContractHistory ph
WHERE ESI_Equipment.ESI_EquipmentID = ph.EquipmentID AND BatchID = 'SLX_000001'),
Renewal_Sent = (SELECT DateProcessCompleted
FROM tbl_ProcessContractHistory ph2
WHERE ESI_Equipment.ESI_EquipmentID = ph2.EquipmentID AND BatchID = 'SLX_000001')
WHERE EXISTS (SELECT *
FROM tbl_ProcessContractHistory ph
WHERE ph.EquipmentID = ESI_Equipment.ESI_EquipmentID)


Is there a better way? (It seems odd to write 1 subquery for each field).

Thanks.
[Reply][Quote]
Phil Parkin
Posts: 819
Top 10 forum poster: 819 posts
 
Re: Is there a better way to write UPDATE Batch queryYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 17 Feb 09 11:13 PM
There's some fairly complex business logic in there and, to me, the query looks as good as it can be.

I do not expect that this would run through the SLX provider though - are you running in a zero-sync environment?

Phil
[Reply][Quote]
Veronka Capone
Posts: 113
 
Re: Is there a better way to write UPDATE Batch queryYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 18 Feb 09 7:44 AM
It's running in a .NET app through SLX provider. It works also in SLX Admin Query, and yes, I am not concerned about remotes.

Thanks!
[Reply][Quote]
Phil Parkin
Posts: 819
Top 10 forum poster: 819 posts
 
Re: Is there a better way to write UPDATE Batch queryYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 18 Feb 09 10:03 AM
My expectation was clearly wrong on this occasion
[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2024 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 5/3/2024 4:30:05 AM