I have a table emp , Fields with empname,dnname,dno,salary.
now I want copy distinct salary with all emp detail from emp into new table which is not already exist in database. how would I do this ?




Answers were Sorted based on User's Feedback



I have a table emp , Fields with empname,dnname,dno,salary. now I want copy distinct salary with all..

Answer / prashant

SELECT DISTINCT empname,dnname,dno,salary into New Table
from emp

Is This Answer Correct ?    3 Yes 2 No

I have a table emp , Fields with empname,dnname,dno,salary. now I want copy distinct salary with all..

Answer / b.kumar

WITH CTE
AS
(
SELECT *, ROW_NUMBER() OVER (PARTITION BY SAL ORDER BY SAL) AS ROWID
FROM EMP7
) SELECT * INTO EMP10 FROM CTE WHERE ROWID=1

Is This Answer Correct ?    1 Yes 0 No

Post New Answer




More SQL Server Interview Questions

Advantages and disadvantages of stored procedures.

2 Answers   HCL,


how to find out the repeated value from table using groupby function?

4 Answers  


What are three SQL keywords used to change or set someone?s permissions?

3 Answers  


explain different types of jions with examples briefly?

1 Answers   Zensar,


I applied Transactional with updatable subscriptions replication on 2 tables now i want to delete those 2 tables but i cannot delete those tables as replication is running how can i stop replication for those 2 tables(but i don't want to delete those replicated tables but i need to stop the replication) how can i do that

0 Answers  






Delete duplicate rows from a table without primary key by using a single query Table Employee empname salary A 200 B 300 A 200 C 400 D 500 D 500 Output should be A 200 B 300 C 400 D 500

14 Answers  


SQL stops working in every 15 days displaying message that database log file is full. Log file size is 3.95 GB. It is happening after shrinking the database also. What is solution to overcome this problem. Please help me as it's urgent.

5 Answers  


What is the difference between UNION and UNIONALL?

5 Answers   CTS, CarrizalSoft Technologies,


What is difference between stored procedure and function?

3 Answers   L&T,


What are the types of indexes available with SQL Server?

2 Answers   Standard Bank,


how to retrive only second row from table in sql server 2000?

15 Answers   Cognizant, CTS,


About types of indexes in SQL server ?

2 Answers   Cognizant,






Categories