Below is the SQL query which can be used to find out the tables which are created or modified on or from a given date. SELECT [name] as Tablename ,create_date ,modify_date FROM sys.tables where cast(create_date as date)>=’Given date’
Sometimes we need to check which tables of our database is highly populated. Below is the T-SQL Script which we can use to find out that. SELECT t.NAME AS TableName, i.name as indexName, sum(p.rows) as RowCounts, sum(a.total_pages) as TotalPages, sum(a.used_pages) as UsedPages, sum(a.data_pages)… Read More »
Many times we need to alter the table definition by adding , deleting or updating a column in the table. In this article, I am trying to explain the following :- 1. How to add a column 2. How to update a column 3. How to drop a column Suppose we have a table say… Read More »
To rename a column in a SQL Table following command can be reused: SP_RENAME ‘old table name’, ‘New table name’ For example, if we want to rename the table from employee to employeemaster, following command can be used. SP_RENAME ’employee’, ’employeemaster’ This command will rename the table from employee to employeemaster.
We often need to change the name of a column of a table to a new name. We can do this with the help of the Exec Sp_rename command. The Syntax of the Sp_rename is given below:- Exec sp_rename ‘TableName.[OldColumnName]’, ‘[NewColumnName]’, ‘Column’ For example, suppose we have a table called Employee who has the following structure:-… Read More »
Tables can be defined as the structure which contains the data in the database. There can be many ways to create table and to insert data into the table. Some of the ways to create a table is given below:- 1)Creation of a table with the help of a create statement For example, suppose we… Read More »