大家好,我想问下:我如何用SQL语句获取数据库的总条数,比如我有个User表,里面有id,name,password等属性,而且这个自动随着新增注册人,总条数就发生改变,我如何数据库有几条数据?

解决方案 »

  1.   

    select count(*) from Users
      

  2.   

    LZ是说所有表,不是单个表
    --查询数据库所有表的记录总数
    CREATE TABLE #temp (TableName VARCHAR (255), RowCnt INT)
    EXEC sp_MSforeachtable 'INSERT INTO #temp SELECT ''?'', COUNT(*) FROM ?'
    SELECT TableName, RowCnt FROM #temp ORDER BY TableName
    DROP TABLE #temp
      

  3.   

    select count(*) as 总条数 from Users
      

  4.   

    --
    --查询数据库所有表的记录总数
    CREATE TABLE #temp (TableName VARCHAR (255), RowCnt INT)
    EXEC sp_MSforeachtable 'INSERT INTO #temp SELECT ''?'', COUNT(*) FROM ?'
    --SELECT TableName, RowCnt FROM #temp ORDER BY TableName --每个表的记录数
    select sum(rowcnt) from #temp --总记录数
    DROP TABLE #temp
      

  5.   

    使用Count(*)函数吧
    Select count(*) from Users
      

  6.   

    Hi,比如我有下个表格:
    <table width="200" border="1">
      <tr>
        <td rowspan="2">IMGtd>
        <td>Name<td>
      </tr>
      <tr>
        <td>Contenttd>
      </tr>
    </table>
    这个其中一条记录,我如何写For语句把所有的列出来呢?