SQL SERVER¶àÁÐÈ¡×î´ó»òÕß×îСֵ
/*
lvl1 lvl2 lvl3 lvl4 lvl
4 3 4 1
3 2 2 1
2 2 3 4
4 4 3 4
3 1 2 2
Ôõôд´úÂë È¥±È½Ïlvl1¡¢lvl2¡¢lvl3¡¢lvl4 ¶ÔӦÿÐеÄÖµ£¬È¡ÆäÖÐ×îСµÄ£¬½«ÆäÖµÌí¼Óµ½lvlÁÐÀï
ÔËÐнá¹ûÓ¦¸ÃÊÇ
lvl
1
1
2
3
1
*/
--·½·¨(Ò») º¯數·¨
-->Title:Generating test data
-->Author:wufeng4552
-->Date :2009-10-16 09:58:16
if not object_id('Tempdb..#t') is null
drop table #t
Go
Create table #t([lvl1] int,[lvl2] int,[lvl3] int,[lvl4] int,[lvl] int)
Insert #t
select 4,3,4,1,null union all
select 3,2,2,1,null union all
select 2,2,3,4,null union all
select 4,4,3,4,null union all
select 3,1,2,2,null
Go
if object_id('UF_minget')is not null drop function UF_minget
go
create function UF_minget
(@col1 int,@col2 int,@col3 int,@col4 int)
returns int
as
begin
declare @t table(col int)
insert @t select @col1 union all
select @col2 union all
select @col3 union all
select @col4
return(select min(col)from @t)
end
go
update t set [lvl]=dbo.UF_minget([lvl1],[lvl2],[lvl3],[lvl4])
from #t t
select * from #t
/*
lvl1 &
Ïà¹ØÎĵµ£º
Èç¹ûÄã¾³£Óöµ½ÏÂÃæµÄÎÊÌ⣬Äã¾ÍÒª¿¼ÂÇʹÓÃSQL ServerµÄÄ£°åÀ´Ð´¹æ·¶µÄSQLÓï¾äÁË£º
SQL³õѧÕß¡£
¾³£Íü¼Ç³£ÓõÄDML»òÊÇDDL SQL Óï¾ä¡£
ÔÚ¶àÈË¿ª·¢Î¬»¤µÄSQLÖУ¬Ã¿¸öÈ˶¼ÓÐ×Ô¼ºµÄSQLÏ°¹ß£¬Ã»ÓÐÒ»Ì×ͳһµÄ¹æ·¶¡£
ÔÚSQL Server Management StudioÖУ¬ÒѾ¸ø´ó¼ÒÌṩÁ˺ܶೣÓõÄÏÖ³ÉSQL¹æ·¶Ä£°å¡£
SQL Server Management ......
Ò»¡¢xpÏÂÃæ×°sql server 2000
SQL Server 2000 Driver for JDBC: Error establishing socket
ÒÔϵķ½·¨ÄãÿÖÖµÄÈ¥ÊÔÊÔ:
#¼ì²éÒ»ÏÂsql serverµÄconnectionÓÐûÓÐfull.
#Èç¹ûÊÇÈÏÖ¤µÄÎÊÌâ.
¿Éµ½sql enterprice manager->Ö¸¶¨server->ÄÚÈÝ->°²È«ÐÔ.
°ÑÑéÖ¤¸ÄΪ SQL server ¼° windows.
#µãÑ¡ÊôÐÔ¼ì²éÒ ......
OracleϵÁУºSQL
Ò»£¬Ê²Ã´ÊÇSQL£¿
1£¬SQLÈ«³ÆÊÇ“½á¹¹»¯²éѯÓïÑÔ(Structured Query Language)”£¬¹ØϵÊý¾Ý¿â¹ÜÀíϵͳµÄÒ»ÖÖ²éѯÓïÑÔ¡£
2£¬SQLÊǸ߼¶µÄ·Ç¹ý³Ì»¯±à³ÌÓïÑÔ£¬¾ßÓÐÍêÈ«²»Í¬µ×²ã½á¹¹µÄ²»Í¬Êý¾Ý¿âϵͳ¿ÉÒÔʹÓÃÏàͬµÄSQLÓïÑÔ×÷ΪÊý¾ÝÊäÈëÓë¹ÜÀíµÄ½Ó¿Ú¡£
3£¬ÒԼǼ¼¯ºÏ×÷Ϊ²Ù× ......
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 ......