1
我想使用存儲過程進行選擇。我的代碼:無法綁定多部分標識符「usr.USERID」
ALTER PROCEDURE [dbo].[PUser]
@nom VARCHAR(50) = '',
@prenom VARCHAR(50) = '',
@model VARCHAR(50) = '',
@immatriculation VARCHAR(50) = '',
@marque VARCHAR(50) = '',
@AntenneId int = NULL,
@ProfilId int = NULL,
@puissance int = NULL
AS
BEGIN
SELECT usr.USERID,usr.LOGIN,usr.NAME,usr.SURNAME,usr.DTECRE,usr.DTEUPD,usr.DTEEXP,
usr.DEFAULTURL,usr.Tel,usr.Celular,usr.Email,usr.AntenneId,pf.ProfilId,pf.ProfilLib,ant.Libelle,
car.MarqueVoiture,car.ModelVoiture,car.Puissance,car.Immatriculation
FROM [TCN_USERS] usr,[TUserVoiture] car
inner join dbo.TAdmProfilUser pfu ON pfu.UserId = usr.USERID
inner join dbo.TAdmProfil pf ON pf.ProfilId = pfu.ProfilId
left join dbo.TParamAntennes ant ON usr.AntenneId = ant.AntenneId
WHERE
usr.NAME like '%' + @nom + '%' AND
usr.SURNAME like '%' + @prenom + '%' AND
car.ModelVoiture like '%' + @model + '%' AND
car.Immatriculation like '%' + @immatriculation + '%' AND
car.ModelVoiture like '%' + @model + '%' AND
car.MarqueVoiture like '%' + @marque + '%' AND
car.Puissance = @puissance AND
usr.AntenneId = @AntenneId AND
pf.ProfilId = @ProfilId
END
當我執行在SQL Server中的代碼,我得到這個錯誤:
Msg 4104, Level 16, State 1, Procedure PUser, Line 13
The multi-part identifier "usr.USERID" could not be bound.
Msg 4104, Level 16, State 1, Procedure PUser, Line 13
The multi-part identifier "usr.AntenneId" could not be bound.
請任何人能幫助我解決我的問題。謝謝!
我寧願建議一直堅持顯式連接。混合太混亂了。 – jarlh
@jarlh: - 同意混合JOINS令人困惑。我只是試圖解釋這個問題。希望OP現在可以解決它。 –
你回答Rahul Tripathi –