Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

SQLÐÐתÁÐ ÁÐתÐÐ


--ÐÐÁл¥×ª
/****************************************************************************************************************************************************** 
ÒÔѧÉú³É¼¨ÎªÀý×Ó£¬±È½ÏÐÎÏóÒ×¶® ÕûÀíÈË£ºÖйú·ç
(Roy) 
ÈÕÆÚ
:2008.06.06 ******************************************************************************************************************************************************/
 
--1¡¢Ðл¥ÁÐ
--> --> (Roy)
Éú³É測試數據
 
if
 
not
 
object_id
(
'Class'
)
is
 
null
 
drop
 
table
 
Class
 
Go
 
Create
 
table
 
Class(
[Student]
 
nvarchar
(
2
),
[Course]
 
nvarchar
(
2
),
[Score]
 
int
)
Insert
 
Class
 
select
 
N
'ÕÅÈý
'
,N
'ÓïÎÄ
'
,
78
 
union
 
all
 
select
 
N
'ÕÅÈý
'
,N
'Êýѧ
'
,
87
 
union
 
all
 
select
 
N
'ÕÅÈý
'
,N
'Ó¢Óï
'
,
82
 
union
 
all
 
select
 
N
'ÕÅÈý
'
,N
'ÎïÀí
'
,
90
 
union
 
all
 
select
 
N
'ÀîËÄ
'
,N
'ÓïÎÄ
'
,
65
 
union
 
all
 
select
 
N
'ÀîËÄ
'
,N
'Êýѧ
'
,
77
 
union
 
all
 
select
 
N
'ÀîËÄ
'
,N
'Ó¢Óï
'
,
65
 
union
 
all
 
select
 
N
'ÀîËÄ
'
,N
'ÎïÀí
'
,
85
 
Go
--2000·½·¨
:
¶¯Ì¬:
declare
 
@s
 
nvarchar
(
4000
)
Set

@s
=
''
Select

@s
=
@s
+
','
+
quotename
(
[Course]
)
+
'=max(case

when [Course]='
+
quotename
(
[Course]
,
''''
)
+
'
 
then [Score] else 0 end)'
 
from
 
Class
group
 
by
[Course]
exec
(
'select [Student]'
+
@s
+
'
 
from Class group by [Student]'
)
 Éú³É¾²Ì¬:
select
 
[Student]
,
[Êýѧ
]
=


Ïà¹ØÎĵµ£º

SQL ServerÊý¾Ý¿â¹ÜÀí³£ÓÃSQLºÍT SQLÓï¾ä

1.²é¿´Êý¾Ý¿âµÄ°æ±¾
select @@version
2.²é¿´Êý¾Ý¿âËùÔÚ»úÆ÷²Ù×÷ϵͳ²ÎÊý
exec master..xp_msver
3.²é¿´Êý¾Ý¿âÆô¶¯µÄ²ÎÊý
sp_configure
4.²é¿´Êý¾Ý¿âÆô¶¯Ê±¼ä
select convert(varchar(30),login_time,120) from master..sysprocesses where spid=1
²é¿´Êý¾Ý¿â·þÎñÆ÷ÃûºÍʵÀýÃû
print ''Server Name...... ......

SQL Server³£ÓÃϵͳ´æ´¢¹ý³Ì

--ÁгöSQL ServerʵÀýÖеÄÊý¾Ý¿â
sp_databases
--·µ»ØSQL Server¡¢Êý¾Ý¿âÍø¹Ø»ò»ù´¡Êý¾ÝÔ´µÄÌØÐÔÃûºÍÆ¥ÅäÖµµÄÁбí
sp_server_info
--·µ»Øµ±Ç°»·¾³ÖеĴ洢¹ý³ÌÁбí
sp_stored_procedures
--·µ»Øµ±Ç°»·¾³Ï¿ɲéѯµÄ¶ÔÏóµÄÁÐ±í£¨ÈκοɳöÏÖÔÚ from ×Ó¾äÖеĶÔÏó£©
sp_tables
select * from sysobjects
---Ìí¼Ó»ò¸ü¸Ä ......

oracle10g SQL ¸ú×Ù

1.¼¤»îSQL¸ú×Ù
   ´Óoracle10gÒÔºóÌṩÁËÐµķ½·¨¼¤»îSQLµÄ¸ú×Ù£¬¼´ÊÇʹÓÃdbms_monitor°üÀ´¿ªÆô»ò¹Ø±ÕSQL¸ú×Ù¡£
   ֮ǰ¾É·½·¨ÊÇʹÓà alter session set events ..  »òÕßʹÓÃdbms_system.set_ev·½Ê½
   ʹÓÃdbms_monitor°ü¿ÉÒÔÔڻỰ£¬¿Í»§¶Ë£¬×é¼þÒÔ¼°Êý¾Ý¿âËĸö²ã¼¶¿ªÆôSQLµÄ¸ú×Ù¡ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ