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 |
|
Jirib
Starting Member
5 Posts |
Posted - 2005-06-02 : 15:29:16
|
| use SAVgoCREATE PROCEDURE sp_procedimiento @Sucursal int = 171, @deposito int = 171, @ruta int = 000001 ASselect CodSuc, CodRut,CodDep from tablsucu,tablruta,tabldepowhere codsuc = @Sucursaland coddep = @depositoand codrut = @rutaand tablsucu.codsuc = tabldepo.codsucand tabldepo.coddep = tablruta.coddepGOthis is my main code for a stored procedure and when check the code it comes an error saying Error Code 209 the name of the field CodDep is ambiguous |
|
|
NoNulls
Starting Member
14 Posts |
Posted - 2005-06-02 : 15:32:42
|
| select CodSuc, CodRut,CodDep you need to specifiy which table you want these columns from...i.e.select tablsucu.codsuc, tablruta.cotrut, tabldepo.coddepit is only necessary for the columns that exist in more than one of those tables |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2005-06-02 : 15:35:33
|
| Apparently, CodDep column is in more than one of your tables. So you'll need to let it know which one to use:CREATE PROCEDURE sp_procedimiento @Sucursal int = 171, @deposito int = 171, @ruta int = 000001 ASselect t1.CodSuc, t3.CodRut, t2.CodDep from tablsucu t1inner join tabldepo t2on t1.codsuc = t2.codsucinner jion tablruta t3on t2.coddep = t3.coddepwhere t1.codsuc = @Sucursaland t2.coddep = @depositoand t3.codrut = @rutaGOUse the JOIN syntax for your joins and not the T-SQL way. Also use aliases for your tables so that you don't have to type the table names over and over again.Tara |
 |
|
|
Jirib
Starting Member
5 Posts |
Posted - 2005-06-02 : 15:38:59
|
| Thx guys is working now.... ill be asking more if needed :P |
 |
|
|
|
|
|
|
|