This should fix the syntax errors, by removing the IIF's. But I question whether the logic is correct. Note, I removed the IIF's because they are STUPID. I mean they can never test true.
Main Topics
Browse All TopicsHello,
I need to convert the following query from Access to SQL. I've started, but am getting errors on line 16.
I could use some assistance.
SELECT DISTINCT Sum(Job_Op_Time.Act_Run_Qt
Sum(Job_Op_Time.Act_Setup_
Job.Job As JobNumber,
Job.Comment As Comments,
Job.Note_Text As SerialNumbers,
Job_Operation.Status As OpStatus,
User_Values.Numeric1 As Split,
Job_Operation.Operation_Se
User_Values.Text4 As ClosedBy,
Job.Part_Number As PartNumber
From User_Values
INNER JOIN Job ON User_Values.User_Values = Job.User_Values
INNER JOIN Job_Operation ON Job_Operation.Job = Job.Job
LEFT JOIN Job_Operation_Time ON Job_Operation_Time.Job_Ope
WHERE User_Values.Numeric1 < (99 + 1) AND User_Values.Numeric1 >= 99
AND Job.Part_Number=IIF (Len('FG')=0, Job.Part_Number,'FG')
AND Job.Job=IIF (Len('1000')=0, Job.Job,'1000')
AND Job_Operation.Operation_Se
GROUP BY Job.Job, Job.Comment, Job.Note_Text, Job_Operation.Status, User_Values.Numeric1,
Job_Operation.Operation_Se
Thanks,
JMO9966
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Thanks guys,
I'm not the original auther of this query so I'm not sure why they were using the IIF statements.
With your help, I am now down to one error. I should not the Comment and Note_Text fields are Memo fields in the database.
SELECT Sum(Job_Operation_Time.Act
Sum(Job_Operation_Time.Act
Job.Job As JobNumber,
IsNull(Job.Comment,'') As Comments,
IsNull(Job.Note_Text,'') As SerialNumbers,
Job_Operation.Status As OpStatus,
User_Values.Numeric1 As Split,
Job_Operation.Operation_Se
User_Values.Text4 As ClosedBy,
Job.Part_Number As PartNumber
From User_Values
INNER JOIN Job ON User_Values.User_Values = Job.User_Values
INNER JOIN Job_Operation ON Job_Operation.Job = Job.Job
LEFT JOIN Job_Operation_Time ON Job_Operation_Time.Job_Ope
WHERE User_Values.Numeric1 < (99 + 1) AND User_Values.Numeric1 >= 99
AND Job.Part_Number='FG'
AND Job.Job='1000'
AND Job_Operation.Operation_Se
GROUP BY Job.Job, Job.Comment, Job.Note_Text, Job_Operation.Status, User_Values.Numeric1,
Job_Operation.Operation_Se
Msg 306, Level 16, State 2, Line 1
The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator.
Please clarify the datatype of job.comment and Job.note_text. You say "memo", but there is no such thing in SQL Server.
If you can change the datatype to VARCHAR(xxxx), the problem goes away. If you cannot, then you need to cast the results into varchar before grouping. Like this:
group by Cast(job.comment as varchar(xxxx))
Business Accounts
Answer for Membership
by: silemonePosted on 2009-10-28 at 13:08:14ID: 25687679
Try a converter like one of these... m/business _directory /access-to - mssql/
this one's free for 30 days, but after that you would have to pay...
http://www.downloadatoz.co