0

GUID在读取表格时使用此过程创建一个数字。

存储过程正常工作,但只显示两列,idEventId

我需要显示Beyond和的所有dbo.ASFC_App_Timetable其他列。idEventId

其他列是EventTitleEventNote例如。

您能否为我提供解决此问题的代码示例?

 CREATE PROCEDURE SPROCGetAllEventsForStudent
    AS
    BEGIN
        SELECT convert(uniqueidentifier,
               stuff('62799568-6EF2-4C95-84E7-4953A6959C99',1,len(rn),convert(varchar,rn))) id,
               T.EventId
        FROM ( 
          select x.EventId,  ROW_NUMBER() over (order by x.EventId) rn
          FROM dbo.ASFC_App_Timetable as x ) T
    END

目前是显示..我也需要显示其他列:

22799568-6EF2-4C95-84E7-4953A6959C99    AB-TT-E1-2/TU12
32799568-6EF2-4C95-84E7-4953A6959C99    PU-A2-2 -Z/CL12
42799568-6EF2-4C95-84E7-4953A6959C99    PU-A2-2 -Z/CL12
52799568-6EF2-4C95-84E7-4953A6959C99    PU-A2-2 -Z/CL12
62799568-6EF2-4C95-84E7-4953A6959C99    PU-A2-2 -Z/CL12
72799568-6EF2-4C95-84E7-4953A6959C99    PU-A2-2 -Z/CL12
82799568-6EF2-4C95-84E7-4953A6959C99    PU-A2-2 -Z/CL12
4

2 回答 2

2

为什么不能在子查询中添加其他列?

SELECT convert(uniqueidentifier,
       stuff('62799568-6EF2-4C95-84E7-4953A6959C99',1,len(rn),convert(varchar,rn))) id,
       T.EventId, 
       T.EventTitle , 
       T.EventNote
FROM 
    ( 
        select  x.EventId, 
                x.EventTitle , 
                x.EventNote, 
                ROW_NUMBER() over (order by x.EventId) rn
        FROM    dbo.ASFC_App_Timetable as x 
    ) T
于 2013-01-26T09:22:35.110 回答
1

我认为这确实有效。

SELECT EventTitle,
       EventNote,
       convert(uniqueidentifier,
       stuff('62799568-6EF2-4C95-84E7-4953A6959C99',1,len(rn),convert(varchar,rn))) id,
       T.EventId
FROM ( 
         select x.EventId,
              EventTitle,
              EventNote,
              ROW_NUMBER() over (order by x.EventId) rn
         FROM dbo.ASFC_App_Timetable as x
     ) T

为什么不使用NEWID()生成GUID

SELECT NEWID() Id
      EventId,
      EventTitle,
      EventNote
 FROM dbo.ASFC_App_Timetabl
于 2013-01-26T09:22:42.893 回答