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 2005 Forums
 Transact-SQL (2005)
 Update Two tables

Author  Topic 

timmemac
Starting Member

6 Posts

Posted - 2010-06-10 : 11:12:28
Hi,

I have a problem updating two tables

create table sales(sid int,name varchar(30),code int,descr varchar(30))
create table Add(id int,addr varchar(30))

i have the above tables to be updated.

Input Params = @sname,@scode,@id,@add


corresponding columns
sales.name = @sname
sales.code = @scode
sid,id = @id
addr = @add

if @scode = 5 then update descr
where sid = @id and id = @id

Regards

Jane

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2010-06-10 : 11:16:43
Ok, so what is your problem and what have you tried so far?
Go to Top of Page

janets20
Starting Member

12 Posts

Posted - 2010-06-10 : 11:33:55
update testcust as c,testadd as a
set c.name = @sname ,c.code=@scode IF isnull(@des,'') <> '' begin ,c.descr = @des end
,a.addr=@addr
where c.id = @id and a.id = @id
Go to Top of Page
   

- Advertisement -