可不可以帮我调一下呢?
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
ALTER function makeField(@FldName nvarchar(10),@FldType nvarchar(10),
@FldLen nvarchar(10), @FldDec nvarchar(10))
returns nvarchar(50) as
begin
declare @result as nvarchar(50)
declare @FName nvarchar(10)
declare @FType nvarchar(10)
declare @FLen nvarchar(10)
declare @FDec nvarchar(10)
declare @error nvarchar(20)
set @FName=ltrim(rtrim(isnull(@FldName,'')))
set @FType=ltrim(rtrim(isnull(@FldType,'')))
set @FLen =ltrim(rtrim(isnull(@FldLen,'')))
set @FDec =ltrim(rtrim(isnull(@FldDec,'')))
if @FName='' RAISERROR('字段名为空',16, 1)
if @FType=''
begin
select @error='字段'+@FldName+'类型为空'
RAISERROR (@error,16, 1)
end
if @FType in ('varchar','char','nchar','nvarchar','decimal','numeric') and isnumeric(@FLen)<>1
begin
select @error='字段'+@FName+'没有指定数据的长度'
RAISERROR (@error,16, 1)
if cast(@FLen as int)<=0
begin
select @error='数据'+@FName+'没有长度'
RAISERROR (@error,16, 1)
end
end
if @FType in ('decimal','numeric') and isnumeric(@FLen)<>1
begin
select @error='字段'+@FName+'没有指定小数位数'
RAISERROR (@error,16, 1)
end
if cast(@FDec as int)<=0
begin
select @error='字段'+ @FName+'没有指定小数位数'
RAISERROR (@error,16, 1)
end
set @result='['+isnull(@FName,'')+'] ' + isnull(@FType,'') + ' '
set @result=@result+
case
when isnull(@FType,'') in('varchar','char','nchar','nvarchar') then
'(' + isnull(@FLen,'') + ')'
when @FldType in('decimal','numeric') then
'(' + isnull(@FLen,'') + ',' + isnull(@FDec,'') + ')'
else
''
end
return @result +','+ NCHAR(13)
End
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO