Solved

Problems Microsoft SQL 2005

Posted on 2012-03-29
18
369 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
ID: 37782483
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
ID: 37782523
0
 
LVL 8

Assisted Solution

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

try also

SELECT CONVERT(VARCHAR(10),GETDATE(),103)
0
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 
LVL 83

Accepted Solution

by:
CodeCruiser earned 400 total points
ID: 37782825
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
ID: 37793556
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
ID: 37795714
>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
ID: 37795955
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
ID: 37796071
I think it has to do with culture settings.
0
 

Author Comment

by:rayluvs
ID: 37796355
what is "culture"
0
 
LVL 83

Assisted Solution

by:CodeCruiser
CodeCruiser earned 400 total points
ID: 37796413
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
ID: 37796450
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
ID: 37797073
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
ID: 37799543
Thanx, good link.

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

Author Comment

by:rayluvs
ID: 37799546
or change collation?

which?

Please advice.
0
 
LVL 83

Expert Comment

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

Author Comment

by:rayluvs
ID: 37802267
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
ID: 37803200
>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
ID: 37817359
Thanx
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

749 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