Home All Groups Group Topic Archive Search About

Bad datetime values stored by SQL Server 2000

Author
8 Jul 2005 12:24 PM
beth
I'm having difficulty coming up with a method to store a datetime value when
inserting new rows into a table. I have tried the following methods, on three
different columns in the same table;

1) Default Value (getdate()) on column testInsertedDt

2) column InsertedDt/getdate() in INSERT statement itself;

INSERT INTO db1..RG_EMPLOYEE
       (column1, column2, ... InsertedDt)
SELECT t.column1, t.column2, ... getdate()
  FROM db2..RG_EMPLOYEE t
WHERE rg_id NOT IN (SELECT rg_id FROM db1..RG_EMPLOYEE)

3) Insert trigger;

create trigger [trggrInsRG_EMPLOYEE]
    on [dbo].[RG_EMPLOYEE]
   for insert as
       update RG_EMPLOYEE
          set InsertedDtTrigger = getdate()
         from RG_EMPLOYEE e
              join inserted i on i.rg_id = e.rg_id

All three methods produce garbage values, such as

32539-05-20 869:56:11.733
1900-01-01 31:04:08.107
-21424-12-31 3124:26:24.493

What am I doing wrong?

thanks, beth

Author
8 Jul 2005 12:51 PM
Alejandro Mesa
Can you post the table definition?


AMB

Show quote
"beth" wrote:

> I'm having difficulty coming up with a method to store a datetime value when
> inserting new rows into a table. I have tried the following methods, on three
> different columns in the same table;
>
> 1) Default Value (getdate()) on column testInsertedDt
>
> 2) column InsertedDt/getdate() in INSERT statement itself;
>
> INSERT INTO db1..RG_EMPLOYEE
>        (column1, column2, ... InsertedDt)
> SELECT t.column1, t.column2, ... getdate()
>   FROM db2..RG_EMPLOYEE t
>  WHERE rg_id NOT IN (SELECT rg_id FROM db1..RG_EMPLOYEE)
>
> 3) Insert trigger;
>
> create trigger [trggrInsRG_EMPLOYEE]
>     on [dbo].[RG_EMPLOYEE]
>    for insert as
>        update RG_EMPLOYEE
>           set InsertedDtTrigger = getdate()
>          from RG_EMPLOYEE e
>               join inserted i on i.rg_id = e.rg_id
>
> All three methods produce garbage values, such as
>
> 32539-05-20 869:56:11.733
> 1900-01-01 31:04:08.107
> -21424-12-31 3124:26:24.493
>
> What am I doing wrong?
>
> thanks, beth
Author
8 Jul 2005 1:52 PM
beth
"Alejandro Mesa" wrote:

> Can you post the table definition?
>
>
> AMB

Note that the trggrUpdRG_EMPLOYEE trigger works - I don't get garbage.

TABLE [dbo].[RG_EMPLOYEE] (
[rg_id] [varchar] (8)  NOT NULL,
[LastName] [varchar] (50)  NULL,
[FirstName] [varchar] (50)  NULL,
[MiddleName] [varchar] (50)  NULL,
[Nickname] [varchar] (50)  NULL,
[Initials] [varchar] (10)  NULL,
[NameSuffix] [varchar] (10)  NULL,
[Spouse] [varchar] (30)  NULL,
[Address1] [varchar] (75)  NULL,
[Address2] [varchar] (75)  NULL,
[City] [varchar] (75)  NULL,
[State] [varchar] (3)  NULL,
[PostalCode] [varchar] (10)  NULL,
[Country] [varchar] (25)  NULL,
[CellPhone] [varchar] (15)  NULL,
[OfficeLocation] [varchar] (3)  NULL,
[EmployeeSatus] [varchar] (50)  NULL,
[EmployeeStatus] [varchar] (50)  NULL,
[JobTitle] [varchar] (125)  NULL,
[ExemptFlag] [bit] NULL,
[SecretaryARgid] [varchar] (8)  NULL,
[SecretaryBRgid] [varchar] (8)  NULL,
[OfficePhone] [varchar] (50)  NULL,
[OfficeNumber] [varchar] (50)  NULL,
[Email] [varchar] (125)  NULL,
[Department] [varchar] (125)  NULL,
[Notary] [bit] NULL,
[CPR] [bit] NULL,
[HomePhone] [varchar] (15)  NULL,
[HomeFax] [varchar] (15)  NULL,
[LoginID] [varchar] (101)  NULL,
[FullName] [varchar] (75)  NULL,
[ShowAddress] [bit] NULL,
[ShowCellPhone] [bit] NULL,
[ShowHomePhone] [bit] NULL,
[NTDomain] [varchar] (50)  NULL,
[NTUserID] [varchar] (50)  NULL,
[ReportId] [varchar] (8)  NULL,
[InsertedDt] [datetime] NULL,
[LastUpdateDt] [datetime] NULL,
[testInsertedDt] [datetime] NULL,
[InsertedDtTrigger] [datetime] NULL
)

ALTER TABLE [dbo].[RG_EMPLOYEE] ADD
CONSTRAINT [DF_RG_EMPLOYEE_testInsertedDt] DEFAULT (getdate()) FOR
[testInsertedDt]

CREATE INDEX [IX_RG_EMPLOYEE_rg_id] ON [dbo].[RG_EMPLOYEE]([rg_id])

create trigger [trggrUpdRG_EMPLOYEE]
    on [dbo].[RG_EMPLOYEE]
   for update as
       update RG_EMPLOYEE
          set LastUpdateDt = getdate()
         from RG_EMPLOYEE e
              join deleted d on d.rg_id = e.rg_id

create trigger [trggrInsRG_EMPLOYEE]
    on [dbo].[RG_EMPLOYEE]
   for insert as
       update RG_EMPLOYEE
          set InsertedDtTrigger = getdate()
         from RG_EMPLOYEE e
              join inserted i on i.rg_id = e.rg_id
Author
8 Jul 2005 2:05 PM
Aaron Bertrand [SQL Server MVP]
I can't reproduce this problem.  What tool are you using to view these
datetime values?


CREATE TABLE [dbo].[RG_EMPLOYEE] (
[rg_id] [varchar] (8)  NOT NULL,
[LastName] [varchar] (50)  NULL,
[FirstName] [varchar] (50)  NULL,
[MiddleName] [varchar] (50)  NULL,
[Nickname] [varchar] (50)  NULL,
[Initials] [varchar] (10)  NULL,
[NameSuffix] [varchar] (10)  NULL,
[Spouse] [varchar] (30)  NULL,
[Address1] [varchar] (75)  NULL,
[Address2] [varchar] (75)  NULL,
[City] [varchar] (75)  NULL,
[State] [varchar] (3)  NULL,
[PostalCode] [varchar] (10)  NULL,
[Country] [varchar] (25)  NULL,
[CellPhone] [varchar] (15)  NULL,
[OfficeLocation] [varchar] (3)  NULL,
[EmployeeSatus] [varchar] (50)  NULL,
[EmployeeStatus] [varchar] (50)  NULL,
[JobTitle] [varchar] (125)  NULL,
[ExemptFlag] [bit] NULL,
[SecretaryARgid] [varchar] (8)  NULL,
[SecretaryBRgid] [varchar] (8)  NULL,
[OfficePhone] [varchar] (50)  NULL,
[OfficeNumber] [varchar] (50)  NULL,
[Email] [varchar] (125)  NULL,
[Department] [varchar] (125)  NULL,
[Notary] [bit] NULL,
[CPR] [bit] NULL,
[HomePhone] [varchar] (15)  NULL,
[HomeFax] [varchar] (15)  NULL,
[LoginID] [varchar] (101)  NULL,
[FullName] [varchar] (75)  NULL,
[ShowAddress] [bit] NULL,
[ShowCellPhone] [bit] NULL,
[ShowHomePhone] [bit] NULL,
[NTDomain] [varchar] (50)  NULL,
[NTUserID] [varchar] (50)  NULL,
[ReportId] [varchar] (8)  NULL,
[InsertedDt] [datetime] NULL,
[LastUpdateDt] [datetime] NULL,
[testInsertedDt] [datetime] NULL,
[InsertedDtTrigger] [datetime] NULL
)
go
ALTER TABLE [dbo].[RG_EMPLOYEE] ADD
CONSTRAINT [DF_RG_EMPLOYEE_testInsertedDt] DEFAULT (getdate()) FOR
[testInsertedDt]
go
CREATE INDEX [IX_RG_EMPLOYEE_rg_id] ON [dbo].[RG_EMPLOYEE]([rg_id])
go
create trigger [trggrUpdRG_EMPLOYEE]
    on [dbo].[RG_EMPLOYEE]
   for update as
       update RG_EMPLOYEE
          set LastUpdateDt = getdate()
         from RG_EMPLOYEE e
              join deleted d on d.rg_id = e.rg_id
go
create trigger [trggrInsRG_EMPLOYEE]
    on [dbo].[RG_EMPLOYEE]
   for insert as
       update RG_EMPLOYEE
          set InsertedDtTrigger = getdate()
         from RG_EMPLOYEE e
              join inserted i on i.rg_id = e.rg_id
go
set nocount on

insert [dbo].[RG_EMPLOYEE](rg_id) SELECT 'aabbccdd'

waitfor delay '00:00:03'
insert [dbo].[RG_EMPLOYEE](rg_id) SELECT 'eeffgghh'

waitfor delay '00:00:03'
update [dbo].[RG_EMPLOYEE] set rg_id = 'iijjkkll'
where rg_id = 'aabbccdd'
go

select rg_id, testInsertedDt, InsertedDtTrigger, LastUpdateDt
from [dbo].[RG_EMPLOYEE]
go

drop table [dbo].[RG_EMPLOYEE]
GO

Yields:

iijjkkll 2005-07-08 10:04:32.350 2005-07-08 10:04:32.370 2005-07-08
10:04:32.400
eeffgghh 2005-07-08 10:04:35.407 2005-07-08 10:04:35.407 2005-07-08
10:04:35.407
Author
8 Jul 2005 2:21 PM
beth
Aaron,

Did you try using this form of INSERT;

INSERT INTO db1..RG_EMPLOYEE
       (column1, column2, ... InsertedDt)
SELECT t.column1, t.column2, ... getdate()
  FROM db2..RG_EMPLOYEE t
WHERE rg_id NOT IN (SELECT rg_id FROM db1..RG_EMPLOYEE)

As I said in my reply to Brian, my colleague wondered if the above form of
INSERT we are using is causing a problem. To clarify, we are doing it this
way so as not to interfere with active queries against the table, so we
maintain what I will call a "master" copy of the table, and then perform
inserts/updates on the "active" copy from the "master" table. Updates to the
"active" copy are done in the same stored procedure, and the update trigger
works as expected.

Show quote
"Aaron Bertrand [SQL Server MVP]" wrote:

> I can't reproduce this problem.  What tool are you using to view these
> datetime values?
Author
8 Jul 2005 2:52 PM
Aaron Bertrand [SQL Server MVP]
You didn't answer this question:

>> What tool are you using to view these datetime values?

So allow me to elaborate.

In another post, you say that you have valid datetime values when you use
"SQL-Transact"... is this in Query Analyzer?  Is this not where you are
using the non-sensical datetime values?  What query are you using to see
those values, and what tool is being used to display them?
Author
8 Jul 2005 3:12 PM
beth
I see the bad values in Query Analyzer using this query;

  select InsertedDt, LastUpdateDt, testInsertedDt, InsertedDtTrigger
    from RG_EMPLOYEE
   where InsertedDt is not null
      or LastUpdateDt is not null
      or testInsertedDt is not null
      or InsertedDtTrigger is not null
order by LastUpdateDt desc

Column LastUpdateDt contains valid values; here is the first row returned
from the above query;

InsertedDt                  LastUpdateDt             testInsertedDt         
   InsertedDtTrigger
-21424-12-31 869:56:11.733  2005-07-08 04:08:25.207  32539-05-20
869:56:11.733  -21513-01-01 10:48:05.267

Rows are updated and inserted by a stored procedure which is run in a DTS
package we have scheduled to run every morning.

Show quote
"Aaron Bertrand [SQL Server MVP]" wrote:

> You didn't answer this question:
>
> >> What tool are you using to view these datetime values?
>
> So allow me to elaborate.
>
> In another post, you say that you have valid datetime values when you use
> "SQL-Transact"... is this in Query Analyzer?  Is this not where you are
> using the non-sensical datetime values?  What query are you using to see
> those values, and what tool is being used to display them?
Author
8 Jul 2005 1:08 PM
Brian Selzer
This is really strange.  I've never seen this kind of thing happen.  Sounds
like a problem in your system.  Do you get garbage when you issue SELECT
GETDATE() in Query Analyzer?  Have you run DBCC CHECKDB?  You might want to
reindex the table DBCC REINDEX.  Can you try it on a different system?  If
all else fails, you could reinstall SQL Server, but I'd call PSS first.
($275 per incident.)

Show quote
"beth" <b***@discussions.microsoft.com> wrote in message
news:3377CFDC-1CBE-4CEE-A950-ED6951D691D7@microsoft.com...
> I'm having difficulty coming up with a method to store a datetime value
when
> inserting new rows into a table. I have tried the following methods, on
three
> different columns in the same table;
>
> 1) Default Value (getdate()) on column testInsertedDt
>
> 2) column InsertedDt/getdate() in INSERT statement itself;
>
> INSERT INTO db1..RG_EMPLOYEE
>        (column1, column2, ... InsertedDt)
> SELECT t.column1, t.column2, ... getdate()
>   FROM db2..RG_EMPLOYEE t
>  WHERE rg_id NOT IN (SELECT rg_id FROM db1..RG_EMPLOYEE)
>
> 3) Insert trigger;
>
> create trigger [trggrInsRG_EMPLOYEE]
>     on [dbo].[RG_EMPLOYEE]
>    for insert as
>        update RG_EMPLOYEE
>           set InsertedDtTrigger = getdate()
>          from RG_EMPLOYEE e
>               join inserted i on i.rg_id = e.rg_id
>
> All three methods produce garbage values, such as
>
> 32539-05-20 869:56:11.733
> 1900-01-01 31:04:08.107
> -21424-12-31 3124:26:24.493
>
> What am I doing wrong?
>
> thanks, beth
Author
8 Jul 2005 2:05 PM
beth
I've have not tried DBCC CHECKDB.

In SQL-Transact, I executed the following;

insert into RG_EMPLOYEE
(rg_id, InsertedDt)
values ('testID', getdate())

select rg_id, InsertedDt, testInsertedDt, InsertedDtTrigger
from RG_EMPLOYEE
where rg_id = 'testID'

Results;

rg_id  InsertedDt              testInsertedDt          InsertedDtTrigger
testID 2005-07-08 09:57:05.180 2005-07-08 09:57:05.180 2005-07-08 09:57:05.180

All valid datetime values.

My colleague wondered if the problem is with the form of INSERT that we are
using in the stored procedure?

thanks, beth

Show quote
"Brian Selzer" wrote:

> This is really strange.  I've never seen this kind of thing happen.  Sounds
> like a problem in your system.  Do you get garbage when you issue SELECT
> GETDATE() in Query Analyzer?  Have you run DBCC CHECKDB?  You might want to
> reindex the table DBCC REINDEX.  Can you try it on a different system?  If
> all else fails, you could reinstall SQL Server, but I'd call PSS first.
> ($275 per incident.)
>
> "beth" <b***@discussions.microsoft.com> wrote in message
> news:3377CFDC-1CBE-4CEE-A950-ED6951D691D7@microsoft.com...
> > I'm having difficulty coming up with a method to store a datetime value
> when
> > inserting new rows into a table. I have tried the following methods, on
> three
> > different columns in the same table;
> >
> > 1) Default Value (getdate()) on column testInsertedDt
> >
> > 2) column InsertedDt/getdate() in INSERT statement itself;
> >
> > INSERT INTO db1..RG_EMPLOYEE
> >        (column1, column2, ... InsertedDt)
> > SELECT t.column1, t.column2, ... getdate()
> >   FROM db2..RG_EMPLOYEE t
> >  WHERE rg_id NOT IN (SELECT rg_id FROM db1..RG_EMPLOYEE)
> >
> > 3) Insert trigger;
> >
> > create trigger [trggrInsRG_EMPLOYEE]
> >     on [dbo].[RG_EMPLOYEE]
> >    for insert as
> >        update RG_EMPLOYEE
> >           set InsertedDtTrigger = getdate()
> >          from RG_EMPLOYEE e
> >               join inserted i on i.rg_id = e.rg_id
> >
> > All three methods produce garbage values, such as
> >
> > 32539-05-20 869:56:11.733
> > 1900-01-01 31:04:08.107
> > -21424-12-31 3124:26:24.493
> >
> > What am I doing wrong?
> >
> > thanks, beth
>
>
>
Author
9 Jul 2005 12:29 AM
Brian Selzer
It can't be the form of the insert.  The bad date values shouldn't be
allowed to be stored in the database.  I'm not sure, but you've said in one
of the posts that a DTS package loads the data.  Have you tried creating a
new DTS package to load the data from the other system in a separate real
table without executing a stored procedure, so you can verify that the data
is arriving in SQL Server correctly?  First verify that the data is arriving
correctly.  There shouldn't be any way to load garbage into a datetime
column, so there must be a couple of problems.  First, the existence of the
garbage is a problem.  Second, how the garbage failed to cause an error is a
problem, and Third, where the garbage came from is a problem.  I would
attack the third problem first, make sure that the data transformations are
correct.  Then I would try to find out who set what flag that bypassed the
default type checking and constraint checking or what bug in SQL Server
exists that allowed the garbage to be passed in and ultimately stored in the
table.


Show quote
"beth" <b***@discussions.microsoft.com> wrote in message
news:6528C80B-A4EF-4447-8D2E-7D25ABE41EB8@microsoft.com...
> I've have not tried DBCC CHECKDB.
>
> In SQL-Transact, I executed the following;
>
> insert into RG_EMPLOYEE
> (rg_id, InsertedDt)
> values ('testID', getdate())
>
> select rg_id, InsertedDt, testInsertedDt, InsertedDtTrigger
> from RG_EMPLOYEE
> where rg_id = 'testID'
>
> Results;
>
> rg_id  InsertedDt              testInsertedDt          InsertedDtTrigger
> testID 2005-07-08 09:57:05.180 2005-07-08 09:57:05.180 2005-07-08
09:57:05.180
Show quote
>
> All valid datetime values.
>
> My colleague wondered if the problem is with the form of INSERT that we
are
> using in the stored procedure?
>
> thanks, beth
>
> "Brian Selzer" wrote:
>
> > This is really strange.  I've never seen this kind of thing happen.
Sounds
> > like a problem in your system.  Do you get garbage when you issue SELECT
> > GETDATE() in Query Analyzer?  Have you run DBCC CHECKDB?  You might want
to
> > reindex the table DBCC REINDEX.  Can you try it on a different system?
If
> > all else fails, you could reinstall SQL Server, but I'd call PSS first.
> > ($275 per incident.)
> >
> > "beth" <b***@discussions.microsoft.com> wrote in message
> > news:3377CFDC-1CBE-4CEE-A950-ED6951D691D7@microsoft.com...
> > > I'm having difficulty coming up with a method to store a datetime
value
> > when
> > > inserting new rows into a table. I have tried the following methods,
on
> > three
> > > different columns in the same table;
> > >
> > > 1) Default Value (getdate()) on column testInsertedDt
> > >
> > > 2) column InsertedDt/getdate() in INSERT statement itself;
> > >
> > > INSERT INTO db1..RG_EMPLOYEE
> > >        (column1, column2, ... InsertedDt)
> > > SELECT t.column1, t.column2, ... getdate()
> > >   FROM db2..RG_EMPLOYEE t
> > >  WHERE rg_id NOT IN (SELECT rg_id FROM db1..RG_EMPLOYEE)
> > >
> > > 3) Insert trigger;
> > >
> > > create trigger [trggrInsRG_EMPLOYEE]
> > >     on [dbo].[RG_EMPLOYEE]
> > >    for insert as
> > >        update RG_EMPLOYEE
> > >           set InsertedDtTrigger = getdate()
> > >          from RG_EMPLOYEE e
> > >               join inserted i on i.rg_id = e.rg_id
> > >
> > > All three methods produce garbage values, such as
> > >
> > > 32539-05-20 869:56:11.733
> > > 1900-01-01 31:04:08.107
> > > -21424-12-31 3124:26:24.493
> > >
> > > What am I doing wrong?
> > >
> > > thanks, beth
> >
> >
> >
Author
9 Jul 2005 12:42 AM
Steve Kass
Though Beth said the inserts and updates are from stored
procedures run by a DTS process, perhaps it does have
something to do with DTS.  I've seen something similar
with invalid decimal data getting into a table through DTS
because of a bum data provider, though from what Beth
has said so far, I'm not sure where a data provider (for
a non-SQL Server data source) would be involved.

Beth, if there is a DTS process involved here, can you say
anything more about the source of the data and how it is
brought in?  Maybe something is going wrong in a different
place than the obvious one.

SK

Brian Selzer wrote:

Show quote
>It can't be the form of the insert.  The bad date values shouldn't be
>allowed to be stored in the database.  I'm not sure, but you've said in one
>of the posts that a DTS package loads the data.  Have you tried creating a
>new DTS package to load the data from the other system in a separate real
>table without executing a stored procedure, so you can verify that the data
>is arriving in SQL Server correctly?  First verify that the data is arriving
>correctly.  There shouldn't be any way to load garbage into a datetime
>column, so there must be a couple of problems.  First, the existence of the
>garbage is a problem.  Second, how the garbage failed to cause an error is a
>problem, and Third, where the garbage came from is a problem.  I would
>attack the third problem first, make sure that the data transformations are
>correct.  Then I would try to find out who set what flag that bypassed the
>default type checking and constraint checking or what bug in SQL Server
>exists that allowed the garbage to be passed in and ultimately stored in the
>table.
>
>
>"beth" <b***@discussions.microsoft.com> wrote in message
>news:6528C80B-A4EF-4447-8D2E-7D25ABE41EB8@microsoft.com...

>
>>I've have not tried DBCC CHECKDB.
>>
>>In SQL-Transact, I executed the following;
>>
>>insert into RG_EMPLOYEE
>>(rg_id, InsertedDt)
>>values ('testID', getdate())
>>
>>select rg_id, InsertedDt, testInsertedDt, InsertedDtTrigger
>>from RG_EMPLOYEE
>>where rg_id = 'testID'
>>
>>Results;
>>
>>rg_id  InsertedDt              testInsertedDt          InsertedDtTrigger
>>testID 2005-07-08 09:57:05.180 2005-07-08 09:57:05.180 2005-07-08
>>   
>>
>09:57:05.180

>
>>All valid datetime values.
>>
>>My colleague wondered if the problem is with the form of INSERT that we
>>   
>>
>are

>
>>using in the stored procedure?
>>
>>thanks, beth
>>
>>"Brian Selzer" wrote:
>>
>>   
>>
>>>This is really strange.  I've never seen this kind of thing happen.
>>>     
>>>
>Sounds

>
>>>like a problem in your system.  Do you get garbage when you issue SELECT
>>>GETDATE() in Query Analyzer?  Have you run DBCC CHECKDB?  You might want
>>>     
>>>
>to

>
>>>reindex the table DBCC REINDEX.  Can you try it on a different system?
>>>     
>>>
>If

>
>>>all else fails, you could reinstall SQL Server, but I'd call PSS first.
>>>($275 per incident.)
>>>
>>>"beth" <b***@discussions.microsoft.com> wrote in message
>>>news:3377CFDC-1CBE-4CEE-A950-ED6951D691D7@microsoft.com...
>>>     
>>>
>>>>I'm having difficulty coming up with a method to store a datetime
>>>>       
>>>>
>value

>
>>>when
>>>     
>>>
>>>>inserting new rows into a table. I have tried the following methods,
>>>>       
>>>>
>on

>
>>>three
>>>     
>>>
>>>>different columns in the same table;
>>>>
>>>>1) Default Value (getdate()) on column testInsertedDt
>>>>
>>>>2) column InsertedDt/getdate() in INSERT statement itself;
>>>>
>>>>INSERT INTO db1..RG_EMPLOYEE
>>>>       (column1, column2, ... InsertedDt)
>>>>SELECT t.column1, t.column2, ... getdate()
>>>>  FROM db2..RG_EMPLOYEE t
>>>> WHERE rg_id NOT IN (SELECT rg_id FROM db1..RG_EMPLOYEE)
>>>>
>>>>3) Insert trigger;
>>>>
>>>>create trigger [trggrInsRG_EMPLOYEE]
>>>>    on [dbo].[RG_EMPLOYEE]
>>>>   for insert as
>>>>       update RG_EMPLOYEE
>>>>          set InsertedDtTrigger = getdate()
>>>>         from RG_EMPLOYEE e
>>>>              join inserted i on i.rg_id = e.rg_id
>>>>
>>>>All three methods produce garbage values, such as
>>>>
>>>>32539-05-20 869:56:11.733
>>>>1900-01-01 31:04:08.107
>>>>-21424-12-31 3124:26:24.493
>>>>
>>>>What am I doing wrong?
>>>>
>>>>thanks, beth
>>>>       
>>>>
>>>
>>>     
>>>
>
>

>
Author
9 Jul 2005 2:37 PM
beth
Steve and Brian,

The DTS package steps are described, briefly, below. I think, based what
you've both suggested, that I will create a new package that will perform
only steps 1, 2 and 4. The rest I will execute in additional steps in the SQL
job. If DTS is the problem, perhaps that will solve the problem.

I appreciate your help and suggestions. I am not a DBA, just a programmer
trying to figure out why something that ought to be easy is proving to be so
hard.

thanks, beth

DTS Package

1 - Copy SQL Server Objects Task

  Copies tables 3 tables from remote server to local
  server with the following properties selected;

  Create Destination Objects
    Drop destination objects first
    Include all dependent objects
  Copy data
    Replace existing data

2 - Execute SQL Task

  drops/creates a local table

3 - Execute SQL Task

  truncate table RG_EMPLOYEE ("master" table)

4 - Transform Data Task

  Source is a remote server. Data is copied into
  the table created in 2 using an SQL Query.

5 - Execute SQL Task

  exec RG_EMPLOYEE_BUILD (loads the "master" table)

6 - Execute SQL Task (EMNTODS)

  exec RG_EMPLOYEE_UPDATE (insert/update from "master" to "active" table)

7 - Execute SQL Task

  drops tables created in 1 and 2

Show quote
"Steve Kass" wrote:

> Though Beth said the inserts and updates are from stored
> procedures run by a DTS process, perhaps it does have
> something to do with DTS.  I've seen something similar
> with invalid decimal data getting into a table through DTS
> because of a bum data provider, though from what Beth
> has said so far, I'm not sure where a data provider (for
> a non-SQL Server data source) would be involved.
>
> Beth, if there is a DTS process involved here, can you say
> anything more about the source of the data and how it is
> brought in?  Maybe something is going wrong in a different
> place than the obvious one.
>
> SK
>
> Brian Selzer wrote:
>
> >It can't be the form of the insert.  The bad date values shouldn't be
> >allowed to be stored in the database.  I'm not sure, but you've said in one
> >of the posts that a DTS package loads the data.  Have you tried creating a
> >new DTS package to load the data from the other system in a separate real
> >table without executing a stored procedure, so you can verify that the data
> >is arriving in SQL Server correctly?  First verify that the data is arriving
> >correctly.  There shouldn't be any way to load garbage into a datetime
> >column, so there must be a couple of problems.  First, the existence of the
> >garbage is a problem.  Second, how the garbage failed to cause an error is a
> >problem, and Third, where the garbage came from is a problem.  I would
> >attack the third problem first, make sure that the data transformations are
> >correct.  Then I would try to find out who set what flag that bypassed the
> >default type checking and constraint checking or what bug in SQL Server
> >exists that allowed the garbage to be passed in and ultimately stored in the
> >table.
Author
9 Jul 2005 3:31 PM
Brian Selzer
If the data is being transformed incorrectly, you'll see it after step 4.
It sounds like you're on the right track.

Show quote
"beth" <b***@discussions.microsoft.com> wrote in message
news:5FC9AB73-206C-4771-823A-EBD0315CFA41@microsoft.com...
> Steve and Brian,
>
> The DTS package steps are described, briefly, below. I think, based what
> you've both suggested, that I will create a new package that will perform
> only steps 1, 2 and 4. The rest I will execute in additional steps in the
SQL
> job. If DTS is the problem, perhaps that will solve the problem.
>
> I appreciate your help and suggestions. I am not a DBA, just a programmer
> trying to figure out why something that ought to be easy is proving to be
so
> hard.
>
> thanks, beth
>
> DTS Package
>
> 1 - Copy SQL Server Objects Task
>
>   Copies tables 3 tables from remote server to local
>   server with the following properties selected;
>
>   Create Destination Objects
>     Drop destination objects first
>     Include all dependent objects
>   Copy data
>     Replace existing data
>
> 2 - Execute SQL Task
>
>   drops/creates a local table
>
> 3 - Execute SQL Task
>
>   truncate table RG_EMPLOYEE ("master" table)
>
> 4 - Transform Data Task
>
>   Source is a remote server. Data is copied into
>   the table created in 2 using an SQL Query.
>
> 5 - Execute SQL Task
>
>   exec RG_EMPLOYEE_BUILD (loads the "master" table)
>
> 6 - Execute SQL Task (EMNTODS)
>
>   exec RG_EMPLOYEE_UPDATE (insert/update from "master" to "active" table)
>
> 7 - Execute SQL Task
>
>   drops tables created in 1 and 2
>
> "Steve Kass" wrote:
>
> > Though Beth said the inserts and updates are from stored
> > procedures run by a DTS process, perhaps it does have
> > something to do with DTS.  I've seen something similar
> > with invalid decimal data getting into a table through DTS
> > because of a bum data provider, though from what Beth
> > has said so far, I'm not sure where a data provider (for
> > a non-SQL Server data source) would be involved.
> >
> > Beth, if there is a DTS process involved here, can you say
> > anything more about the source of the data and how it is
> > brought in?  Maybe something is going wrong in a different
> > place than the obvious one.
> >
> > SK
> >
> > Brian Selzer wrote:
> >
> > >It can't be the form of the insert.  The bad date values shouldn't be
> > >allowed to be stored in the database.  I'm not sure, but you've said in
one
> > >of the posts that a DTS package loads the data.  Have you tried
creating a
> > >new DTS package to load the data from the other system in a separate
real
> > >table without executing a stored procedure, so you can verify that the
data
> > >is arriving in SQL Server correctly?  First verify that the data is
arriving
> > >correctly.  There shouldn't be any way to load garbage into a datetime
> > >column, so there must be a couple of problems.  First, the existence of
the
> > >garbage is a problem.  Second, how the garbage failed to cause an error
is a
> > >problem, and Third, where the garbage came from is a problem.  I would
> > >attack the third problem first, make sure that the data transformations
are
> > >correct.  Then I would try to find out who set what flag that bypassed
the
> > >default type checking and constraint checking or what bug in SQL Server
> > >exists that allowed the garbage to be passed in and ultimately stored
in the
> > >table.
Author
8 Jul 2005 3:35 PM
beth
Brian,

My colleague ran DBCC CHECKDB - no errors

"Brian Selzer" wrote:

> This is really strange.  I've never seen this kind of thing happen.  Sounds
> like a problem in your system.  Do you get garbage when you issue SELECT
> GETDATE() in Query Analyzer?  Have you run DBCC CHECKDB?  You might want to
> reindex the table DBCC REINDEX.  Can you try it on a different system?  If
> all else fails, you could reinstall SQL Server, but I'd call PSS first.
> ($275 per incident.)

[snip]
Author
8 Jul 2005 1:15 PM
Keith Kratochvil
What is the layout of your table?
From Query Analyzer issue the following commands:

------------
USE DbNameGoesHere
GO
exec sp_help 'TableNameGoesHere'
GO
------------

When you query your table and observe the "bad" data what tool are you using
to pull the data?
Is the column that you are trying to insert into a datetime data type?
What happens when you run this example within Query Analyzer?

------------
create table #test (col datetime)
insert into #test (col) values (getdate())
select * from #test
go
select getdate()
------------

--
Keith


Show quote
"beth" <b***@discussions.microsoft.com> wrote in message
news:3377CFDC-1CBE-4CEE-A950-ED6951D691D7@microsoft.com...
> I'm having difficulty coming up with a method to store a datetime value
> when
> inserting new rows into a table. I have tried the following methods, on
> three
> different columns in the same table;
>
> 1) Default Value (getdate()) on column testInsertedDt
>
> 2) column InsertedDt/getdate() in INSERT statement itself;
>
> INSERT INTO db1..RG_EMPLOYEE
>       (column1, column2, ... InsertedDt)
> SELECT t.column1, t.column2, ... getdate()
>  FROM db2..RG_EMPLOYEE t
> WHERE rg_id NOT IN (SELECT rg_id FROM db1..RG_EMPLOYEE)
>
> 3) Insert trigger;
>
> create trigger [trggrInsRG_EMPLOYEE]
>    on [dbo].[RG_EMPLOYEE]
>   for insert as
>       update RG_EMPLOYEE
>          set InsertedDtTrigger = getdate()
>         from RG_EMPLOYEE e
>              join inserted i on i.rg_id = e.rg_id
>
> All three methods produce garbage values, such as
>
> 32539-05-20 869:56:11.733
> 1900-01-01 31:04:08.107
> -21424-12-31 3124:26:24.493
>
> What am I doing wrong?
>
> thanks, beth
Author
8 Jul 2005 2:27 PM
beth
Keith,

Please see my replies to Alejandro, Aaron and Brian - if these do not answer
your questions, let me know.

thanks, beth

Show quote
"Keith Kratochvil" wrote:

> What is the layout of your table?
> From Query Analyzer issue the following commands:
>
> ------------
> USE DbNameGoesHere
> GO
> exec sp_help 'TableNameGoesHere'
> GO
> ------------
>
> When you query your table and observe the "bad" data what tool are you using
> to pull the data?
> Is the column that you are trying to insert into a datetime data type?
> What happens when you run this example within Query Analyzer?
>
> ------------
> create table #test (col datetime)
> insert into #test (col) values (getdate())
> select * from #test
> go
> select getdate()
> ------------
>
> --
> Keith
>
>
> "beth" <b***@discussions.microsoft.com> wrote in message
> news:3377CFDC-1CBE-4CEE-A950-ED6951D691D7@microsoft.com...
> > I'm having difficulty coming up with a method to store a datetime value
> > when
> > inserting new rows into a table. I have tried the following methods, on
> > three
> > different columns in the same table;

[snip]
Author
8 Jul 2005 7:28 PM
JT
When you eventually discover the root cause of this issue, then post back
with the story for those of us who are eager to know.

Show quote
"beth" <b***@discussions.microsoft.com> wrote in message
news:3377CFDC-1CBE-4CEE-A950-ED6951D691D7@microsoft.com...
> I'm having difficulty coming up with a method to store a datetime value
when
> inserting new rows into a table. I have tried the following methods, on
three
> different columns in the same table;
>
> 1) Default Value (getdate()) on column testInsertedDt
>
> 2) column InsertedDt/getdate() in INSERT statement itself;
>
> INSERT INTO db1..RG_EMPLOYEE
>        (column1, column2, ... InsertedDt)
> SELECT t.column1, t.column2, ... getdate()
>   FROM db2..RG_EMPLOYEE t
>  WHERE rg_id NOT IN (SELECT rg_id FROM db1..RG_EMPLOYEE)
>
> 3) Insert trigger;
>
> create trigger [trggrInsRG_EMPLOYEE]
>     on [dbo].[RG_EMPLOYEE]
>    for insert as
>        update RG_EMPLOYEE
>           set InsertedDtTrigger = getdate()
>          from RG_EMPLOYEE e
>               join inserted i on i.rg_id = e.rg_id
>
> All three methods produce garbage values, such as
>
> 32539-05-20 869:56:11.733
> 1900-01-01 31:04:08.107
> -21424-12-31 3124:26:24.493
>
> What am I doing wrong?
>
> thanks, beth
Author
8 Jul 2005 8:33 PM
beth
I wish I had your confidence; I'm out of ideas.

thanks, beth

Show quote
"JT" wrote:

> When you eventually discover the root cause of this issue, then post back
> with the story for those of us who are eager to know.
Author
8 Jul 2005 10:00 PM
Steve Kass
Beth,

  Can you post the binary contents of some of the bad values, along
with a guess as to what the correct date-time should be?  If these
bad values are bit-shifted or byte-reordered from what they should
be, it might give a useful clue.  Also (now or later, if not convenient),
can you post the values of the [bit] columns in the rows with the
bad data, and also check that they are what was inserted?  Those bit
rows would precede the datetime value on the data page.  The variable
length varchar columns would come afterwards and are less likely
to be an issue.

  My guess is that you are seeing an obscure bug having to do
with bit columns (or possibly code pages), or having to do with
tables with a history of ALTER TABLE ALTER COLUMN or
ALTER TABLE ADD operations.   Something seems to have
gotten messed up with offsets in the INSERT .. VALUES
statement.

There are other things to check, like what DBCC PAGE
shows, but the binary of the datetime columns is a good start.
You can get that by selecting

select ... cast(datetimecolumn as varbinary) as b_datetimecolumn...

  Also, let us know if the database compatibility setting is
less than 80, or if there is or ever was an unusual collation
or code page in place (especially a double-byte character set).

Steve Kass
Drew University

beth wrote:

Show quote
>I wish I had your confidence; I'm out of ideas.
>
>thanks, beth
>
>"JT" wrote:
>

>
>>When you eventually discover the root cause of this issue, then post back
>>with the story for those of us who are eager to know.
>>   
>>
Author
9 Jul 2005 2:19 PM
beth
Steve,

Here are the binary values from the last row updated this morning;

  select top 1 LastUpdateDt, InsertedDt, cast(InsertedDt as varbinary) as
'binInsertedDt',
         testInsertedDt, cast(testInsertedDt as varbinary) as
'bintestInsertedDt',
         InsertedDtTrigger, cast(InsertedDtTrigger as varbinary) as
'binInsertedDtTrigger'
    from RG_EMPLOYEE
   where LastUpdateDt is not null
order by LastUpdateDt desc
LastUpdateDt    InsertedDt    binInsertedDt    testInsertedDt    bintestInsertedDt    InsertedDtTrigger    binInsertedDtTrigger
2005-07-09 04:03:37.610    -21513-01-01
3855:59:27.320    0x0258002AF838C5B4    25047-01-06
07:49:40.890    0x008100810081007B    31686-01-12 08:00:36.280    0x00A6009500840084

The job ran at 4am this morning, and took 3 minutes 37 seconds to run.

Where/how do I get "database compatibility setting" and "code page"?

As for collation, well, that's a bit of a mess on this particular server;

Server: Latin1_General_BIN
tempdb: Latin1_General_BIN
other Databases: SQL_Latin1_General_CP437_BIN

Show quote
"Steve Kass" wrote:

> Beth,
>
>   Can you post the binary contents of some of the bad values, along
> with a guess as to what the correct date-time should be?  If these
> bad values are bit-shifted or byte-reordered from what they should
> be, it might give a useful clue.  Also (now or later, if not convenient),
> can you post the values of the [bit] columns in the rows with the
> bad data, and also check that they are what was inserted?  Those bit
> rows would precede the datetime value on the data page.  The variable
> length varchar columns would come afterwards and are less likely
> to be an issue.
>
>   My guess is that you are seeing an obscure bug having to do
> with bit columns (or possibly code pages), or having to do with
> tables with a history of ALTER TABLE ALTER COLUMN or
> ALTER TABLE ADD operations.   Something seems to have
> gotten messed up with offsets in the INSERT .. VALUES
> statement.
>
> There are other things to check, like what DBCC PAGE
> shows, but the binary of the datetime columns is a good start.
> You can get that by selecting
>
> select ... cast(datetimecolumn as varbinary) as b_datetimecolumn...
>
>   Also, let us know if the database compatibility setting is
> less than 80, or if there is or ever was an unusual collation
> or code page in place (especially a double-byte character set).
>
> Steve Kass
> Drew University
Author
8 Jul 2005 10:02 PM
Steve Kass
Beth,

  Also, I don't see where you've posted the version of SQL Server 2000.
Hopefully you are running sp3, sp3a, or sp4, but can you post the result
of

SELECT @@version

for us?  If it is not up-to-date on service packs, you could be
seeing a long-ago-fixed bug.

SK

beth wrote:

Show quote
>I wish I had your confidence; I'm out of ideas.
>
>thanks, beth
>
>"JT" wrote:
>

>
>>When you eventually discover the root cause of this issue, then post back
>>with the story for those of us who are eager to know.
>>   
>>
Author
9 Jul 2005 1:44 PM
beth
Steve,

We're running;

Microsoft SQL Server  2000 - 8.00.384 (Intel X86)
May 23 2001 00:02:52
Copyright (c) 1988-2000 Microsoft Corporation
Standard Edition on Windows NT 5.0 (Build 2195: Service Pack 4)

Show quote
"Steve Kass" wrote:

> Beth,
>
>   Also, I don't see where you've posted the version of SQL Server 2000.
> Hopefully you are running sp3, sp3a, or sp4, but can you post the result
> of
>
> SELECT @@version
>
> for us?  If it is not up-to-date on service packs, you could be
> seeing a long-ago-fixed bug.
>
> SK
Author
9 Jul 2005 3:22 PM
Anith Sen
It seems like you are on SP1 which is more than years old. As Steve said, it
could a bug which might have been fixed in later SPs or updates. Have you
considered applying the latest service pack on this box?

--
Anith
Author
9 Jul 2005 4:25 PM
Steve Kass
Beth,

  As Anith notes, you are two service packs (and two and one-half years)
behind in SQL Server updates.  Many bug and performance fixes, and
important security updates (such as protection against the "SQL Slammer")
have been provided since then, and my best advice is for you to apply
Service Pack 4, or at least Service Pack 3a along with the security
fix MS03-031, and see if the bug is still present.

See http://support.microsoft.com/kb/821277, the article for the MS03-031
patch, which also links to the "latest service pack for SQL Server" article.

The binary data you provided looks like it belongs elsewhere than in
a date time, because of its regularity (0x008100810081007B,
0x00A6009500840084), so this is looking somewhat more like
a bug to me.

SK

beth wrote:

Show quote
>Steve,
>
>We're running;
>
>Microsoft SQL Server  2000 - 8.00.384 (Intel X86)
> May 23 2001 00:02:52
> Copyright (c) 1988-2000 Microsoft Corporation
> Standard Edition on Windows NT 5.0 (Build 2195: Service Pack 4)
>
>"Steve Kass" wrote:
>

>
>>Beth,
>>
>>  Also, I don't see where you've posted the version of SQL Server 2000.
>>Hopefully you are running sp3, sp3a, or sp4, but can you post the result
>>of
>>
>>SELECT @@version
>>
>>for us?  If it is not up-to-date on service packs, you could be
>>seeing a long-ago-fixed bug.
>>
>>SK
>>   
>>
Author
9 Jul 2005 4:48 PM
beth
Steve, Anith,

I'm confused. It looks like we are using SP4??

Microsoft SQL Server  2000 - 8.00.384 (Intel X86)
May 23 2001 00:02:52
Copyright (c) 1988-2000 Microsoft Corporation
Standard Edition on Windows NT 5.0 (Build 2195: Service Pack 4)

Show quote
"Steve Kass" wrote:

> Beth,
>
>   As Anith notes, you are two service packs (and two and one-half years)
> behind in SQL Server updates.  Many bug and performance fixes, and
> important security updates (such as protection against the "SQL Slammer")
> have been provided since then, and my best advice is for you to apply
> Service Pack 4, or at least Service Pack 3a along with the security
> fix MS03-031, and see if the bug is still present.
>
> See http://support.microsoft.com/kb/821277, the article for the MS03-031
> patch, which also links to the "latest service pack for SQL Server" article.
>
> The binary data you provided looks like it belongs elsewhere than in
> a date time, because of its regularity (0x008100810081007B,
> 0x00A6009500840084), so this is looking somewhat more like
> a bug to me.
>
> SK
>
> beth wrote:
>
> >Steve,
> >
> >We're running;
> >
> >Microsoft SQL Server  2000 - 8.00.384 (Intel X86)
> > May 23 2001 00:02:52
> > Copyright (c) 1988-2000 Microsoft Corporation
> > Standard Edition on Windows NT 5.0 (Build 2195: Service Pack 4)
> >
> >"Steve Kass" wrote:
> >
> > 
> >
> >>Beth,
> >>
> >>  Also, I don't see where you've posted the version of SQL Server 2000.
> >>Hopefully you are running sp3, sp3a, or sp4, but can you post the result
> >>of
> >>
> >>SELECT @@version
> >>
> >>for us?  If it is not up-to-date on service packs, you could be
> >>seeing a long-ago-fixed bug.
> >>
> >>SK
> >>   
> >>
>
Author
9 Jul 2005 5:27 PM
Mike Epprecht (SQL MVP)
Standard Edition on Windows NT 5.0 (Build 2195: Service Pack 4)

= Windows 2000, Standard Edition, Service Pack 4


Microsoft SQL Server  2000 - 8.00.384 (Intel X86)

= SQL Server 2000, Standard Edition, Service Pack 1

8.00.2040 is the SP4 Hotfix for AWE
8.00.2039 is the SP4
8.00.0818 is the SP3/SP3a security rollup (MS03-031)
8.00.0760 is SP3/SP3a
8.00.0534 is SP2
8.00.0384 is SP1
8.00.0194 is SQL 2000 RTM

Regards
--------------------------------
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland

IM: m***@epprecht.net

MVP Program: http://www.microsoft.com/mvp

Blog: http://www.msmvps.com/epprecht/

Show quote
"beth" <b***@discussions.microsoft.com> wrote in message
news:040F8D55-9E26-4772-A931-280F99909A3C@microsoft.com...
> Steve, Anith,
>
> I'm confused. It looks like we are using SP4??
>
> Microsoft SQL Server  2000 - 8.00.384 (Intel X86)
> May 23 2001 00:02:52
> Copyright (c) 1988-2000 Microsoft Corporation
> Standard Edition on Windows NT 5.0 (Build 2195: Service Pack 4)
>
> "Steve Kass" wrote:
>
>> Beth,
>>
>>   As Anith notes, you are two service packs (and two and one-half years)
>> behind in SQL Server updates.  Many bug and performance fixes, and
>> important security updates (such as protection against the "SQL Slammer")
>> have been provided since then, and my best advice is for you to apply
>> Service Pack 4, or at least Service Pack 3a along with the security
>> fix MS03-031, and see if the bug is still present.
>>
>> See http://support.microsoft.com/kb/821277, the article for the MS03-031
>> patch, which also links to the "latest service pack for SQL Server"
>> article.
>>
>> The binary data you provided looks like it belongs elsewhere than in
>> a date time, because of its regularity (0x008100810081007B,
>> 0x00A6009500840084), so this is looking somewhat more like
>> a bug to me.
>>
>> SK
>>
>> beth wrote:
>>
>> >Steve,
>> >
>> >We're running;
>> >
>> >Microsoft SQL Server  2000 - 8.00.384 (Intel X86)
>> > May 23 2001 00:02:52
>> > Copyright (c) 1988-2000 Microsoft Corporation
>> > Standard Edition on Windows NT 5.0 (Build 2195: Service Pack 4)
>> >
>> >"Steve Kass" wrote:
>> >
>> >
>> >
>> >>Beth,
>> >>
>> >>  Also, I don't see where you've posted the version of SQL Server 2000.
>> >>Hopefully you are running sp3, sp3a, or sp4, but can you post the
>> >>result
>> >>of
>> >>
>> >>SELECT @@version
>> >>
>> >>for us?  If it is not up-to-date on service packs, you could be
>> >>seeing a long-ago-fixed bug.
>> >>
>> >>SK
>> >>
>> >>
>>
Author
9 Jul 2005 5:52 PM
beth
oh, duh, I feel stupid. Thank you for the clarification Mike.

regards, beth

Show quote
"Mike Epprecht (SQL MVP)" wrote:

> Standard Edition on Windows NT 5.0 (Build 2195: Service Pack 4)
>
> = Windows 2000, Standard Edition, Service Pack 4
>
>
> Microsoft SQL Server  2000 - 8.00.384 (Intel X86)
>
> = SQL Server 2000, Standard Edition, Service Pack 1
>
> 8.00.2040 is the SP4 Hotfix for AWE
> 8.00.2039 is the SP4
> 8.00.0818 is the SP3/SP3a security rollup (MS03-031)
> 8.00.0760 is SP3/SP3a
> 8.00.0534 is SP2
> 8.00.0384 is SP1
> 8.00.0194 is SQL 2000 RTM
>
> Regards
> --------------------------------
> Mike Epprecht, Microsoft SQL Server MVP
> Zurich, Switzerland
>
> IM: m***@epprecht.net
>
> MVP Program: http://www.microsoft.com/mvp
>
> Blog: http://www.msmvps.com/epprecht/
>
> "beth" <b***@discussions.microsoft.com> wrote in message
> news:040F8D55-9E26-4772-A931-280F99909A3C@microsoft.com...
> > Steve, Anith,
> >
> > I'm confused. It looks like we are using SP4??
> >
> > Microsoft SQL Server  2000 - 8.00.384 (Intel X86)
> > May 23 2001 00:02:52
> > Copyright (c) 1988-2000 Microsoft Corporation
> > Standard Edition on Windows NT 5.0 (Build 2195: Service Pack 4)
> >
> > "Steve Kass" wrote:
> >
> >> Beth,
> >>
> >>   As Anith notes, you are two service packs (and two and one-half years)
> >> behind in SQL Server updates.  Many bug and performance fixes, and
> >> important security updates (such as protection against the "SQL Slammer")
> >> have been provided since then, and my best advice is for you to apply
> >> Service Pack 4, or at least Service Pack 3a along with the security
> >> fix MS03-031, and see if the bug is still present.
> >>
> >> See http://support.microsoft.com/kb/821277, the article for the MS03-031
> >> patch, which also links to the "latest service pack for SQL Server"
> >> article.
> >>
> >> The binary data you provided looks like it belongs elsewhere than in
> >> a date time, because of its regularity (0x008100810081007B,
> >> 0x00A6009500840084), so this is looking somewhat more like
> >> a bug to me.
> >>
> >> SK
> >>
> >> beth wrote:
> >>
> >> >Steve,
> >> >
> >> >We're running;
> >> >
> >> >Microsoft SQL Server  2000 - 8.00.384 (Intel X86)
> >> > May 23 2001 00:02:52
> >> > Copyright (c) 1988-2000 Microsoft Corporation
> >> > Standard Edition on Windows NT 5.0 (Build 2195: Service Pack 4)
> >> >
> >> >"Steve Kass" wrote:
> >> >
> >> >
> >> >
> >> >>Beth,
> >> >>
> >> >>  Also, I don't see where you've posted the version of SQL Server 2000.
> >> >>Hopefully you are running sp3, sp3a, or sp4, but can you post the
> >> >>result
> >> >>of
> >> >>
> >> >>SELECT @@version
> >> >>
> >> >>for us?  If it is not up-to-date on service packs, you could be
> >> >>seeing a long-ago-fixed bug.
> >> >>
> >> >>SK
> >> >>
> >> >>
> >>
>
>
>
Author
12 Jul 2005 4:06 PM
beth
Well, moving execution of the RG_EMPLOYEE_UPDATE procedure from inside the
DTS package to a subsequent step in the SQL job did not fix the problem, so
if there is a bug, I don't think it is specific to DTS.  I added some selects
to the RG_EMPLOYEE_UPDATE procedure to try and help diagnose what is
happening.  There has not been much activity yet, but there were two inserts
yesterday;

rg_id    InsertedDt              LastUpdateDt
-------- ----------------------- -----------------------
50094    2005-07-11 12:04:16.230 (null)
26194    2005-07-11 12:04:16.230 (null)

This morning, two rows were updated;

                rg_id     InsertedDt                  LastUpdateDt          

--------------- --------  --------------------------- -----------------------
Update - before 50060     (null)                      (null)
         after  50060     -23201-12-31 2609:47:20.960 2005-07-12 04:02:23.160
Update - before 28813     (null)                      (null)
         after  28813     28232-11-30 497:06:09.707   2005-07-12 04:02:35.143

(note we did not bother pre-setting InsertedDt or LastUpdateDt when we added
the two columns last week)

Running the job again later this morning updated another row;

                rg_id     InsertedDt                  LastUpdateDt
--------------- --------  --------------------------- -----------------------
Update - before 01907     (null)                      (null)
         after  01907     1900-01-01 00:02:16.943     2005-07-12 10:54:19.207

All this time I had been thinking InsertedDt was getting fouled up during an
INSERT, but it's looking like UPDATE is the source of the problem.

I sent a query to our Help Desk, asking why this SQL server version is so
old; have not received an answer yet.

beth
Author
12 Jul 2005 5:51 PM
Steve Kass
Hi Beth,

  I found one newsgroup report similar to what you describe:

http://groups.google.co.uk/groups?q=%2229335-01-30+993%3A14%3A04.160%22

(The date of that post is a week after the release of Service Pack 2.)

There's a workaround in that thread, which is to reset the
problem columns to their own values in each update statement.  In other
words, wherever you have

update T set
  ...

change it to

update T set
  ...,
  InsertedDt = InsertedDt,
  LastUpdateDt = LastUpdateDt


Of course this shouldn't be required, but maybe it will help until
you find out if an upgrade fixes the problem once and for all.

SK


beth wrote:

Show quote
>Well, moving execution of the RG_EMPLOYEE_UPDATE procedure from inside the
>DTS package to a subsequent step in the SQL job did not fix the problem, so
>if there is a bug, I don't think it is specific to DTS.  I added some selects
>to the RG_EMPLOYEE_UPDATE procedure to try and help diagnose what is
>happening.  There has not been much activity yet, but there were two inserts
>yesterday;
>
>rg_id    InsertedDt              LastUpdateDt
>-------- ----------------------- -----------------------
>50094    2005-07-11 12:04:16.230 (null)
>26194    2005-07-11 12:04:16.230 (null)
>
>This morning, two rows were updated;
>
>                rg_id     InsertedDt                  LastUpdateDt          
>                              
>--------------- --------  --------------------------- -----------------------
>Update - before 50060     (null)                      (null)
>         after  50060     -23201-12-31 2609:47:20.960 2005-07-12 04:02:23.160
>Update - before 28813     (null)                      (null)
>         after  28813     28232-11-30 497:06:09.707   2005-07-12 04:02:35.143
>
>(note we did not bother pre-setting InsertedDt or LastUpdateDt when we added
>the two columns last week)
>
>Running the job again later this morning updated another row;
>
>                rg_id     InsertedDt                  LastUpdateDt
>--------------- --------  --------------------------- -----------------------
>Update - before 01907     (null)                      (null)
>         after  01907     1900-01-01 00:02:16.943     2005-07-12 10:54:19.207
>
>All this time I had been thinking InsertedDt was getting fouled up during an
>INSERT, but it's looking like UPDATE is the source of the problem.
>
>I sent a query to our Help Desk, asking why this SQL server version is so
>old; have not received an answer yet.
>
>beth

>
Author
13 Jul 2005 1:51 PM
beth
thanks for the idea Steve. I've modified the stored procedure, adding;

  InsertedDt = InsertedDt

to the update statement.  I'll post what happens the next time there is an
update.

regards, beth

Show quote
"Steve Kass" wrote:

> Hi Beth,
>
>   I found one newsgroup report similar to what you describe:
>
> http://groups.google.co.uk/groups?q=%2229335-01-30+993%3A14%3A04.160%22
>
> (The date of that post is a week after the release of Service Pack 2.)
>
> There's a workaround in that thread, which is to reset the
> problem columns to their own values in each update statement.  In other
> words, wherever you have
>
> update T set
>   ...
>
> change it to
>
> update T set
>   ...,
>   InsertedDt = InsertedDt,
>   LastUpdateDt = LastUpdateDt
>
>
> Of course this shouldn't be required, but maybe it will help until
> you find out if an upgrade fixes the problem once and for all.
>
> SK
Author
13 Jul 2005 4:56 PM
beth
Good news Steve. InsertedDt = InsertedDt did the trick;

       rg_id    InsertedDt              LastUpdateDt
------ -------- ----------------------- -----------------------
before 26998    2005-07-08 00:00:00.000 2005-07-09 11:17:49.333
after  26998    2005-07-08 00:00:00.000 2005-07-13 12:35:23.667
------ -------- ----------------------- -----------------------
before 50001    (null)                  (null)
after  50001    (null)                  2005-07-13 12:35:23.760
------ -------- ----------------------- -----------------------
before 50053    (null)                  (null)
after  50053    (null)                  2005-07-13 12:35:23.777
------ -------- ----------------------- -----------------------
before 00541    (null)                  (null)
after  00541    (null)                  2005-07-13 12:35:23.810

thank you so much!

....beth

Show quote
"Steve Kass" wrote:

> Hi Beth,
>
>   I found one newsgroup report similar to what you describe:
>
> http://groups.google.co.uk/groups?q=%2229335-01-30+993%3A14%3A04.160%22
>
> (The date of that post is a week after the release of Service Pack 2.)
>
> There's a workaround in that thread, which is to reset the
> problem columns to their own values in each update statement.  In other
> words, wherever you have
>
> update T set
>   ...
>
> change it to
>
> update T set
>   ...,
>   InsertedDt = InsertedDt,
>   LastUpdateDt = LastUpdateDt
>
>
> Of course this shouldn't be required, but maybe it will help until
> you find out if an upgrade fixes the problem once and for all.
>
> SK

AddThis Social Bookmark Button