alter PRoc testpaPErs as begin declare @tems nvArchar(max),@zidaun nVARchar(max) set @tems=select * From @tems order by @zidaun exec(@tems) end exec testpapers
alter proc testpapers as begin declare @startRow nvarchar(max),@tems nvarchar(max),@zidaun nvarchar(max) set @startRow='temp' set @tems='select * from '; set @zidaun='p_id'; exec(@tems+@startRow+' order by '+@zidaun) end