SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


out-of-range value


out-of-range value

Author
Message
Walshy
Walshy
Valued Member
Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)

Group: General Forum Members
Points: 52 Visits: 11132
Hi,

I have a system that has been moved from a SQL2008R2 box to a SQL2012 box but there is query it executes (had to run a trace to find it) that throws the old 'The conversion of a varchar data type to a smalldatetime data type resulted in an out-of-range value'. The query is evaluating the UK date '29/05/2013'. I know the best way to fix it would be to amend the query but that would involve the 3rd party to amend the front-end which is not going to happen.

The new server is also running Windows 2012 and I've checked all locales are set to United Kingdom and the dates are set to 'dd\mm\yyyy'. The language the login the front-end uses is also set to 'British English'.

Any thoughts on how to get round this without altering the code. Is SQL2012 more stringent with dates?

Any help greatly appreciated.
Joie Andrew
Joie Andrew
SSCrazy
SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)

Group: General Forum Members
Points: 2351 Visits: 2032
Not sure what you mean by "the login front-end". Is this the SQL Server or another server? What happens if you open up a query window in SSMS and run SELECT @@LANGUAGE?

Can you post the query that is throwing the error?

Joie Andrew
"Since 1982"
dwain.c
dwain.c
SSCertifiable
SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)

Group: General Forum Members
Points: 7403 Visits: 6431
Probably not a great suggestion but if you can't correct it in the fronte end and if this is happening during an INSERT or UPDATE, you could add an INSTEAD OF trigger to the table and fix the value before completing the DML (within that trigger).


My mantra: No loops! No CURSORs! No RBAR! Hoo-uh!

My thought question: Have you ever been told that your query runs too fast?

My advice:
INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.


Need to UNPIVOT? Why not CROSS APPLY VALUES instead?
Since random numbers are too important to be left to chance, let's generate some!
Learn to understand recursive CTEs by example.
Splitting strings based on patterns can be fast!
My temporal SQL musings: Calendar Tables, an Easter SQL, Time Slots and Self-maintaining, Contiguous Effective Dates in Temporal Tables
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search