Drop Table

Support Forum for database administrators and web based access to important newsgroups related to databases
Register on Database Support Forum Edit your profileCalendarFind other Database Support forum membersFrequently Asked QuestionsSearch this forum -> 
For Database admins: Free Database-related Magazines Now Free shipping to Texas


Post New Thread










Thread
Author

update stattement doesn't update my fields...
Hi,

I have an update statement in a storedprocedure whichis:
Update TargetDB..Table
Set
Column1 = coalesce(@Column1 ,Column1 ) ,
Column4 = @Column4 ,
Column2 = coalesce(@Column2 ,Column2 ) ,
Column3 = @Column3
....
where TableKey = @TableKey

the column 1 and 2 are not updated when I provide a new value.
and the column4 is not updated except if I move it after the coalesce
updates!!!

what's appends?
I'm using SQL 2000.

thanks.

Jerome.



Report this thread to moderator Post Follow-up to this message
Old Post
Jéjé
11-29-05 08:23 AM


Re: update stattement doesn't update my fields...
Can you post a repro?

--
Roji. P. Thomas
Net Asset Management
http://toponewithties.blogspot.com


"Jéjé" < willgart@BBBhotmailA
AA.com> wrote in message
news:e7VfxDK9FHA.2816@tk2msftngp13.phx.gbl...
> Hi,
>
> I have an update statement in a storedprocedure whichis:
> Update TargetDB..Table
> Set
> Column1 = coalesce(@Column1 ,Column1 ) ,
> Column4 = @Column4 ,
> Column2 = coalesce(@Column2 ,Column2 ) ,
> Column3 = @Column3
> ....
> where TableKey = @TableKey
>
> the column 1 and 2 are not updated when I provide a new value.
> and the column4 is not updated except if I move it after the coalesce
> updates!!!
>
> what's appends?
> I'm using SQL 2000.
>
> thanks.
>
> Jerome.
>
>



Report this thread to moderator Post Follow-up to this message
Old Post
Roji. P. Thomas
11-29-05 08:23 AM


Re: update stattement doesn't update my fields...
Try to print out the data of the varaibles priot sending the Update
command to check wheter the data is (first and second expression) not
containing NULLS. Something like PRINT 'The Expression is --> ' +
@Column1

HTH, jens Suessmeyer.


Report this thread to moderator Post Follow-up to this message
Old Post
Jens
11-29-05 08:23 AM


Re: update stattement doesn't update my fields...
the print of the variables in the SP is good, I see the new value:

print @column1
print @column2
....

print 'Before update'
Select * from table where id=@id

update.....

print 'After update'
Select * from table where id=@id

the second select statement display that coealesce columns are not updated
with the new value.
if I change coalesce for isnull(@column1, column1) the result is the same.
the print commands display the right values.
when I remove the coalesce function and update directly, the statement works
fine!!!



"Jens" <Jens@sqlserver2005.de> wrote in message
news:1133248760.044990.115790@o13g2000cwo.googlegroups.com...
> Try to print out the data of the varaibles priot sending the Update
> command to check wheter the data is (first and second expression) not
> containing NULLS. Something like PRINT 'The Expression is --> ' +
> @Column1
>
> HTH, jens Suessmeyer.
>



Report this thread to moderator Post Follow-up to this message
Old Post
Jéjé
11-29-05 12:23 PM


Re: update stattement doesn't update my fields...
try replacing it with

Column1 = CASE WHEN @Column1 IS NULL THEN
Column1
ELSE
@Column1
END

it may be longer, but really Coalesce and isnull are rarely needed, and
should only be used if there is no other option.

Andy



Report this thread to moderator Post Follow-up to this message
Old Post
Andy Thompson
11-29-05 04:23 PM


Sponsored Links





Last Thread Next Thread
Post New Thread

MS SQL Server archive

Show a Printable Version Email This Page to Someone! Receive updates to this thread
Microsoft SQL Server
Access database support
PostgreSQL Replication
SQL Server ODBC
FoxPro Support
PostgreSQL pgAdmin
SQL Server Clustering
MySQL ODBC
Web Applications with dBASE
SQL Server CE
MySQL++
Sybase Database Support
MS SQL Full Text Search
PostgreSQL Administration
SQL Anywhere support
DB2 UDB Database
Paradox Database Support
Filemaker Database
Berkley DB
SQL 2000/2000i database
ASE Database
Forum Jump:
All times are GMT. The time now is 03:43 PM.

 
Mobile devices forum | Database support forum archive




Copyrights DropTable.com Database Support Forum 2004 - 2006