declare @EmployeeID INT
declare @age varchar(4)
select @age = 'birthdate'
select @EmployeeID = 'BusinessEntityID'
select BusinessEntityID , Birthdate
from AdventureWorks2016.HumanResources.Employee
where BirthDate=@age and BusinessEntityID= @EmployeeID
错误是:
消息245,级别16,状态1,第58行转换时转换失败 数据类型为int的varchar值“ BusinessEntityID”。
答案 0 :(得分:0)
只需输入ID,而不是字符串'BusinessEntityID'
:
select @EmployeeID = 10