--sql循环
declare @i int;
set @i=1;
while (@i<=5)
begin
print @i;
set @i=@i+1;
end
--调用函数
select top 10 dbo.TestFunction(id) as returnvalue from userinfo
--调用自带函数select convert(char(8),getdate(),101)
--函数
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
alter FUNCTION [TestFunction]
(
@a int
)
RETURNS nvarchar(100)
AS
BEGIN
if(@a=2)
begin
return 1
end
return 2
END
GO
未完待续