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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 and / or

Author  Topic 

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2007-07-19 : 07:00:12
Hi,
Can you see if this query is correct?
I would like to make sure the select query returns fieldID only if any of the fields inside the bracket (field4, 5, 6, 7) has changed.

--has anything for this record changed?...
--if so, add it into the Differences table...
select
fieldID
from
tblTable
where
fieldID = @fieldID and
fieldID2 = @NB
and
( field3 != @field3 or field4 != @field4
or field5 != @field5
or field6 != @field6
or field7 != @field7
)

pootle_flump

1064 Posts

Posted - 2007-07-20 : 04:00:16
Can any of the parameters or fields be null?
Go to Top of Page

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2007-07-20 : 04:22:01
Yes
Go to Top of Page

pootle_flump

1064 Posts

Posted - 2007-07-20 : 05:45:37
Then it will not work. If field3 is NULL and @field3 is 'something' then field3 != @field3 will return NULL, not true as you would like.
Go to Top of Page
   

- Advertisement -