sqlserver Êý¾Ý¿âËÀËøºó¶à³¤Ê±¼ä½âËø£¿
¸÷λ´óÏÀ£¬sqlserver Êý¾Ý¿âËÀËøºó£¬»á²»»á×Ô¶¯½âËøÄØ£¿¶à³¤Ê±¼äÄÜ×Ô¶¯½âËøÄØ£¿Ð»Ð»£¡
SQL code:
use master
go
create procedure sp_who_lock
as
begin
declare @spid int,@bl int,
@intTransactionCountOnEntry int,
@intRowcount int,
@intCountProperties int,
@intCounter int
create table #tmp_lock_who (
id int identity(1,1),
spid smallint,
bl smallint)
IF @@ERROR<>0 RETURN @@ERROR
insert into #tmp_lock_who(spid,bl) select 0 ,blocked
from (select * from sysprocesses where blocked>0 ) a
where not exists(select * from
(select * from sysprocesses where blocked>0 ) b
where a.blocked=spid)
union select spid,blocked from sysprocesses where blocked>0
IF @@ERROR<>0 RETURN @@ERROR
-- ÕÒµ½ÁÙʱ±íµÄ¼Ç¼Êý
select @intCountProperties = Count(*),@intCounter = 1
from #tmp_lock_who
IF @@ERROR<>0 RETURN @@ERROR
if @intCountProperties=0
select 'ÏÖÔÚûÓÐ×èÈûºÍËÀËøÐÅÏ¢' as message
-- Ñ»·¿ªÊ¼
while @intCounter <= @intCountProperties
begin
-- È¡µÚÒ»Ìõ¼Ç¼
select @spid = spid,@bl = bl
from #tmp_lock_who where Id = @intCounter
begin
if @spid =0
select 'ÒýÆðÊý¾Ý¿âËÀËøµÄÊÇ: '+ CAST(@bl AS VARCHAR(10))
+ '½ø³ÌºÅ,ÆäÖ´ÐеÄSQLÓï·¨ÈçÏÂ'
else
select '½ø³ÌºÅSPID£º'+ CAST(@spid AS VARCHAR(10))+ '±»'
+ '½ø³ÌºÅSPID£º'+ CAST(@bl AS VARCHAR(10)) +'×èÈû,Æäµ±
ǰ½ø³ÌÖ´ÐеÄSQLÓï·¨ÈçÏÂ'DBCC INPUTBUFFER
×Ô¼ºÊÔÏÂ
{{--
Ïà¹ØÎÊ´ð£º
ÎÒµÄÊý¾Ý¿âÊǼòÌåsqlserver2000 ,ÎÒÏëÔÚ·±ÌåaccessÏÂÁ¬½Ó,ͨ¹ýodbcÊÇ¿ÉÒÔÁË,µ«ÔÚaccessϳöÏÖ´ò¿ªµÄ±íÈ«ÖÐ"#ÒÑɾ³ý"
²»ÖªµÀÒªÔõô²Ù×÷²Å¿ÉÒÔÓÃACCESS·±ÌåÁ¬½Ó¼òÌåsqlserver2000.лл!!!
´ó¼Ò¶¼ ......
дÁËÒ»¸öÓÃCÓïÑÔ²Ù×÷sqlserverÊý¾Ý¿âµÄ³ÌÐò£¬ÔÚÎÒ×Ô¼ºµÄ¼ÆËã»úÉÏÔËÐÐûÎÊÌâ¡£µ«µ½Áíһ̨»úÆ÷ÉÏÔËÐÐʱ£¬SQLConnectº¯ÊýÁ¬½ÓÊý¾Ý¿âʧ°Ü£¬×Ðϸ¼ì²éÉèÖö¼Ã»Óз¢ÏÖÎÊÌ⣬µ«¸Ã»úÆ÷µÄ²Ù×÷ϵͳÊÇWindows Server 2003 Enterp ......
SQL code:
CREATE TABLE TUser
(
FName CHAR(8000),
FAge INT,
FSex bit
)
INSERT INTO TUser
SELECT 'ÕÅÈý',18,1
UNION ALL
SELECT 'ÀîËÄ',20,1
UNION ALL
SELECT 'ÍõÎå',32,1
UNION ALL
SE ......
ÇëÎÊһϣ¬ÍâÍøÁ½Ì¨SQLSERVERʵÀýÊý¾Ý´«Ê䣬ÓÐûÓвÉÓÃÊý¾ÝѹËõºÍ¼ÓÃÜ¡£Ñ¹Ëõ±ÈÊǶàÉÙ£¬¼ÓÃÜÊÇʲô¼ÓÃÜËã·¨£¿Ïà¹ØÎĵµÄÄÀï¿ÉÒÔÕÒµ½£¿Ð»Ð»
ÎÒÒ²ÏëÖªµÀ£¡¹Ø×¢´ËÌù£¡
¹Ø×¢¡«¡«
Êý¾Ý¿â´óÅ£¶¼ÄÄÈ¥Á˰¡£¿
......
±íÖÐÊý¾Ý 700ÍòÌõ×óÓÒ£¬29¸ö×ֶΣ¬×Ô¶¯Ôö³¤ÁÐÉèΪÖ÷¼ü£¬ ʹÓÃcount£¨1£© ²éѯ×ÜÌõÊýÐèÒª1·ÖÖÓ£¬
select top 1000 ×Ö¶ÎÃû from ±í order by ʱ¼ä(¸Ã×Ö¶ÎÓÐÖØ¸´ÖµºÍnullÖµ) ÕâÑùµÄÓï¾ä²éѯ¸üÊÇÂýµÃ»ù± ......