楼上兄弟:dbcc CHECKALLOC('yourdatabasename',REPAIR_REBUILD)语句不能执行,说明
一下,我的数据库是MS SQL6.5。谁能帮我。
SQL 语句如下:
declare @choose_para int,@assi_id char(5),@begin_date datetime,@end_date datetime
select @choose_para=2 //查询的条件类别
select @assi_id='pa033' //产品代码
select @begin_date='2002/1/2' //开始日期
select @end_date='2002/4/2' //结束日期
SELECT product_code.prod_id,
product_code.prod_name,
product_code.prod_stand,
product_code.prod_unit,
item_name = (
( case
when @choose_para = 0 then '按日期汇总'
when @choose_para = 1 then (select distinct custom_code.cust_name from custom_code where custom_code.cust_id = @assi_id )
when @choose_para = 2 then (select distinct dept_code.dept_name from dept_code where dept_code.dept_id = @assi_id)
when @choose_para = 3 then @assi_id
when @choose_para = 4 then @assi_id
end )
),
in_account = ( select sum(prod_in) from prod_sub
where prod_sub.prod_id = product_code.prod_id and
prod_sub.prod_number in ( select prod_inout.prod_number
from prod_inout
where (prod_inout.prod_date >= @begin_date) and
(prod_inout.prod_date <= @end_date) and
prod_inout.prod_inout in ('1','3') and
( case
when @choose_para = 0 then @assi_id
when @choose_para = 1 then prod_inout.cust_id
when @choose_para = 2 then prod_inout.dept_id
when @choose_para = 3 then prod_inout.inout_staff
when @choose_para = 4 then prod_inout.prod_memo
end ) like '%'+@assi_id+'%'
) ),
in_money = ( select sum(prod_piece) from prod_sub
where prod_sub.prod_id = product_code.prod_id and
prod_sub.prod_number in ( select prod_inout.prod_number
from prod_inout
where (prod_inout.prod_date >= @begin_date) and
(prod_inout.prod_date <= @end_date) and
prod_inout.prod_inout in ('1','3') and
( case
when @choose_para = 0 then @assi_id
when @choose_para = 1 then prod_inout.cust_id
when @choose_para = 2 then prod_inout.dept_id
when @choose_para = 3 then prod_inout.inout_staff
when @choose_para = 4 then prod_inout.prod_memo
end ) like '%'+@assi_id+'%'
) ),
out_account = ( select sum(prod_in) from prod_sub
where prod_sub.prod_id = product_code.prod_id and
prod_sub.prod_number in ( select prod_inout.prod_number
from prod_inout
where (prod_inout.prod_date >= @begin_date) and
(prod_inout.prod_date <= @end_date) and
prod_inout.prod_inout in ('2','4') and
( case
when @choose_para = 0 then @assi_id
when @choose_para = 1 then prod_inout.cust_id
when @choose_para = 2 then prod_inout.dept_id
when @choose_para = 3 then prod_inout.inout_staff
when @choose_para = 4 then prod_inout.prod_memo
end ) like '%'+@assi_id+'%'
) ),
out_imoney = ( select sum(prod_piece) from prod_sub
where prod_sub.prod_id = product_code.prod_id and
prod_sub.prod_number in ( select prod_inout.prod_number
from prod_inout
where (prod_inout.prod_date >= @begin_date) and
(prod_inout.prod_date <= @end_date) and
prod_inout.prod_inout in ('2','4') and
( case
when @choose_para = 0 then @assi_id
when @choose_para = 1 then prod_inout.cust_id
when @choose_para = 2 then prod_inout.dept_id
when @choose_para = 3 then prod_inout.inout_staff
when @choose_para = 4 then prod_inout.prod_memo
end ) like '%'+@assi_id+'%'
) ),
type_name = ( select product_type.prod_tname from product_type
where product_type.prod_type = substring(product_code.prod_id,1,2) ),
type_nameid = ( select product_type.prod_tname from product_type
where product_type.prod_type = substring(product_code.prod_id,2,1) )
FROM product_code
出现错误如下:
Msg 1105, Level 17, State 1
Can't allocate space for object '-435' in database 'tempdb' because the 'system'
segment is full. If you ran out of space in Syslogs, dump the transaction log.
Otherwise, use ALTER DATABASE or sp_extendsegment to increase the size of
the segment.
Msg 1510, Level 17, State 2
Sort failed: Out of space or locks in database 'tempdb'
Msg 1108, Level 21, State 1
Cannot deallocate extent 680, database 2. Object id 0, index id 0, status 0
in extent does not match object id -435, index id 0, status 0 in object being
deallocated. Run DBCC CHECKALLOC.