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

MS SQL µÝ¹éº¯Êý

 declare @ID varchar(10)
set @ID=9 --¸ù½Úµã
declare @i int --¼¶Êý
declare @t table(ID varchar(10),ParentID varchar(10),Level int)
set @i = 1
insert into @t select @ID,0,0 --µ±Ç°¼¶£¬±¾¼¶£¬Èç¹û²»ÒªµÄ»°¿ÉÒÔ×¢Ê͵ô»òÔÙ¼Ó¸ö²ÎÊýÀ´Ñ¡Ôñ²Ù×÷
insert into @t select ID,ParentID,@i from t_menuprivilege where ParentID = @ID
while @@rowcount<>0
begin
set @i = @i + 1
insert into @t
select
a.ID,a.ParentID,@i
from
t_menuprivilege a,@t b
where
a.ParentID=b.ID and b.Level = @i-1
end
select * from @t



Ïà¹ØÎĵµ£º

Microsoft SQL Server ²éѯ´¦ÀíÆ÷µÄÄÚ²¿»úÖÆÓë½á¹¹

ÕªÒª£º±¾ÎĽéÉÜÁËÔÚ¿Í»§»úÉÏ´¦Àí Microsoft sql server(WINDOWSƽ̨ÉÏÇ¿´óµÄÊý¾Ý¿âƽ̨) ²éѯµÄ·½Ê½£¬¸÷ÖÖ¿Í»§»úÓë sql server(WINDOWSƽ̨ÉÏÇ¿´óµÄÊý¾Ý¿âƽ̨) µÄ½»»¥·½Ê½£¬ÒÔ¼° sql server(WINDOWSƽ̨ÉÏÇ¿´óµÄÊý¾Ý¿âƽ̨) ÔÚ´¦Àí¿Í»§»ú³ÌÐòµÄÇëÇóʱÐèÒªÍê³ÉµÄ¹¤×÷¡£
¼ò½é
¡¡¡¡Microsoft(R) sql server(WINDOWSƽ̨ÉÏÇ¿ ......

EXCELתÊý¾Ýµ½SQL(ÒÑÓбí½á¹¹)

insert into Country123 ([Country_Id], [Region_ID], [Country_EN_Name], [Country], [Country_ALL_ID], [Country_Order_Id]) select [Country_Id], [Region_ID], [Country_EN_Name], [Country], [Country_ALL_ID], [Country_Order_Id] from openrowset( 'Microsoft.Jet.OLEDB.4.0', 'EXCEL 5.0;HDR=YES;IMEX=1; DATABASE= ......

SQL ServerÖÐÁÙʱ±íÓë±í±äÁ¿µÄÇø±ð

ÎÒÃÇÔÚÊý¾Ý¿âÖÐʹÓñíµÄʱºò,¾­³£»áÓöµ½Á½ÖÖʹÓñíµÄ·½·¨,·Ö±ð¾ÍÊÇʹÓÃÁÙʱ±í¼°±í±äÁ¿¡£ÔÚʵ¼ÊʹÓõÄʱºò£¬ÎÒÃÇÈçºÎÁé»îµÄÔÚ´æ´¢¹ý³ÌÖÐÔËÓÃËüÃÇ£¬ËäÈ»ËüÃÇʵÏֵŦÄÜ»ù±¾ÉÏÊÇÒ»ÑùµÄ£¬¿ÉÈçºÎÔÚÒ»¸ö´æ´¢¹ý³ÌÖÐÓÐʱºòȥʹÓÃÁÙʱ±í¶ø²»Ê¹Óñí±äÁ¿£¬ÓÐʱºòȥʹÓñí±äÁ¿¶ø²»Ê¹ÓÃÁÙʱ±íÄØ?
¡¡¡¡ÁÙʱ±í
¡¡¡¡ÁÙʱ±íÓëÓÀ¾Ã±íÏàËÆ£¬ ......

ms sql³£ÓÃÓï¾ä(¸ù¾ÝÐèÒªËæʱ¸üÐÂ)


²éѯÖظ´Öµ£¬ÏÔʾ³ö²»Öظ´µÄ²¿·Ö
select distinct(employeeid) from orders
²éѯÁ½¸ö±íÖ®¼äÏàͬÊý¾Ý
select orders.EmployeeID,Employees.EmployeeID
from orders  INNER JOIN Employees
on Employees.EmployeeID=orders.EmployeeID
ʵÏÖÄ¿µÄ£¬Ò»¸ö±í´æ·ÅÓû§±àºÅºÍÓû§Ãû£¬ÔÚÁíÒ»¸ö±íÖпÉÒÔ¸ù¾ÝÓû§±àº ......

SQL ServerÓëExcelÊý¾Ý»¥µ¼

SQL ServerÓëExcelÊý¾Ý»¥µ¼
´ÓSQL ServerÖе¼Èë/µ¼³ö Excel µÄ»ù±¾·½·¨
/*=================== µ¼Èë/µ¼³ö Excel µÄ»ù±¾·½·¨ ===================*/
´ÓExcelÎļþÖÐ,µ¼ÈëÊý¾Ýµ½SQLÊý¾Ý¿âÖÐ,ºÜ¼òµ¥,Ö±½ÓÓÃÏÂÃæµÄÓï¾ä:
/*========================================================*/
--Èç¹û½ÓÊÜÊý¾Ýµ¼ÈëµÄ±íÒѾ­´æÔÚ
ins ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ