<div class="codebody" id="code40746"> CREATE FUNCTION FUN_GetInfoList(@type varchar(10)) RETURNS @Table TABLE(TPR_ID int,TPR_Title nvarchar(100),TPR_PubDate datetime) AS BEGIN DECLARE @a varchar(10) SELECT @a = xx FROM XX WHERE xx = @type INSERT @Table SELECT XX,XX,XX FROM TableName WHERE XX = @a --表变量里定义的列数和取值列数要一致 RETURN END
<div class="codebody" id="code18719"> CREATE FUNCTION FUN_DataFormat (@strDate datetime) RETURNS varchar(20) AS BEGIN declare @date varchar(20) set @date = DATENAME(YY,@strDate)+'年'+Convert(VARCHAR,MONTH(@strDate))+'月'+Convert(VARCHAR,DAY(@strDate))+'日' return @date END