SQL 2000Óû§×Ô¶¨Ò庯Êý
Ò»¡£SQL Server µÄÈýÖÖ×Ô¶¨Ò庯Êý
“×Ô¶¨Ò庯Êý”ÊÇÎÒÃÇƽ³£µÄ˵·¨£¬¶ø“Óû§¶¨ÒåµÄº¯Êý”ÊÇ SQL Server ÖÐÊéÃæµÄ˵·¨¡£
SQL Server 2000 ÔÊÐíÓû§´´½¨×Ô¶¨Ò庯Êý£¬×Ô¶¨Ò庯Êý¿ÉÒÔÓзµ»ØÖµ¡£
×Ô¶¨Ò庯Êý·ÖΪ£º±êÁ¿Öµº¯Êý»ò±íÖµº¯Êý
Èç¹û RETURNS ×Ó¾äÖ¸¶¨Ò»ÖÖ±êÁ¿Êý¾ÝÀàÐÍ£¬Ôòº¯ÊýΪ±êÁ¿Öµº¯Êý¡£¿ÉÒÔʹÓöàÌõ Transact-SQL Óï¾ä¶¨Òå±êÁ¿Öµº¯Êý¡£
Èç¹û RETURNS ×Ó¾äÖ¸¶¨ TABLE£¬Ôòº¯ÊýΪ±íÖµº¯Êý¡£
±íÖµº¯ÊýÓÖ¿É·ÖΪ£ºÄÚǶ±íÖµº¯Êý£¨ÐÐÄÚº¯Êý£©»ò¶àÓï¾äº¯Êý
Èç¹û RETURNS ×Ó¾äÖ¸¶¨µÄ TABLE ²»¸½´øÁеÄÁÐ±í£¬Ôò¸Ãº¯ÊýΪÄÚǶ±íÖµº¯Êý¡£
Èç¹û RETURNS ×Ó¾äÖ¸¶¨µÄ TABLE ÀàÐÍ´øÓÐÁм°ÆäÊý¾ÝÀàÐÍ£¬Ôò¸Ãº¯ÊýÊǶàÓï¾ä±íÖµº¯Êý¡£
±êÁ¿Öµº¯ÊýʾÀý
CREATE FUNCTION dbo.Foo()
RETURNS int
AS
BEGIN
declare @n int
select @n=3
return @n
END
create function GetSex(@sex int)
returns varchar(2)-- ÓÃnvarchar(1)
as -- nvarchar:²»¹ÜÊÇÒ»¸ö×Ö·û»¹ÊÇÒ»¸öºº×Ö,¶¼´æΪ2¸ö×Ö½Ú
begin -- varchar:ºº×ÖÊÇ2¸ö×Ö½Ú,ÆäËû×Ö·û´æΪ1¸ö×Ö½Ú
declare @ssex varchar(2)-- ÓÃnvarchar(1)
if(@sex=1)
set @ssex='ÄÐ'
else
set @ssex='Å®'
return (@ssex)
end
µ÷Óãº
select id,username,dbo.GetSex(Sex) as sex ,loginnum from t_user
ÄÚǶ±íÖµº¯ÊýʾÀý
CREATE FUNCTION dbo.Foo()
RETURNS TABLE
AS
return select id, title from msgs
ÄÚǶ±íÖµº¯ÊýÖ»ÓÐÒ»¸ö select Óï¾ä¡£
¶àÓï¾ä±íÖµº¯ÊýʾÀý£¨²¿·Ö£©
CREATE FUNCTION FindUsers (@userid int )
RETURNS @FindUser TABLE (id int primary key, UserName varchar(30), RegDateTime DateTime,LoginNum int)
as
begin
insert into @FindUser Select ID, UserName,RegDateTime,LoginNum from T_User Where ID=@userid
return
end
µ÷Óãº
SELECT * from FindUsers(6)
×¢ÒâÆä RETURNS ²¿·Ö¡£
¶àÓï¾äº¯ÊýµÄÖ÷ÌåÖÐÔÊÐíʹÓÃÒÔÏÂÓï¾ä¡£Î´ÔÚÏÂÃæµÄÁбíÖÐÁг
Ïà¹ØÎĵµ£º
±¾ÎĹؼü´Ê£ºSQL 2008 SQL SQL Server SQL Server 2008
¶ÔÓÚ¼´½«ÔÚ2008Äê¡ÖØ·¢²¼µÄSQL Server 2008£¬Î¢ÈíÆÚÍûÊг¡²»½ö½öÊÇ°ÑËü×÷Ϊ¹ØϵÊý¾Ý¿âϵͳÀ´¿´´ý£¬Î¢Èí½«Æ䶨λΪһ¸öÆóÒµÊý¾Ýƽ̨£¬ËäÈ»¹ØϵÊý¾Ý¿âÒýÇæÈÔÈ»ÊÇSQL Server 2008µÄºËÐÄ£¬²»¹ýSQL Server 2008ËùÄÜÌṩµÄ·þÎñ¹ã¶È½«Ô¶³¬¹ý¼òµ¥µÄ¹ØϵÊý¾ ......
¼Æ»®ÓÚ2008ÄêµÚÒ»¼¾¶È·¢²¼µÄSQL Server 2008²»½ö¶ÔÔÓÐÐÔÄܽøÐÐÁ˸Ľø£¬»¹Ìí¼ÓÁËÐí¶àÐÂÌØÐÔ£¬±ÈÈçÐÂÌíÁËÊý¾Ý¼¯³É¹¦ÄÜ£¬¸Ä½øÁË·ÖÎö·þÎñ£¬±¨¸æ·þÎñ£¬ÒÔ¼°Office¼¯³ÉµÈµÈ¡£
¡¡¡¡SQL Server¼¯³É·þÎñ
¡¡¡¡SSIS(SQL Server¼¯³É·þÎñ)ÊÇÒ»¸öǶÈëʽӦÓóÌÐò£¬ÓÃÓÚ¿ª·¢ºÍÖ´ÐÐETL(½âѹËõ¡¢×ª»»ºÍ¼ÓÔØ)°ü¡£SSIS´úÌæÁËSQL 2000µÄDTS¡£Õ ......
ASP.NETÈçºÎÁ¬½ÓAccess»òSQL ServerÊý¾Ý¿â
Ê×ÏÈ¿´Ò»¸öÀý×Ó´úÂëƬ¶Ï:
³ÌÐò´úÂë:
--------------------------------------------------------------------------------
using System.Data;
using System.Data.OleDb;
......
string strConnection="Provider=Microsoft.Jet.OleDb.4.0;";
strConnection+ ......
¹«¸æ£º±¾²©¿ÍΪ΢ÈíÔƼÆËãÖÐÎIJ©¿ÍµÄ¾µÏñ²©¿Í£¬²¢²»±£Ö¤Á´½Ó¿ÉÓÃÐÔ£¬ÎªÁ˱£Ö¤ÔĶÁÌåÑ飬Çë·ÃÎÊhttp://blogs.msdn.com/azchina¡£
October CTPµÄ SQL Azure DatabaseµÄ¹Ø¼ü¹«¸æÊÇʲô£¿
October CTPµÄSQL Azure database¶ÔÓÚPDC2009À´Ëµ»ù±¾¹¦ÄÜÒѾÍê³ÉÁË¡£ October CTP&nbs ......
–1¡¢²éÕÒÔ±¹¤µÄ±àºÅ¡¢ÐÕÃû¡¢²¿ÃźͳöÉúÈÕÆÚ£¬Èç¹û³öÉúÈÕÆÚΪ¿ÕÖµ£¬ÏÔʾÈÕÆÚ²»Ïê,²¢°´²¿ÃÅÅÅÐòÊä³ö,ÈÕÆÚ¸ñʽΪyyyy-mm-dd¡£
select emp_no,emp_name,dept,isnull(convert(char(10),birthday,120),’ÈÕÆÚ²»Ïê’) birthday
from employee
order by dept
–2¡¢²éÕÒÓëÓ÷×ÔÇ¿ÔÚͬһ¸öµ¥Î»µÄÔ±¹¤ÐÕÃû¡¢ ......