Interviews - C# Corner

Rohit Kainth
How to insert ONLY HEADER of one table into another table?
By Rohit Kainth in SQL Server onOct 09 2018
  • Mamta Rajpoot
    Oct, 2018 27

    First we create a table with only header , no data should be inserted. After that by using insert into command we can move the header of first table to second table.create table table1 ( Id int, name varchar(10)) Go Select * into table2 from table1 where 1=2

    • 0
  • Rohit Kainth
    Oct, 2018 9

    We can do so by adding a condition at the end of the T-SQLCREATE TABLE TEST_WF (ID INT, NAME VARCHAR(5))INSERT INTO TEST_WF VALUES (1,'A'),(2,'B'),(3,'B'),(4,'C'),(5,'C'),(6,'C')SELECT * INTO TEST FROM TEST_WF WHERE 1=2By adding the false condition or the condition which can not be true, we can insert Headers only from one table to another table.

    • 0

Most Popular Companies

Most Popular Job Functions

MOST LIKED QUESTIONS