SQL Server2008中用了MAX()函数后,总是出现错误信息。(列名无效)详情如下!
Declare@totalIntDeclare@numIntDeclare@baseIntDeclare@qzChar(3)Declare@hzChar(3)Declar...
Declare @total IntDeclare @num IntDeclare @base IntDeclare @qz Char(3)Declare @hz Char(3)Declare @Name Char(6)Declare @max IntDeclare @rowno Int--这是SQL语句Set @num=190Set @base=1Set @total=(Select COUNT(*)From T_Biz_Client As A Where A.EnterpriseNO='')Set @qz='C-00'Select (ROW_NUMBER() OVER(ORDER BY T_Biz_Client.ID))As RowNumber From T_Biz_ClientSet @max=MAX(RowNumber)Set @rowno=1While(@base<=@total and @rowno<=@max)BeginSet @num=@num+1Set @hz=CONVERT(Char(3),@num)--Update T_Biz_Client Set T_Biz_Client.EnterpriseNO=@qz+@hz--Select EnterpriseNO From T_Biz_ClientSet @base=@base + 1Set @Name=@qz+@hzSet @rowno=@rowno+1Select EnterpriseNO,@Name As NO,@base As Step,@qz As qz, @hz As hz From T_Biz_ClientEnd--错误信息如下:消息 207,级别 16,状态 1,第 17 行列名 'RowNumber' 无效。
展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询