declare @nRow int
set @nRow = 4
select top @nRow * from MD_CountyUnit where ID_County = '410102' and ID_Dept = 'AH1701'

解决方案 »

  1.   

    declare @nRow int
    set @nRow = 4
    select top (@nRow) * from MD_CountyUnit where ID_County = '410102' and ID_Dept = 'AH1701'
      

  2.   

    lare @nRow int
    set @nRow = 4
    exec('select top '+@nRow+' * from MD_CountyUnit where ID_County = ''410102'' and ID_Dept = ''AH1701''')
      

  3.   


    declare @nRow int
    set rowcount @nRow 
    select * from MD_CountyUnit where ID_County = '410102' and ID_Dept = 'AH1701'
    set rowcount 0
      

  4.   

    漏了一行
    declare @nRow int
    set @nRow = 4
    set rowcount @nRow 
    select * from MD_CountyUnit where ID_County = '410102' and ID_Dept = 'AH1701'
    set rowcount 0
      

  5.   


    lare @nRow int
    set @nRow = 4
    exec('select top '+@nRow+' * from MD_CountyUnit where ID_County = ''410102'' and ID_Dept =''AH1701''')
      

  6.   


    --2005以上
    declare @nRow int
    set @nRow = 4
    select top (@nRow) * FROM sys.tables
    go--2000以上
    declare @nRow int
    set @nRow = 4
    exec('select top '+@nRow+' * from MD_CountyUnit where ID_County = ''410102'' and ID_Dept = ''AH1701''')
    go
    --2000以上
    declare @nRow int
    set @nRow = 4
    set rowcount @nRow 
    select * from MD_CountyUnit where ID_County = '410102' and ID_Dept = 'AH1701'
    set rowcount 0