Solved

Problems Microsoft SQL 2005

Posted on 2012-03-29
18
365 Views
Last Modified: 2012-04-06
We have a situation when a PC connects to the Ms SQL instance, that it would halt a specific areas and the message that appears is "data type error.

What can be causing this?
0
Comment
Question by:rayluvs
18 Comments
 

Author Comment

by:rayluvs
Comment Utility
Ooops, wrong error message.  Tha message is:

Msg 242, Level 16, State 3, Line 3
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.

Open in new window


When debuging the VB.NET apps we see the error happens in the line where the script is:

SET @Var = (SELECT CONVERT(VARCHAR,GETDATE(),103))

Open in new window


We noticed that the Server is Ms SQL 2005 English version, but another server is Spanish version and it runs ok.  We also noticed that doing the query directly in the Studio SQL, gave same result in 2005 SQL version.

We tested other values beside 103 and it works.  We thought it was Regional, but changed it, still error.

Please adveice
0
 
LVL 15

Expert Comment

by:Anuj
Comment Utility
0
 
LVL 8

Assisted Solution

by:gpizzuto
gpizzuto earned 100 total points
Comment Utility
did you declare the variable  @Var
as
nvarchar (at least 10) ???

try also

SELECT CONVERT(VARCHAR(10),GETDATE(),103)
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 400 total points
Comment Utility
Try changing

SET @Var = (SELECT CONVERT(VARCHAR,GETDATE(),103))

to

SET @Var = (SELECT CONVERT(VARCHAR,Convert(DateTime, GETDATE(), 103),103))
0
 

Author Comment

by:rayluvs
Comment Utility
It did work.  Question, can this be an issue as I the install parameters of the SQL instance?
0
 
LVL 83

Expert Comment

by:CodeCruiser
Comment Utility
>It did work.
My suggestion?

>Question, can this be an issue as I the install parameters of the SQL instance?
Not sure what you mean.
0
 

Author Comment

by:rayluvs
Comment Utility
All suggestions worked.

What we mean by "if this can be a SQL instance issue", is since in server SQL 2000 worked excellently and in the 2005 didnt.  So can it be the actual installation?
0
 
LVL 83

Assisted Solution

by:CodeCruiser
CodeCruiser earned 400 total points
Comment Utility
I think it has to do with culture settings.
0
 

Author Comment

by:rayluvs
Comment Utility
what is "culture"
0
Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

 
LVL 83

Assisted Solution

by:CodeCruiser
CodeCruiser earned 400 total points
Comment Utility
Regional and culture settings of the system/server. Dates have different format in different cultures like dd/mm/yyyy in UK vs mm/dd/yyyy in US.
0
 

Author Comment

by:rayluvs
Comment Utility
Understood.

One last question; if truly based on "culture settings", should we reinstall SQL?
0
 
LVL 83

Assisted Solution

by:CodeCruiser
CodeCruiser earned 400 total points
Comment Utility
What are regional settings of the operating systems running the sql servers?

http://stackoverflow.com/questions/2432185/how-can-i-query-the-database-culture-sql-server-2005
0
 

Author Comment

by:rayluvs
Comment Utility
Thanx, good link.

Should we reinstall SQL or just modify the script as recommended?
0
 

Author Comment

by:rayluvs
Comment Utility
or change collation?

which?

Please advice.
0
 
LVL 83

Expert Comment

by:CodeCruiser
Comment Utility
Change script is a quick fix. Other fixes would need more investigation. Do you have a DBA?
0
 

Author Comment

by:rayluvs
Comment Utility
Don't understand by change script and quick script.  We would to just a simple SELECT various time within MsAccess SQL scripting area.

All googles searches has indicated that it not possible so this where we rely on EE expert advice.

No, we don't have a DBA
0
 
LVL 83

Expert Comment

by:CodeCruiser
Comment Utility
>Don't understand by change script and quick script.  We would to just a simple SELECT various time within MsAccess SQL scripting area

Your question was whether you should change the select statement, reinstall sql, or change collation. My response was that changing the select statement (sql script) is a quick fix if its working. Reinstalling and changing collation is also an option.
0
 

Author Comment

by:rayluvs
Comment Utility
Thanx
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

763 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now