复制代码 代码如下:
CREATE FUNCTION Fun_GetReportNews(@type varchar(10))
RETURNS TABLE
AS
RETURN
(
SELECT TPR_ID,TPR_Title,TPR_Date FROM TP_ReportNews WHERE TPR_Type = @type
)
复制代码 代码如下:
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
复制代码 代码如下:
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
新闻热点
疑难解答