select SortID,StatisticsID,StatisticsName,StatisticsUrl,Re from Sys_WFStatistics where StatisticsID in ( select StatisticsReports from Sys_Emplyee where EmpAccount='NEWSIGHT\zhangzhongsheng')

解决方案 »

  1.   

    select SortID
           ,StatisticsID
           ,StatisticsName
           ,StatisticsUrl
           ,Re 
    from Sys_WFStatistics 
    where exists (select 1 
                     from Sys_Emplyee 
                         where EmpAccount='NEWSIGHT\zhangzhongsheng'
                           and charindex(','+Convert(varchar,StatisticsID)+','
                                         ,
                                         ','+StatisticsReports+',')>0
                  )
      

  2.   

    或者
    select SortID,StatisticsID,StatisticsName,StatisticsUrl,Re from Sys_WFStatistics where StatisticsID in ( select cast(StatisticsReports as varchar) from Sys_Emplyee where EmpAccount='NEWSIGHT\zhangzhongsheng')
      

  3.   

    try:select SortID
           ,StatisticsID
           ,StatisticsName
           ,StatisticsUrl
           ,Re 
    from Sys_WFStatistics 
    where exists (select 1 
                     from Sys_Emplyee 
                         where EmpAccount='NEWSIGHT\zhangzhongsheng'
                           and charindex(','''+Convert(varchar,StatisticsID)+''','
                                         ,
                                         ','''+StatisticsReports+''',')>0
                  )
      

  4.   

    create table Sys_WFStatistics
    (
      StatisticsID ID,
      SortID int default 0,
      StatisticsName varchar(20) default '',
      StatisticsUrl varchar(20) default '',
      Re varchar(100) default ''
    )create table Sys_Emplyee
    (
      StatisticsReports  varchar(20),
      EmpAccount varchar(100) 
    )
    insert  Sys_WFStatistics(StatisticsID)
    select 1 union
    select 2 union
    select 3
    insert Sys_Emplyee
    select '''1'',''2'',''3''','NEWSIGHT\zhangzhongsheng'
    go
    --查询
    select SortID
           ,StatisticsID
           ,StatisticsName
           ,StatisticsUrl
           ,Re 
    from Sys_WFStatistics 
    where exists (select 1 
                     from Sys_Emplyee 
                         where EmpAccount='NEWSIGHT\zhangzhongsheng'
                           and charindex(','''+Convert(varchar,StatisticsID)+''','
                                         ,
                                         ','''+StatisticsReports+''',')>0
                  )drop table Sys_WFStatistics,Sys_Emplyee
    /*--结果
    SortID      StatisticsID StatisticsName       StatisticsUrl        Re 
    ----------- ------------ -------------------- -------------------- -------
    0           2                                                      (1 row(s) affected)--*/
      

  5.   

    create table Sys_WFStatistics
    (
      StatisticsID ID,
      SortID int default 0,
      StatisticsName varchar(20) default '',
      StatisticsUrl varchar(20) default '',
      Re varchar(100) default ''
    )create table Sys_Emplyee
    (
      StatisticsReports  varchar(20),
      EmpAccount varchar(100) 
    )
    insert  Sys_WFStatistics(StatisticsID)
    select 1 union
    select 2 union
    select 3
    insert Sys_Emplyee
    select '''1'',''2'',''3''','NEWSIGHT\zhangzhongsheng'
    go
    --查询
    select SortID
           ,StatisticsID
           ,StatisticsName
           ,StatisticsUrl
           ,Re 
    from Sys_WFStatistics 
    where exists (select 1 
                     from Sys_Emplyee 
                         where EmpAccount='NEWSIGHT\zhangzhongsheng'
                           and charindex(','''+Convert(varchar,StatisticsID)+''','
                                         ,
                                         ','+StatisticsReports+',')>0
                  )drop table Sys_WFStatistics,Sys_Emplyee
    /*--结果
    SortID      StatisticsID StatisticsName       StatisticsUrl        Re   
    ----------- ------------ -------------------- -------------------- --------
    0           1                                                      
    0           2                                                      
    0           3                                                      (3 row(s) affected)--*/
      

  6.   

    呵呵,已经搞定了,方法跟 vivianfdlpw()差不多的.