-- select top 1 [ID],[Name,Title from WebSite -- where not [ID] in (select top 11 [ID] from WebSite order by [ID] asc) order by [ID] asc Declare @strSql Varchar(200),@intTopN int Set @intTopN = 11 Set @strSql = 'select top 1 [ID],[Name,Title from WebSite where not [ID] in (select top '+Cast(@intTopN As Varchar(10))+' [ID] from WebSite order by [ID] asc) order by [ID] asc' Print @strSql Exec(@strSql)
-- where not [ID] in (select top 11 [ID] from WebSite order by [ID] asc) order by [ID] asc
Declare @strSql Varchar(200),@intTopN int
Set @intTopN = 11
Set @strSql = 'select top 1 [ID],[Name,Title from WebSite where not [ID] in (select top '+Cast(@intTopN As Varchar(10))+' [ID] from WebSite order by [ID] asc) order by [ID] asc'
Print @strSql
Exec(@strSql)