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.
Author |
Topic |
rh_hosseiny
Starting Member
5 Posts |
Posted - 2011-05-04 : 05:00:21
|
Hi all,i have Ambiguous column name 'IdTypeTakhasos' in bellow queryCREATE PROCEDURE dbo.Doctor_Update ( @IdDoctor int, @Fname nvarchar(20), @Lname nvarchar(20), @ShNezamPezeshki varchar(10), @IdTypeTakhasos int, @UpdateDate nvarchar(10) )as update Tbl_Doctor set Fname=@Fname,Lname=@Lname,ShNezamPezeshki=@ShNezamPezeshki, IdTypeTakhasos=(select IdTypeTakhasos from Tbl_TypeTakhasos t inner join Tbl_Doctor D on t.IdTypeTakhasos=D.IdTypeTakhasos), UpdateDate=@UpdateDate where IdDoctor=@IdDoctorcould anyboby help me?thank u in advance |
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-05-04 : 05:10:08
|
select t.IdTypeTakhasos from Tbl_TypeTakhasos t inner join Tbl_Doctor D on t.IdTypeTakhasos=D.IdTypeTakhasosBut this doesn't make senseI suspect you want something more like thisupdate Tbl_Doctor set Fname=@Fname,Lname=@Lname,ShNezamPezeshki=@ShNezamPezeshki,IdTypeTakhasos=(select t.IdTypeTakhasos from Tbl_TypeTakhasos t where t.IdTypeTakhasos=D.IdTypeTakhasos),UpdateDate=@UpdateDatefrom Tbl_Doctor Dwhere IdDoctor=@IdDoctorbut this still won't be right maybe - I suspect you want some other relation to get the value.==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
lionofdezert
Aged Yak Warrior
885 Posts |
Posted - 2011-05-04 : 07:08:08
|
or you can useUPDATE Tbl_DoctorSET Fname = @Fname, Lname = @Lname, ShNezamPezeshki = @ShNezamPezeshki, UpdateDate = @UpdateDate, IdTypeTakhasos = D.IdTypeTakhasosFROM Tbl_Doctor T INNER JOIN Tbl_TypeTakhasos D ON T.IdTypeTakhasos = D.IdTypeTakhasosWHERE IdDoctor = @IdDoctor But if IdTypeTakhasos is same on both side then WHY we are joining ;) and using in UPDATE--------------------------http://connectsql.blogspot.com/ |
 |
|
wided
Posting Yak Master
218 Posts |
Posted - 2011-05-04 : 07:13:43
|
try thisupdate Tbl_Doctor set Fname=@Fname,Lname=@Lname,ShNezamPezeshki=@ShNezamPezeshki,UpdateDate=@UpdateDate,Tbl_Doctor.IdTypeTakhasos= Tbl_TypeTakhasos.IdTypeTakhasosfrom Tbl_TypeTakhasos where Tbl_TypeTakhasos.IdTypeTakhasos=Tbl_Doctor.IdTypeTakhasosand Tbl_Doctor.IdDoctor=@IdDoctor |
 |
|
wided
Posting Yak Master
218 Posts |
Posted - 2011-05-04 : 07:23:02
|
i think you have not to update Tbl_Doctor.IdTypeTakhasosis is the same in the to tablesupdate Tbl_Doctor set Fname=@Fname,Lname=@Lname,ShNezamPezeshki=@ShNezamPezeshki,UpdateDate=@UpdateDatewhere Tbl_Doctor.IdDoctor=@IdDoctor |
 |
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-05-04 : 07:25:24
|
quote: Originally posted by wided try thisupdate Tbl_Doctor set Fname=@Fname,Lname=@Lname,ShNezamPezeshki=@ShNezamPezeshki,UpdateDate=@UpdateDate,Tbl_Doctor.IdTypeTakhasos= Tbl_TypeTakhasos.IdTypeTakhasosfrom Tbl_TypeTakhasos where Tbl_TypeTakhasos.IdTypeTakhasos=Tbl_Doctor.IdTypeTakhasosand Tbl_Doctor.IdDoctor=@IdDoctor
see my commentthat won't change the value of IdTypeTakhasos as it's the join column.All it will do is change the updateddate.(unless I'm missing a column name difference)==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|
|