Drop Table
Support Forum for database administrators and web based access to important newsgroups related to databasesI 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
Post Follow-up to this messageHi 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
Post Follow-up to this messageWh 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.
Post Follow-up to this messageJust 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... > > >
Post Follow-up to this messageCutting 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. > >
Post Follow-up to this message"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
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread