在链接服务器上运行T-SQL语句

时间:2014-07-02 13:47:11

标签: sql-server

语法错误“接近1”。如果我删除TOP1,我在{@ 1}}附近也会收到错误。建议?

where

1 个答案:

答案 0 :(得分:1)

无需exec

DECLARE @MainHospital varchar(50) = 'Hospital1'

select TOP 1 p.providerid, p.NAME, c.ClientType
from providers p
inner join hcfa_1450_main i on p.ProviderID=i.ProviderID
left outer join ClientTypes c on i.ClientTypeID = c.ClientTypeID
--where c.ClientType is not null
where p.NAME = @MainHospital
order by p.providerid