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

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   &


Ïà¹ØÎĵµ£º

SQL2005ºÍ(Excel |access)Ö®¼äµÄÊý¾Ýµ¼Èëµ¼³ö


Sql´úÂë
--²ÉÓÃSQLÓï¾äʵÏÖsql2005ºÍExcel Êý¾ÝÖ®¼äµÄÊý¾Ýµ¼Èëµ¼³ö£¬ÔÚÍøÉÏÕÒÀ´Ò»--Ï£¬ÊµÏÖ·½·¨ÊÇÕâÑùµÄ£º    
  
  
--Excel---->SQL2005  µ¼È룺    
  
  
select * into useinfo from O ......

SQL ServerÐÔÄܵ÷ÓÅÈëÃÅ£¨Í¼Îİ棩

µÚÒ»²½£¬ÔÚÒµÎñ¸ß·åÆÚץȡÑù±¾Êý¾Ý£¨2¸öСʱ×óÓÒ£©¡£²ÉÓõŤ¾ßÊÇsqlserver×Ô´øµÄprofiler£¬Ò²½Ðʼþ̽²éÆ÷£¬ÈçÏÂͼ£º

½øÈëºó£¬µã»÷×î×óÃæµÄ°´Å¥£¬½¨Á¢Ò»¸öеĸú×Ù£º

µÇ¼ÐèÒªÓÃDBOȨÏÞ£¬ËùÒÔ¿ÉÒÔÓÃsaµÇ¼£¬Ò²¿ÉÒÔÓÃwindows¼¯³ÉÑéÖ¤·½Ê½£¨Èç¹ûµ±Ç°µÇ¼µÄ¾ÍÊÇsqlserverµÄ»°£©

н¨¸ú×Ù£¬Ò»¹²ÓÐ4¸ötabÒ³½øÐÐÅ ......

SQL Server×Ö·û´®·Ö¸î

 Ò»¡¢°´Ö¸¶¨·ûºÅ·Ö¸î×Ö·û´®£¬·µ»Ø·Ö¸îºóµÄÔªËØ¸öÊý£¬·½·¨ºÜ¼òµ¥£¬¾ÍÊÇ¿´×Ö·û´®ÖдæÔÚ¶àÉÙ¸ö·Ö¸ô·ûºÅ£¬È»ºóÔÙ¼ÓÒ»£¬¾ÍÊÇÒªÇóµÄ½á¹û¡£
CREATE function Get_StrArrayLength
(
  @str varchar(1024),  --Òª·Ö¸îµÄ×Ö·û´®
  @split varchar(10)  --·Ö¸ô·û ......

50Ìõ³£ÓÃsqlÓï¾ä£¨ÒÔѧÉú±íΪÀý£©


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  ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ