MSSQL¾µäÓï¾ä
MSSQL¾µäÓï¾ä
1.°´ÐÕÊϱʻÅÅÐò:Select * from TableName Order By CustomerName Collate Chinese_PRC_Stroke_ci_as
2.Êý¾Ý¿â¼ÓÃÜ:select encrypt('ÔʼÃÜÂë')
select pwdencrypt('ÔʼÃÜÂë')
select pwdcompare('ÔʼÃÜÂë','¼ÓÃܺóÃÜÂë') = 1--Ïàͬ£»·ñÔò²»Ïàͬ encrypt('ÔʼÃÜÂë')
select pwdencrypt('ÔʼÃÜÂë')
select pwdcompare('ÔʼÃÜÂë','¼ÓÃܺóÃÜÂë') = 1--Ïàͬ£»·ñÔò²»Ïàͬ
3.È¡»Ø±íÖÐ×Ö¶Î:declare @list varchar(1000),@sql nvarchar(1000)
select @list=@list+','+b.name from sysobjects a,syscolumns b where a.id=b.id and a.name='±íA'
set @sql='select '+right(@list,len(@list)-1)+' from ±íA'
exec (@sql)
4.²é¿´Ó²ÅÌ·ÖÇø:EXEC master..xp_fixeddrives
5.±È½ÏA,B±íÊÇ·ñÏàµÈ:if (select checksum_agg(binary_checksum(*)) from A)
=
(select checksum_agg(binary_checksum(*)) from B)
print 'ÏàµÈ'
else
print '²»ÏàµÈ'
6.ɱµôËùÓеÄʼþ̽²ìÆ÷½ø³Ì:DECLARE hcforeach CURSOR GLOBAL FOR SELECT 'kill '+RTRIM(spid) from master.dbo.sysprocesses
WHERE program_name IN('SQL profiler',N'SQL ʼþ̽²éÆ÷')
EXEC sp_msforeach_worker '?'
7.¼Ç¼ËÑË÷:¿ªÍ·µ½NÌõ¼Ç¼
Select Top N * from ±í
-------------------------------
Nµ½MÌõ¼Ç¼(ÒªÓÐÖ÷Ë÷ÒýID)
Select Top M-N * from ±í Where ID in (Select Top M ID from ±í) Order by ID Desc
----------------------------------
Nµ½½áβ¼Ç¼
Select Top N * from ±í Order by ID Desc
8.ÈçºÎÐÞ¸ÄÊý¾Ý¿âµÄÃû³Æ:sp_renamedb 'old_name', 'new_name'
9£º»ñÈ¡µ±Ç°Êý¾Ý¿âÖеÄËùÓÐÓû§±í
select Name from sysobjects where xtype='u' and status>=0
10£º»ñȡijһ¸ö±íµÄËùÓÐ×Ö¶Î
select name from syscolumns where id=object_id('±íÃû')
11£º²é¿´Óëijһ¸ö±íÏà¹ØµÄÊÓͼ¡¢´æ´¢¹ý³Ì¡¢º¯Êý
select a.* from sysobjects a, syscomments b where a.id = b.id and b.text like '%±íÃû%'
12£º²é¿´µ±Ç°Êý¾Ý¿âÖÐËùÓд洢¹ý³Ì
select name as ´æ´¢¹ý³ÌÃû³Æ from sysobjects where xtype='P'
13£º²éѯÓû§´´½¨µÄËùÓÐÊý¾Ý¿â
select * from master..sysdatabases D where sid not in(select sid from master..syslogins where name='sa')
»òÕß
select dbid, name AS DB_NAME from master..sysdatabases where sid <> 0x01
14£º²éѯijһ¸ö±í
Ïà¹ØÎĵµ£º
SQL Server ÌṩϵͳÊý¾ÝÀàÐͼ¯£¬¶¨ÒåÁË¿ÉÓë SQL Server Ò»ÆðʹÓõÄËùÓÐÊý¾ÝÀàÐÍ¡£ÏÂÃæÁгöϵͳÌṩµÄÊý¾ÝÀàÐͼ¯¡£
¿ÉÒÔ¶¨ÒåÓû§¶¨ÒåµÄÊý¾ÝÀàÐÍ£¬ÆäÊÇϵͳÌṩµÄÊý¾ÝÀàÐ͵ıðÃû¡£ÓйØÓû§¶¨ÒåµÄÊý¾ÝÀàÐ͵ĸü¶àÐÅÏ¢£¬Çë²Î¼û sp_addtype ºÍ´´½¨Óû§¶¨ÒåµÄÊý¾ÝÀàÐÍ¡£
µ±Á½¸ö¾ßÓв»Í¬Êý¾ÝÀàÐÍ¡¢ÅÅÐò¹æÔò¡¢¾«¶È¡¢Ð¡ÊýλÊý»ò³ ......
1
¡¢
MSSQL
Êý¾Ý¿âµÄ¶¨ÆÚ×Ô¶¯±¸·Ý¼Æ»®
ͨ¹ýÆóÒµ¹ÜÀíÆ÷
ÉèÖÃÊý¾Ý¿âµÄ¶¨ÆÚ×Ô¶¯±¸·Ý¼Æ»®¡£
1
¡¢´ò¿ªÆóÒµ¹Ü
ÀíÆ÷£¬Ë«»÷´ò¿ªÄãµÄ·þÎñÆ÷
2
¡¢È»ºóµãÉÏÃæ
²Ëµ¥ÖеŤ¾ß
-->
Ñ¡ÔñÊý¾Ý¿âά»¤¼Æ»®Æ÷
3
¡¢ÏÂÒ»²½Ñ¡ÔñÒª½øÐÐ×Ô¶¯±¸·ÝµÄÊý¾Ý
-->
ÏÂÒ»²½¸üÐÂÊý¾ÝÓÅ»¯ÐÅÏ¢£¬ÕâÀïÒ»°ã²»ÓÃ×öÑ¡Ôñ
-->
ÏÂÒ ......
1.
--½«ºº×Öת»»ÎªÆ´ÒôÊ××Öĸ
CREATE function GetAllPY(@str nvarchar(4000))
returns nvarchar(4000)
--WITH ENCRYPTION
as
begin
declare @intLen int
declare @strRet nvarchar(4000)
declare @temp nvarchar(100)
set @intLen &nb ......
ÏàÐźܶàASP+MSSQLµÄÍøÕ¾¶¼Óб»ÈË×¢Èë¹ýµÄ¾Àú£¬Êý¾Ý¿â±íÖжàÁËһЩ±í£¬ÀàËÆÒÔϵıíD99_tmp,D99_cmd£¬kill_kk¡£
D99_tmp£¨subdirectory,depth,fileÈý¸ö×ֶΣ¬ÀïÃæµÄÊý¾Ý¶¼ÊÇÍøÕ¾ÎļþºÍĿ¼£©
MSSQLÊý¾Ý¿â´æÔÚ¼¸¸öΣÏÕµÄÀ©Õ¹´æ´¢¹ý³Ì£¬Ä¬ÈÏPublic×é¿ÉÖ´ÐÐȨÏÞ£¬SQL×¢ÈëÕß¿ÉÀûÓô˶ÁÈ¡ÎļþĿ¼¼°Óû§×飬²¢¿Éͨ¹ýÏÈдÈëÊý¾ ......
Sql2005ÖÐʹÓÃow_number() partition½øÐзÖ×éʵÑ飬
SQL£º
select * from stu
select id,row_number() over (partition by snm order by id) from stu
½á¹û£º
id snm
----------------
111 111V
111 111W
222 222N
333 3123
444 3123
555 3123
666 3232
777 3232
--·Ö×éºóµÄ½á¹û
id &n ......