--存储过程名不要和变量一样
CREATE PROCEDURE [dbo].[sproLocation]
(
@Topcount int,
@Location char(50)
)
as
declare @strCounter varchar(10)
set @strCounter=convert(varchar(10),@Topcount)
exec('select top '+'('+@strCounter+')'+' * from tt where [_FontOrImage]=1 and [Location]='+@Location+'Order By _Start_Time Desc')
GO
CREATE PROCEDURE [dbo].[sproLocation]
(
@Topcount int,
@Location char(50)
)
as
declare @strCounter varchar(10)
set @strCounter=convert(varchar(10),@Topcount)
exec('select top '+'('+@strCounter+')'+' * from tt where [_FontOrImage]=1 and [Location]='+@Location+'Order By _Start_Time Desc')
GO
exec('select top '+@strCounter+' * from tt where [_FontOrImage]=1 and [Location]='+@Location+' Order By _Start_Time Desc')
--->
exec('select top '+@strCounter+' * from tt where [_FontOrImage]=1 and [Location]='''+@Location+''' Order By _Start_Time Desc')
(
@Topcount int,
@Location char(50)
)
as
declare @strCounter varchar(10)
set @strCounter=convert(varchar(10),@Topcount)
exec('select top '+@strCounter+' * from tt where [_FontOrImage]=1 and [Location]='''+@Location+''' Order By _Start_Time Desc')
GO