create function dbo.F_Get_No
(
@No varchar(100)
)
RETURNS bigint
AS
BEGIN
WHILE PATINDEX('%[^0-9]%',@No)>0
BEGIN
SET @No=STUFF(@No,PATINDEX('%[^0-9]%',@No),1,'') --ɾµôÒ»¸ö·ÇÊý×ÖµÄ×Ö·û£¬Ñ»·½áÊø£¬Ê£ÓàµÄΪÊý×Ö²¿·Ö
END
RETURN CONVERT(bigint,@No)
END
´Ëº¯Êý¿ÉÒÔ·µ»Øij×Ö·û´®ÖеÄÊý×Ö²¿·Ö
PATINDEXº¯Êý ·µ»ØËù²éÄÚÈÝÔÚ×Ö·û´®ÖеÚÒ»´Î³öÏÖµÄË÷Òý
STUFFº¯Êý ɾ³ýÖ¸¶¨³¤¶ÈµÄ×Ö·û²¢ÔÚÖ¸¶¨µÄÆðʼµã²åÈëÁíÒ»×é×Ö·û¡£
select F_Get_No('sdsdf2334sfsd234') ·µ»Ø'2334234'
×¢Ã÷£º´Ë·½·¨¿ÉÒÔ½â¾ö²éѯij×Ö¶ÎÖÐÊý×Ö²¿·ÖΪ¹Ì¶¨ÖµµÄ¼Ç¼£¬×Öĸ²¿·ÖΪ¶¨ÖµÀàËÆ ......
ÁгöTableAÖÐÓеĶøTableBÖÐûÓÐ, ÒÔ¼°BÖÐÓжøAÖÐûÓеļǼ£º
ÆäÖÐÁ½¸ö±íµÄ½á¹¹Ïàͬ£¬Ñ¡ÔñµÄKey¿ÉÒÔ¶à¸ö
Select Key from
( select * from TableA
Union select * from TableB
)
group by Key
having count(Key)=1
ÁгöTableAÖÐÓеĶøTableBÖÐûÓеļǼ£º
Select Key from
( (select * from TableA
Union all select * from TableB)
Union select * from TableB
)a
group by Key
having count(Key)=1 ......
Student(S#,Sname,Sage,Ssex) ѧÉú±í
Course(C#,Cname,T#) ¿Î³Ì±í
SC(S#,C#,score) ³É¼¨±í
Teacher(T#,Tname) ½Ìʦ±í
ÎÊÌ⣺
1¡¢²éѯ“”¿Î³Ì±È“”¿Î³Ì³É¼¨¸ßµÄËùÓÐѧÉúµÄѧºÅ£»
SELECT a.S# from (SELECT s#,score from SC WHERE C#='001') a,
(SELECT s#,score from SC WHERE C#='002') b
WHERE a.score>b.score AND a.s#=b.s#;
2¡¢²éѯƽ¾ù³É¼¨´óÓÚ·ÖµÄͬѧµÄѧºÅºÍƽ¾ù³É¼¨£»
SELECT S#,avg(score)
from sc
GROUP BY S# having avg(score) >60;
3¡¢²éѯËùÓÐͬѧµÄѧºÅ¡¢ÐÕÃû¡¢Ñ¡¿ÎÊý¡¢×ܳɼ¨£»
SELECT Student.S#,Student.Sname,count(SC.C#),sum(score)
from Student left Outer JOIN SC on Student.S#=SC.S#
GROUP BY Student.S#,Sname
4¡¢²éѯÐÕ“ÀÄÀÏʦµÄ¸öÊý£»
SELECT count(distinct(Tname))
from Teacher
WHERE Tname like 'Àî%';
5¡¢²éѯûѧ¹ý“Ҷƽ”ÀÏʦ¿ ......
Êý¾Ý¿â±¸·ÝʵÀý/**
**Êý¾Ý¿â±¸·ÝʵÀý
**Öì¶þ 2004Äê5ÔÂ
**±¸·Ý²ßÂÔ:
**Êý¾Ý¿âÃû:test
**±¸·ÝÎļþµÄ·¾¶e:\backup
**ÿ¸öÐÇÆÚÌìÁ賿1µã×öÒ»´ÎÍêÈ«±¸·Ý,Ϊ±£ÏÕÆð¼û,±¸·Ýµ½Á½¸öͬÑùµÄÍêÈ«±¸·ÝÎļþtest_full_A.bakºÍtest_full_B.bak
**ÿÌì1µã(³ýÁËÐÇÆÚÌì)×öÒ»´Î²îÒ챸·Ý,·Ö±ð±¸·Ýµ½Á½¸öÎļþtest_df_A.bakºÍtest_df_B.bak(²ÉÓø½¼Óµ½Ô±¸·ÝµÄ·½Ê½)
**ÿһ¸öСʱ×öÒ»´ÎÊÂÎñÈÕÖ¾±¸·Ý,·Ö±ð±¸·Ýµ½Á½¸öÎļþtest_log_A.bakºÍtest_log_B.bak(²ÉÓø½¼Óµ½Ô±¸·ÝµÄ·½Ê½)
**/
--µÚÒ» ÍêÈ«±¸·Ý²¿·Ö
--ÐÂÔö×÷Òµ
EXEC sp_add_job @job_name = 'ÍêÈ«±¸·Ý'
--ÐÂÔö×÷Òµ²½Öè1,°ÑÊý¾Ý¿â±¸·Ýµ½test_full_backup_A.bak
EXEC sp_add_jobstep @job_name = 'ÍêÈ«±¸·Ý',
@step_name = 'Setp1',
@subsystem = 'TSQL',
@command = 'BACKUP DATABASE Test TO DISK=''e:\backup\test_full_A.bak'' WITH INIT',
@on_fail_action=3, --ʧ°Üºóתµ½ÏÂÒ»²½
&n ......
»ñÈ¡SQL ServerµÄµ±Ç°Á¬½ÓÊý
[ת]http://www.cnblogs.com/confach/archive/2006/05/31/414156.html
Ê×ÏÈÉùÃ÷:Õâ¸öÎÊÌâÎÒûÓнâ¾ö
µ±ÍøÓÑÎʵ½ÎÒÕâ¸öÎÊÌâʱ,ÎÒÒ²»¹ÒÔΪºÜ¼òµ¥,ÒÔΪSQL ServerÓ¦¸ÃÌṩÁ˶ÔÓ¦µÄϵͳ±äÁ¿Ê²Ã´µÄ.µ«Êǵ½Ä¿Ç°ÎªÖ¹,ÎÒ»¹Ã»Óеõ½Ò»¸ö±È½ÏºÃµÄ½â¾ö·½°¸.¿ÉÄܼܺòµ¥,,Ö»²»¹ýÎÒ²»ÖªµÀ°ÕÁË.Ï£ÍûÈç´Ë..
ÏÂÃæÎÒ˵˵Ïà¹ØµÄ֪ʶ°É.Ï£Íû´ó¼Ò¿ÉÒÔ¸ø³öÒ»¸ö±È½ÏºÃµÄ·½·¨.
ÕâÀïÓм¸¸öÓëÖ®Ïà¹ØµÄ¸ÅÄî.
SQL ServerÌṩÁËһЩº¯Êý·µ»ØÁ¬½ÓÖµ(ÕâÀï¿É²»Êǵ±Ç°Á¬½ÓÊýÓ´!),¸öÈ˾õµÃ,ºÜÈÝÒײúÉúÎó½â.
ϵͳ±äÁ¿
@@CONNECTIONS ·µ»Ø×ÔÉÏ´ÎÆô¶¯ Microsoft® SQL Server™ ÒÔÀ´Á¬½Ó»òÊÔͼÁ¬½ÓµÄ´ÎÊý¡£
@@MAX_CONNECTIONS ·µ»Ø Microsoft® SQL Server™ ÉÏÔÊÐíµÄͬʱÓû§Á¬½ÓµÄ×î´óÊý¡£·µ»ØµÄÊý²»±ØΪµ±Ç°ÅäÖõÄÊýÖµ¡£
ϵͳ´æ´¢¹ý³Ì
SP_WHO
Ìṩ¹ØÓÚµ±Ç° Microsoft® SQL Server™ Óû§ºÍ½ø³ÌµÄÐÅÏ¢¡£¿ÉÒÔɸѡ·µ»ØµÄÐÅÏ¢£¬ÒÔ±ãÖ»·µ»ØÄÇЩ²»ÊÇ¿ÕÏеĽø³Ì¡£
ÁгöËùÓлµÄÓû§:SP_WHO ‘active’
Áгöij¸öÌض¨Óû§µÄÐÅÏ¢:SP_WHO ‘sa’
ϵͳ±í
Sysprocesses
sysprocesses ±íÖб£´æ¹ØÓÚÔËÐÐÔÚ ......
ÔõôÔö¼ÓSQL ServerÁ¬½ÓÊý
1. ¿´²Ù×÷ƽ̨µÄ連½Ó數ÊǶàÉÙ
¿ØÖÆ̨µÄÊÚ權¿´¿´
2. 進GENERAL¿´¿´SQL SERVER USERS CONNECTIONS
Ôö´ó¼´¿É
sp_configure 'number of connection'
go ......