Showing posts with label SQL. Show all posts
Showing posts with label SQL. Show all posts

Find the database size in SQL Server

This is very important to find regularly if you are hosting the web site in hosting providers. The database size grows day to day and we have to find it more often. otherwise it grows than the given size and account will be suspended.  Below is the command used to find the size of the database and logs.

SELECT name,size from sys.database_files

Here is the sample output:
NameSize
SampleDatabase384
SampleDatabase_log392


Hope this helps. Read More...

List all Tables using SQL Query in a database

This is not needed in general development times. But, very rare cases only we have to get these kind of requirements and use these rarely used commands. I have a requirement where I need to know the list of tables in a database and do something. So, below is the simple query which is used to list or display the tables in a database.

select [name] from dbo.sysobjects where OBJECTPROPERTY(id, N'IsUserTable') = 1

"sysobjects" is the system table which holds all objects in a database. By using where clause "IsUserTable" returns true if it is a table and filtering the results.
Hope this helps. Read More...
Related Posts with Thumbnails
GiF Pictures, Images and Photos