我想得到一个带有行号的表值,这给出了语法错误。任何人都可以帮助我吗?

时间:2010-12-07 08:24:30

标签: sql-server-2005

 SELECT @ihotelID= [hotelID] , @ihotelCode = [hotelCode], @iroomTypeCode = [roomTypeCode] ,@dcratePerNight=[ratePerNight],
           @iroomid =[roomid],@inoOfRooms =[noOFRooms],@Datefrom=toDate,@sstatus=status,@specialday='No',
          @dcb2BPercentage=[b2BPercentage],@dcb2CPercentage=[b2CPercentage],@sadditionalBenefits=[imgBenefits]  
FROM (SELECT  ROW_NUMBER() OVER(ORDER BY hotelID) AS 'RowNo' FROM RoomDetails1 t1) 

1 个答案:

答案 0 :(得分:1)

您正在尝试选择子查询未返回的字段(仅返回RowNo)。

尝试例如:

SELECT ROW_NUMBER() OVER(ORDER BY hotelID) AS 'RowNo', [hotelID] ,[hotelCode],........
FROM RoomDetails1 t1

对于演示,我已将字段值的分配删除为变量 - 只是为了明确更改的内容