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
 SQL Server Development (2000)
 update query

Author  Topic 

fmardani
Constraint Violating Yak Guru

433 Posts

Posted - 2007-01-16 : 07:01:40
hello,
This is the update query that I have created.
Let's say @UnderlyingIndexID is to be set to null.
I think this query does not allow for such an update.
How can this query be altered to do so?
Thanks

update
tblTest
set
IsActive = isnull(@IsActive, IsActive),
UnderlyingIndexID = isnull(@UnderlyingIndexID, UnderlyingIndexID),
LastUpdatedUser = @ActiveUser,
LastUpdatedDate = getdate()
where
IndexID = @IndexID

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-01-16 : 07:05:40
Seems fine to me.
But we do not know your business rules. Is the column supposed to be set to NULL when parameter is NULL? If so, just remove the ISNULL for that line.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-01-16 : 07:06:43
[code]
update tblTest
set IsActive = isnull(@IsActive, IsActive),
UnderlyingIndexID = isnull(@UnderlyingIndexID, UnderlyingIndexID) @UnderlyingIndexID,
LastUpdatedUser = @ActiveUser,
LastUpdatedDate = getdate()
where
IndexID = @IndexID
[/code]


KH

Go to Top of Page
   

- Advertisement -