Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
anilkumar.forum
Starting Member
5 Posts |
Posted - 2011-03-27 : 04:57:33
|
Hello Everyone,I am facing a very strange problem. I m using a timestamp column in my database to handle concurency. As per my knowledge if you declare any column as timestamp, it would change its value whenever there is any modification to that row. This is fine.But in my table the timestamp value is returning diferent values even for SELECT statement also. So when i am trying to update any row, values are not matching. i mean in my where condition i am checking for timestamp value.Can anyone please tell me why the value for the timestamp column is changing for SELECT statement.Any help on this would be higly appreciated.Thanks in advanceAnil KumarWith Best RegardsAnil Kumar |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2011-03-27 : 05:18:33
|
Are you using a calculated column in the table?Do you have a trigger on the column?Post your actual DDL so we have a chance to reproduce the behaviour. N 56°04'39.26"E 12°55'05.63" |
 |
|
anilkumar.forum
Starting Member
5 Posts |
Posted - 2011-03-27 : 13:31:31
|
Following is the script of that table. and my select statement is SELECT chgTimeStamp from Event_MasterAnd this behaviour is happening intermittently. Sometimes the value remains the same but sometimes for the same query it changes. USE [PSQL24]GO/****** Object: Table [dbo].[Event_Master] Script Date: 03/27/2011 22:54:25 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOSET ANSI_PADDING ONGOCREATE TABLE [dbo].[Event_Master]( [Poll_Id] [int] IDENTITY(1,1) NOT NULL, [EventName] [nvarchar](50) NOT NULL, [EventPath] [nvarchar](max) NOT NULL, [Enable] [bit] NOT NULL, [Retries] [smallint] NULL, [LinkPrevious] [int] NULL, [LinkNext] [int] NULL, [LastResult] [nvarchar](50) NULL, [AfterSuccess] [bit] NULL, [ExecuteEvery] [int] NULL, [ExecuteInterval] [nvarchar](50) NULL, [StartDate] [datetime] NOT NULL, [EndDate] [datetime] NULL, [RepeatForever] [bit] NOT NULL, [Type] [text] NULL, [Parameter] [text] NULL, [Options] [text] NULL, [LastUpdate] [text] NULL, [Description] [text] NULL, [PollAfterSiteCtrler] [bit] NULL, [ExeDate] [datetime] NOT NULL, [Siteid] [nvarchar](max) NULL, [ImportPollData] [bit] NOT NULL, [CardUpdate] [bit] NOT NULL, [PollTankGauge] [bit] NOT NULL, [ChgTimeStamp] [timestamp] NULL, [Reportparameters] [varchar](400) NULL, CONSTRAINT [PK_Event_Master] PRIMARY KEY CLUSTERED ( [Poll_Id] ASC)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]GOSET ANSI_PADDING OFFGOALTER TABLE [dbo].[Event_Master] ADD CONSTRAINT [DF_Event_Master_ImportPollData] DEFAULT ((0)) FOR [ImportPollData]GOALTER TABLE [dbo].[Event_Master] ADD CONSTRAINT [DF_Event_Master_CardUpdate] DEFAULT ((0)) FOR [CardUpdate]GOALTER TABLE [dbo].[Event_Master] ADD CONSTRAINT [DF_Event_Master_PollTankGauge] DEFAULT ((0)) FOR [PollTankGauge]GOquote: Originally posted by Peso Are you using a calculated column in the table?Do you have a trigger on the column?Post your actual DDL so we have a chance to reproduce the behaviour. N 56°04'39.26"E 12°55'05.63"
With Best RegardsAnil Kumar |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2011-03-27 : 13:58:59
|
How are you noticing the changes? N 56°04'39.26"E 12°55'05.63" |
 |
|
anilkumar.forum
Starting Member
5 Posts |
Posted - 2011-03-28 : 00:31:28
|
I ran the above query for 6 times and i got the following results0x00000000000045060x00000000000045080x00000000000045220x000000000000452A0x00000000000045300x000000000000453Aquote: Originally posted by Peso How are you noticing the changes? N 56°04'39.26"E 12°55'05.63"
With Best RegardsAnil Kumar |
 |
|
matty
Posting Yak Master
161 Posts |
Posted - 2011-03-29 : 03:21:39
|
Did you miss the WHERE clause?SELECT chgTimeStamp from Event_Master WHERE .. |
 |
|
|
|
|
|
|