How to Copy Structure of One Table into Another Table?

SQL Query to copy structure of one table to another table in SQL Server.

Syntax: Select * into Newtable from Oldtable where 1=2

Ex: Select * into emp1 from emp where 1=2

The above query copies only structure(not data) of emp to emp1.

SQL Query to get structure of table

How To Get Structure of a Table in SQL Server?

SQL Query to view structure of a table in sqlserver.

SP_help tablename

SP_help emp

SQL Query to Rename Column Name in SQL Server-Query to change Column Name in SQL SERVER

Query to change Column Name in SQL SERVER

sp_rename 'Tablename.old fieldname', 'new field name'

sp_rename 'xyz.aaa','bbb'

Query to add years to particular date

Query to add years to particular date
select dateadd(year,noofyears to be added,datecolumndate)yearadd from tablename

Query to add years to particular date

Query to add years to particular date
select dateadd(year,noofyears to be added,datecolumndate)yearadd from tablename

Query to add months to particular date

Query to add months to particular date
select dateadd(month,noofmonths to be added,datecolumndate)monthadd from tablename

Query to add days to particular date

Query to add days to particular date
select dateadd(day,noofdays to be added,datecolumnname)dayadd from tablename

Query to get only year from particular date

Query to get only year from particular date
select year(datecolumnname)as year from tablename

Query to get only month from particular date

Query to get only month from particular date
select month(datecolumnname)as month from tablename

Query to get only day from particualar date

Query to get only day from particualar date
select day(datecolumnname)as day from tablename

Query to get only date from datetime field

Query to get only date from datetime field
select convert(varchar,datecolumnname,110) from tablename

query to rename table

query to rename table using sqlserver

sp_rename existingtablename,newtablename

query to get system date

query to get system date and time using sqlserver

select getdate()

query to get column names of table

query to get column names of particular table using sqlserver 2000

select name from SYSCOLUMNS where id=(select id from SYSOBJECTS where name='tablename')

SQL Query to copy only structure of one table to other table in SqlServer
SQL Query to get structure of table in SqlServer

Movie Songs Lyrics
Software Testing-QTP Scripts,Testing Faqs

sql query to get column count of table-query to get number of columns in table

query to get number of columns of particular table using sqlserver

select count(*)as NOC from SYSCOLUMNS where id=(select id from SYSOBJECTS where name='tablename')

Recent Posts