Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SQL error

Posted on 2014-10-16
4
Medium Priority
?
147 Views
Last Modified: 2014-10-16
Dear,

I am getting error for my web page which is showing below view.

Microsoft OLE DB Provider for SQL Server error '80004005'
Invalid length parameter passed to the RIGHT function.

There was no issue before and no recent change made. Screen shot of error is also attached.

Please help to solve it. I am using SQL 2005.

Thanks.,

VIEW

SELECT     dbo.shopcountries.countryname, dbo.orders.odate, dbo.orders.orderamount, dbo.orders.oemail, dbo.orders.oshipmethod, dbo.orders.oshipcost, 
                      dbo.orders.oshipname, dbo.orders.oshipcompany, dbo.orders.oshipemail, dbo.orders.oshipmethodtype, dbo.orders.oshipaddress, 
                      dbo.orders.oshiptown, dbo.orders.oshipzip, dbo.orders.oshipstate, dbo.orders.oshipcountry, dbo.orders.opaymethod, dbo.orders.oshipaddress2, 
                      dbo.s_ems_orders.emsid, dbo.s_ems_orders.ems_trackno, dbo.s_ems_orders.orderid, dbo.s_ems_orders.s_date, dbo.s_ems_orders.printed, 
                      dbo.s_ems_orders.Pickup_date, dbo.s_ems_orders.Pickup_time, dbo.s_ems_orders.recvd_for, dbo.s_ems_orders.emp_code, 
                      dbo.s_ems_orders.No_of_pcs, dbo.s_ems_orders.weight, dbo.s_ems_orders.nature_good_doc, dbo.s_ems_orders.nature_good_non_doc, 
                      dbo.s_ems_orders.breif_description, dbo.s_ems_orders.decl_inv_value, dbo.s_ems_orders.delivery_date, dbo.s_ems_orders.delivery_time, 
                      dbo.s_ems_orders.service_domestic, dbo.s_ems_orders.service_intl, dbo.s_ems_orders.payment_cash, dbo.s_ems_orders.payment_credit, 
                      dbo.s_ems_orders.ship_dom_exp, dbo.s_ems_orders.ship_intl_exp, dbo.s_ems_orders.ship_intra_ciity, dbo.s_ems_orders.ship_premium, 
                      dbo.s_ems_orders.ship_prepaid, dbo.s_ems_orders.ship_cod, dbo.s_ems_orders.credit_account, dbo.s_ems_orders.charges_basic, 
                      dbo.s_ems_orders.charges_insurance, dbo.s_ems_orders.charges_total, dbo.s_ems_orders.pickup_remarks, dbo.s_ems_orders.s_printed, 
                      dbo.s_ems_orders.s_system_id, dbo.s_ems_orders.service, dbo.s_ems_orders.userid, dbo.s_ems_orders.lastupdate, 
                      dbo.s_ems_orders.process_email_send, dbo.s_ems_orders.process_date, dbo.s_ems_orders.track_email, dbo.s_ems_orders.track_email_date, 
                      dbo.s_ems_orders.resend_process_email, dbo.s_ems_orders.disptach_req, dbo.s_ems_orders.dispatch_req_date, dbo.s_ems_orders.feedback_sent, 
                      dbo.s_ems_orders.feedback_sent_date, dbo.s_ems_orders.partner, dbo.s_ems_orders.partner_track, dbo.s_ems_orders.ship_status, 
                      dbo.orders.ophone, dbo.orders.ostatus, dbo.s_ems_orders.s_system_id AS chec_systemid, dbo.s_ems_orders.s_printed AS chec_printed, 
                      dbo.s_ems_orders.lastupdate AS Lastupdated, dbo.s_ems_orders.userid AS Usermade, dbo.s_ems_orders.service AS Servioceselected, 
                      dbo.s_ems_orders.process_email_send AS order_process, dbo.s_ems_orders.process_date AS order_process_date, 
                      dbo.s_ems_orders.resend_process_email AS track_resend, dbo.orders.ofirstname, dbo.orders.olastname, dbo.orders.oprocessed, 
                      dbo.s_ems_orders.track_email_date AS [tracking date sent], dbo.s_ems_orders.track_email AS [tracking email], 
                      dbo.s_ems_orders.dispatch_req_date AS [EMS req date], dbo.s_ems_orders.disptach_req AS [EMS dispatch req], 
                      RIGHT(dbo.s_ems_orders.ems_trackno, LEN(dbo.s_ems_orders.ems_trackno) - 4) AS Skynet_track, 
                      dbo.s_ems_orders.feedback_sent_date AS d_feedback, dbo.s_ems_orders.feedback_sent AS feedback, dbo.s_skynet_mapping.partner_url, 
                      dbo.s_ems_orders.ship_status AS shipping_status, dbo.s_ems_orders.shipper_remarks, dbo.s_ems_orders.customer_remarks
FROM         dbo.s_skynet_mapping RIGHT OUTER JOIN
                      dbo.s_ems_orders ON dbo.s_skynet_mapping.partner = dbo.s_ems_orders.partner LEFT OUTER JOIN
                      dbo.shopcountries RIGHT OUTER JOIN
                      dbo.orders ON dbo.shopcountries.country = dbo.orders.oshipcountry ON dbo.s_ems_orders.orderid = dbo.orders.orderid
WHERE     (dbo.s_ems_orders.service = 'SKYNET')

Open in new window

2014-10-16-20-45-21.jpg
0
Comment
Question by:NickHoward
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 15

Expert Comment

by:Haris Djulic
ID: 40385237
Most probably the issue is with data can you check if you have the column value less than 4 chars i.e.

select  ems_trackno
from dbo.s_ems_orders
where LEN(dbo.s_ems_orders.ems_trackno) <4
0
 
LVL 15

Expert Comment

by:Haris Djulic
ID: 40385240
If there is those less than 4 you can use something like this :

SELECT     dbo.shopcountries.countryname, dbo.orders.odate, dbo.orders.orderamount, dbo.orders.oemail, dbo.orders.oshipmethod, dbo.orders.oshipcost, 
                      dbo.orders.oshipname, dbo.orders.oshipcompany, dbo.orders.oshipemail, dbo.orders.oshipmethodtype, dbo.orders.oshipaddress, 
                      dbo.orders.oshiptown, dbo.orders.oshipzip, dbo.orders.oshipstate, dbo.orders.oshipcountry, dbo.orders.opaymethod, dbo.orders.oshipaddress2, 
                      dbo.s_ems_orders.emsid, dbo.s_ems_orders.ems_trackno, dbo.s_ems_orders.orderid, dbo.s_ems_orders.s_date, dbo.s_ems_orders.printed, 
                      dbo.s_ems_orders.Pickup_date, dbo.s_ems_orders.Pickup_time, dbo.s_ems_orders.recvd_for, dbo.s_ems_orders.emp_code, 
                      dbo.s_ems_orders.No_of_pcs, dbo.s_ems_orders.weight, dbo.s_ems_orders.nature_good_doc, dbo.s_ems_orders.nature_good_non_doc, 
                      dbo.s_ems_orders.breif_description, dbo.s_ems_orders.decl_inv_value, dbo.s_ems_orders.delivery_date, dbo.s_ems_orders.delivery_time, 
                      dbo.s_ems_orders.service_domestic, dbo.s_ems_orders.service_intl, dbo.s_ems_orders.payment_cash, dbo.s_ems_orders.payment_credit, 
                      dbo.s_ems_orders.ship_dom_exp, dbo.s_ems_orders.ship_intl_exp, dbo.s_ems_orders.ship_intra_ciity, dbo.s_ems_orders.ship_premium, 
                      dbo.s_ems_orders.ship_prepaid, dbo.s_ems_orders.ship_cod, dbo.s_ems_orders.credit_account, dbo.s_ems_orders.charges_basic, 
                      dbo.s_ems_orders.charges_insurance, dbo.s_ems_orders.charges_total, dbo.s_ems_orders.pickup_remarks, dbo.s_ems_orders.s_printed, 
                      dbo.s_ems_orders.s_system_id, dbo.s_ems_orders.service, dbo.s_ems_orders.userid, dbo.s_ems_orders.lastupdate,
                      dbo.s_ems_orders.process_email_send, dbo.s_ems_orders.process_date, dbo.s_ems_orders.track_email, dbo.s_ems_orders.track_email_date, 
                      dbo.s_ems_orders.resend_process_email, dbo.s_ems_orders.disptach_req, dbo.s_ems_orders.dispatch_req_date, dbo.s_ems_orders.feedback_sent, 
                      dbo.s_ems_orders.feedback_sent_date, dbo.s_ems_orders.partner, dbo.s_ems_orders.partner_track, dbo.s_ems_orders.ship_status, 
                      dbo.orders.ophone, dbo.orders.ostatus, dbo.s_ems_orders.s_system_id AS chec_systemid, dbo.s_ems_orders.s_printed AS chec_printed, 
                      dbo.s_ems_orders.lastupdate AS Lastupdated, dbo.s_ems_orders.userid AS Usermade, dbo.s_ems_orders.service AS Servioceselected, 
                      dbo.s_ems_orders.process_email_send AS order_process, dbo.s_ems_orders.process_date AS order_process_date, 
                      dbo.s_ems_orders.resend_process_email AS track_resend, dbo.orders.ofirstname, dbo.orders.olastname, dbo.orders.oprocessed, 
                      dbo.s_ems_orders.track_email_date AS [tracking date sent], dbo.s_ems_orders.track_email AS [tracking email], 
                      dbo.s_ems_orders.dispatch_req_date AS [EMS req date], dbo.s_ems_orders.disptach_req AS [EMS dispatch req], 
                      RIGHT(dbo.s_ems_orders.ems_trackno, LEN(dbo.s_ems_orders.ems_trackno) - case when LEN(dbo.s_ems_orders.ems_trackno) - 4 >= 0 then LEN(dbo.s_ems_orders.ems_trackno) - 4 else 0 end ) AS Skynet_track, 
                      dbo.s_ems_orders.feedback_sent_date AS d_feedback, dbo.s_ems_orders.feedback_sent AS feedback, dbo.s_skynet_mapping.partner_url, 
                      dbo.s_ems_orders.ship_status AS shipping_status, dbo.s_ems_orders.shipper_remarks, dbo.s_ems_orders.customer_remarks
FROM         dbo.s_skynet_mapping RIGHT OUTER JOIN
                      dbo.s_ems_orders ON dbo.s_skynet_mapping.partner = dbo.s_ems_orders.partner LEFT OUTER JOIN
                      dbo.shopcountries RIGHT OUTER JOIN
                      dbo.orders ON dbo.shopcountries.country = dbo.orders.oshipcountry ON dbo.s_ems_orders.orderid = dbo.orders.orderid
WHERE     (dbo.s_ems_orders.service = 'SKYNET')

Open in new window

0
 

Author Comment

by:NickHoward
ID: 40385242
Yeah I already spotted out and this was the reason for error. Any way I can avoid this in future?
0
 
LVL 15

Accepted Solution

by:
Haris Djulic earned 2000 total points
ID: 40385246
I posted the code which you can use . It is worked on case function which will check if the length is less than 4 than if it is the it will put 0 if not it will calculate len -4
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question