日期:2014-05-17 浏览次数:21097 次
--删除测试表A
DROP TABLE a
--删除函数 F_Test_One
DROP FUNCTION F_Test_One
--创建A表
create table a
(
id int identity(1,1) primary key,
[name] varchar(20)
)
INSERT INTO A([name])
SELECT 'a'
union all
select 'b'
GO
--创建函数
create function dbo.F_Test_One(@name varchar(50))
returns @TempTableOne table ([name] VARCHAR(50))
as
begin
IF @name='a'
BEGIN
insert into @TempTableOne SELECT @name
END
ELSE
insert into @TempTableOne SELECT @name+'test!'
RETURN;
end
GO
SELECT
(
SELECT COUNT(1) FROM dbo.F_Test_One(a.[name])
) AS ccount
FROM a
SELECT @@VERSION
/*
Microsoft SQL Server 2005 - 9.00.1399.06 (Intel X86)
Oct 14 2005 00:33:37
Copyright (c) 1988-2005 Microsoft Corporation
Developer Edition on Windows NT 6.1 (Build 7601: Service Pack 1)
*/
if object_id('a','u') is not null
drop table a
if object_id('F_Test_One') is not null
drop function F_Test_One