March 6, 2011 at 12:24 pm
hi.i have a table that contains id,header,content,image fileds. id is primary key. Other fields are string fields(varchar). i keep image's path on the image field. update stored proc of my is like this:
create procedure Upd_Info
@hea varchar(max)=null,
@cont varchar(max)=null,
@im varchar(max)=null
as
begin
update Info set header=@hea,content=@cont,image=@im
end
if i don't give value a field on update proc running,it gives null value that field.(this is normal for this proc)
what i want to do is this: if i don't give value to the filed, that fied will be protect old value. Or else it takes new value.
for example, a row has value of (aa,qqq,img/p.jpg)
if i runs update proc parameters like (ww,cc) values, i want image filed doesn't change. row wil be remain with ww,cc,img/p.jpg values.
i hope, i can express my problem properly. Thanks.
March 6, 2011 at 12:56 pm
update Info set header=ISNULL(@hea,header),content=ISNULL(@cont,content),image=(@im,image)
--Jeff Moden
Change is inevitable... Change for the better is not.
March 6, 2011 at 5:01 pm
don't forget the where clause or all of your records will be the same 😉
For better, quicker answers, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
March 7, 2011 at 6:16 am
Mike01 (3/6/2011)
don't forget the where clause or all of your records will be the same 😉
Thanks for the catch, Mike. Shamefully, I only fixed what I saw. :blush:
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply