本文介绍了CREATE FUNCTION失败,因为函数sql server 2008中没有为列1 ....指定列名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我使用的功能生成Uniq没有WardID + SerialNo WardID来自表FamilyHead SerialNo保存在FamilyMember WardID Uniq否应生成 12 12000001,12000002,12000003等等.. 13 13000001,13000002,13000003等... 15 15000001, 15000002,15000003等.... 我使用这种类型逻辑它不能正常工作 你可以帮忙吗.... ALTER function [dbo]。[fnFamilyUniqueID]( @ WardID int )返回 table as 返回 ( SELECT 转换( Varchar ( 15 ), CONVERT ( varchar , @ WardID )+ ' W - ')+ CONVERT ( varchar ( 6 ),dbo.fnFormatSerialNoPostfix ( CONVERT ( int ,SUBSTRING(MAX(SerialNo), 10 , 6 )+ 1)) FROM FamilyMember inner join FamilyHead on FamilyMember.FamilyID = FamilyHead.FamilyID WHERE FamilyHead.WardID = @WardID } 其中dbo.fnFormatSerialNoPostfix是...生成6位数字否 ALTER 功能 [dbo]。[fnFormatSerialNoPostfix] ( @ SerialNo Int ) 返回 varchar ( 10 ) 作为 开始 返回 正确(复制(' 0', 6 )+转换( Varchar ( 10 ), @ SerialNo ) , 6 ) 结束 解决案 只是追加 ASID I am use the function for generate Uniq No WardID+SerialNoWardID Comes from table FamilyHeadSerialNo Save in FamilyMemberWardID Uniq No Should be Generated12 12000001,12000002,12000003 and so on..13 13000001,13000002,13000003 and so on...15 15000001,15000002,15000003 and so on....I use this type logic it's not work properlycan you help please....ALTER function [dbo].[fnFamilyUniqueID](@WardID int) returns tableasRETURN(SELECT CONVERT(Varchar(15),CONVERT(varchar,@WardID) + 'W-') + CONVERT(varchar(6),dbo.fnFormatSerialNoPostfix (CONVERT(int,SUBSTRING(MAX(SerialNo),10,6)+1)) FROM FamilyMember inner join FamilyHead on FamilyMember.FamilyID = FamilyHead.FamilyID WHERE FamilyHead.WardID=@WardID}Where dbo.fnFormatSerialNoPostfix is... generate the 6 digit noALTER Function [dbo].[fnFormatSerialNoPostfix](@SerialNo Int)Returns varchar(10)AsBegin return Right(Replicate('0',6)+Convert(Varchar(10),@SerialNo),6)End 解决方案 just append AS 'ID' 这篇关于CREATE FUNCTION失败,因为函数sql server 2008中没有为列1 ....指定列名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-23 07:10