我有這個T-SQL過程中的SQL Server 2008:過程調用T-SQL等程序
create procedure rolledback as
begin
set nocount on ;
declare @min int
declare @max int
declare @I INT
IF OBJECT_ID ('TEMDB..#TempTable') IS NOT NULL
begin
drop table #TempTable
end
create table #TempTable
(TempOrderNumber int )
SELECT @min = (SELECT MIN (numero)
from controlanum with (nolock))
SELECT @max = (SELECT Max (numero)
from controlanum with (nolock))
select @I = @min
while @I <= @max
begin
insert into #TempTable
select @I
select @I = @I + 1
end
select tempordernumber from #TempTable
left join controlanum O with (nolock)
on TempOrderNumber = o.numero where o.numero is null
end
這可以完美兼容視圖controlanum,但我需要選擇的日期間隔
我已經寫了另外兩個程序來過濾此期間
create proc maxiN (@emp int, @mes int, @ano int)
as
select Max (numero)
from ctrc
WHERE (EMITENTE = @emp)
AND (MONTH(EMISSAODATA) = @mes) AND (YEAR(EMISSAODATA) = @ano)
create proc Minix (@emp int, @mes int, @ano int)
as
select Min (numero)
from ctrc
WHERE (EMITENTE = @emp)
AND (MONTH(EMISSAODATA) = @mes) AND (YEAR(EMISSAODATA) = @ano)
我插在rolledback
程序,這些程序,但什麼是錯的,現在rolledback2返回0,就像是在p最大值和最小值的rocedures返回任何東西。
create procedure rolledback2 (@emp int, @mes int, @ano int) as
begin
set nocount on ;
declare @min int
declare @max int
declare @I INT
IF OBJECT_ID ('TEMDB..#TempTable') IS NOT NULL
begin
drop table #TempTable
end
create table #TempTable
(TempOrderNumber int )
exec @min = min2 @emp,@mes ,@ano
exec @min = min2 @emp,@mes ,@ano
select @I = @min
while @I <= @max
begin
insert into #TempTable
select @I
select @I = @I + 1
end
select tempordernumber from #TempTable
left join controlanum O with (nolock)
on TempOrderNumber = o.numero where o.numero is null
end
與功能不返回任何
declare @min int
select @min = fmin 504,2,2013
只能這樣
FMIN 504,2,2013
感謝任何方向
亞歷