Tuesday, July 17, 2018

SQL Server commands


Get the table name and the row count in a DB:


SELECT
    t.NAME AS TableName,
    SUM(p.rows) AS [RowCount]
FROM
    sys.tables t
INNER JOIN   
    sys.indexes i ON t.OBJECT_ID = i.object_id
INNER JOIN
    sys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id
WHERE 
    i.index_id <= 1
GROUP BY
    t.NAME, i.object_id, i.index_id, i.name
ORDER BY
    SUM(p.rows) DESC

Source: https://stackoverflow.com/questions/3980622/sql-server-2008-i-have-1000-tables-i-need-to-know-which-tables-have-data

Get System time

select SYSDATE()

9 comments:

  1. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.

    Big Data Hadoop training in electronic city

    ReplyDelete
  2. A really good post man, very thankful and hopeful that you will write many more posts like this one.
    kajal hot

    ReplyDelete
  3. Mytranings _Hadoop is an Open Source Framework Data Processing For Application Big Data Environment Cluster Using Computers in a Simple Modules .Programming Modules .
    * I want to Give Best Training time Link _< http://mytrainingsonline.com/course/hadoop/ >

    Hadoop Online Trainings
    Hadoop Best Online Trainings
    Hadoop Online Trainings in Hyderabad

    ReplyDelete
  4. )Wow it is really wonderful and awesome thus it is veWow it is really wonderful and awesome thus it is very much useful for me to understand many concepts and helped me a lot. it is really explainable very well and i got more information from your site.ry much useful for me to understand many concepts and helped me a lot.
    Hadoop Training in Bangalore

    ReplyDelete