Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need Help Converting Access Query to TSQL

Status
Not open for further replies.

rodeomount

Programmer
Sep 25, 2007
50
0
0
US
I need to convert the following Access query to TSQL. The only problem is that I don't have any experience with a query like this. Any help is deeply appreciated.



(((IIf([tbl0000Tracking]![AvailableScanDate] Is Not Null,CStr(Format([tbl0000Tracking]![AvailableScanDate],"mm/dd/yyyy")),Null)) Is Not Null)
AND ((WorkDaysDiff([tbl0000Tracking]![AvailableScanDate],Now()))>0)
AND ((Left([tbl0000Shipments]![Carrier],3))="UPS") AND ((tbl0000Tracking.DelvScanDate) Is Null)
AND ((tbl0000Tracking_2.TrackingNumber) Is Null) AND ((tbl0000Tracking_1.TrackingNumber) Is Null)
AND ((tbl0000Shipments.AbandonedRptSent) Is Null));
 
Have a look at the three following functions. You should be able to use any of these functions to replace your existing IIF function:

COALESCE
CASE
ISNULL

To get the current date and time, you can use GetDate instead of your Now method.


-------------------------------------------------------

Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]
[URL unfurl="true"]http://mdssolutions.co.uk[/url] - Delivering professional ASP.NET solutions
[URL unfurl="true"]http://weblogs.asp.net/marksmith[/url]
 
How does "WorkDaysDiff" work? I'm assuming the following:

WorkDaysDiff(A,B)

Is equivalent to A - B
 
I think WorkDaysDiff will be a user written function rather than a built-in Access function. ave a look through the Access database to find out. If it is, you will have to write a similar function in SQL Server.


-------------------------------------------------------

Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]
[URL unfurl="true"]http://mdssolutions.co.uk[/url] - Delivering professional ASP.NET solutions
[URL unfurl="true"]http://weblogs.asp.net/marksmith[/url]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top