解决了它我就觉得你是高手
declare @firstfield varchar(20)
declare @first_pkid numeric(2)
declare @secondfield varchar(20)
declare @second_pkid numeric(2)
declare @totalcount int
/*以下几个变量可以在程序中定义,这里是暂时为它定义量值*/
select @firstfield='zn'
select @first_pkid='3'
select @secondfield='indeg'
select @second_pkid='21'
/*目的是满足@firstfield=convert(nvarchar,@first_pkid)的记录数目@totalcount,
不用exec sp_executesql @str的方法因为还要对记录数@totalcount进行操作*/
select @totalcount=count(distinct pkid) from table_yeikue where @firstfield=convert(nvarchar,@first_pkid) --这里不能通过
select @totalcount
各位,我该怎么改,或者有什么变通的方法?