Drop Table

Support Forum for database administrators and web based access to important newsgroups related to databases
Register on Database Support Forum Edit your profileCalendarFind other Database Support forum membersFrequently Asked QuestionsSearch this forum -> 
For Database admins: Free Database-related Magazines Now Free shipping to Texas


Post New Thread










Thread
Author

DateTime problem....
I run the below code on several servers via a scheduled jobs, on one server
the job fails reporting "Error converting data type char to datetime.
[SQLSTATE 42000] (Error 8114)", Any ideas on where to start troubleshoot
ing
this server, I can't think?

DECLARE @BAKDate Char(10)

SET @BAKDate =  CONVERT(Char(10),Get
Date()-28, 102)
EXEC  sp_delete_backuphist
ory @BAKDate

Report this thread to moderator Post Follow-up to this message
Old Post
BenUK
01-31-06 12:23 PM


Re: DateTime problem....
Hi
 CONVERT(Char(10),Get
Date()-28, 112)





"BenUK" <BenUK@discussions.microsoft.com> wrote in message
news:DC58F65D-C5AC-4FA4-A014- 8C4B492B9196@microso
ft.com...
>I run the below code on several servers via a scheduled jobs, on one server
> the job fails reporting "Error converting data type char to datetime.
> [SQLSTATE 42000] (Error 8114)", Any ideas on where to start
> troubleshooting
> this server, I can't think?
>
> DECLARE @BAKDate Char(10)
>
> SET @BAKDate =  CONVERT(Char(10),Get
Date()-28, 102)
> EXEC  sp_delete_backuphist
ory @BAKDate



Report this thread to moderator Post Follow-up to this message
Old Post
Uri Dimant
01-31-06 12:23 PM


Re: DateTime problem....
Wh are you back casting the value to char if a datetime is needed ?

DECLARE @BAKDate datetime


SET @BAKDate = GetDate()-28
EXEC  sp_delete_backuphist
ory @BAKDate


HTH, Jens Suessmeyer.


Report this thread to moderator Post Follow-up to this message
Old Post
Jens
01-31-06 12:23 PM


Re: DateTime problem....
Just reran the job manually, using original code and success, I figure it
must have been due to the code looking to last year and getting confused...
...strange???

"Uri Dimant" wrote:

> Hi
>  CONVERT(Char(10),Get
Date()-28, 112)
>
>
>
>
>
> "BenUK" <BenUK@discussions.microsoft.com> wrote in message
> news:DC58F65D-C5AC-4FA4-A014- 8C4B492B9196@microso
ft.com... 
>
>
>

Report this thread to moderator Post Follow-up to this message
Old Post
BenUK
01-31-06 12:23 PM


Re: DateTime problem....
Cutting the time element...

"Jens" wrote:

> Wh are you back casting the value to char if a datetime is needed ?
>
> DECLARE @BAKDate datetime
>
>
> SET @BAKDate = GetDate()-28
> EXEC  sp_delete_backuphist
ory @BAKDate
>
>
> HTH, Jens Suessmeyer.
>
>

Report this thread to moderator Post Follow-up to this message
Old Post
BenUK
01-31-06 12:23 PM


Re: DateTime problem....
"BenUK" <BenUK@discussions.microsoft.com> wrote in message
news:6958188D-93F6-42C1-8F97- 2E75001DA6C9@microso
ft.com...
> Cutting the time element...

Well, the argument is defined as a datetime.  You are relying on an unsafe
character format AND implicit conversion - hence, the error.

http://www.karaszi.com/sqlserver/in...e
Portion



Report this thread to moderator Post Follow-up to this message
Old Post
Scott Morris
01-31-06 02:23 PM


Sponsored Links





Last Thread Next Thread
Post New Thread

MS SQL Server archive

Show a Printable Version Email This Page to Someone! Receive updates to this thread
Microsoft SQL Server
Access database support
PostgreSQL Replication
SQL Server ODBC
FoxPro Support
PostgreSQL pgAdmin
SQL Server Clustering
MySQL ODBC
Web Applications with dBASE
SQL Server CE
MySQL++
Sybase Database Support
MS SQL Full Text Search
PostgreSQL Administration
SQL Anywhere support
DB2 UDB Database
Paradox Database Support
Filemaker Database
Berkley DB
SQL 2000/2000i database
ASE Database
Forum Jump:
All times are GMT. The time now is 05:02 AM.

 
Mobile devices forum | Database support forum archive




Copyrights DropTable.com Database Support Forum 2004 - 2006