SQL Server Interview Questions

Showing Questions 181 - 183 of 183 Questions
First | Prev | Next | Last Page
Sort by: 
 | 
Jump to Page:
  •  

    What is DESCRIBE command in SQL Server?

    What is its purpose?How to use it?

    Star Read Best Answer

    Editorial / Best Answer

    suji  

    • Member Since Sep-2005 | Nov 5th, 2011


    Here are multiple ways to get the table information. The DESCRIBE command does not exist in MS SQL SERVER. This is an Oracle command used to describe the structure of objects within a given database. To achieve the same task in MSSQL Server, there are a series of stored procedures with the prefix SP_ that can be used. To view the structure of a table within the current database, use the command

    Code
    1. sp_help 'TABLE_NAME';
    If you would like to see more details, Create your custom procedure
    Code
    1. span style="color: #ff0000;">'order'
    Here is another alternative way to get the same information
    Code
    1. span style="color: #ff0000;">'TableName''Employee'
    Here is the usage :
    Code
    1. span style="color: #ff0000;">'Department''sa''TableName'
    Contributors for the editorial answer : Kewlshiva, srilakshmi.b, raaghav,kevaburg

    Rooshi

    • Oct 17th, 2014

    Sp_help will give all the details about the table columns, indexes, partitions etc.

    Saket Kale

    • Oct 24th, 2012

    Sp_help dbo.customers;

    worked for me just fine.

    Thanks to the OP, this runs perfectly on SQL 2008 R2, do not know about other versions

  •  

    Write sql query for retrieving employee names from employee table who are having salary greater than 5000 without using where clause?

    Star Read Best Answer

    Editorial / Best Answer

    Answered by: Parished.D Chennai India

    • Apr 24th, 2007


    create table ee (eno int, ename varchar(200), sal int)

    insert into ee values(1, 'a', 2000)
    insert into ee values(2, 'b', 6000)
    insert into ee values(3, 'c', 8000)

    select ENO, ENAME, min(sal) AS SAL from ee group by eno,ename having min(sal) > 5000

    Aman Gupta

    • Jul 15th, 2024

    SELECT Emp_Name, MIN(Salary) FROM Employee
    GROUP BY Emp_Name
    HAVING MIN(SALARY) > 5000

    Arshad

    • Jul 30th, 2023

    SELECT ENO, SUM(SALARY)
    FROM EE
    GROUP BY ENO
    HAVING SUM(SALARY) > 5000

  •  

    How to remove duplicate records from a table?

    Vijay

    • May 10th, 2012

    SELECT ID FROM TBLSAMPLE GROUP BY ID OR SELECT DISTINCT (ID) FROM TBLSAMPLE

    Code
    1.  

    Mally

    • Feb 13th, 2012

    Good Code...however the code will delete all the duplicates... you may want to add:

    delete top(n) clause in your delete statement to exactly delete the required number of records.

Showing Questions 181 - 183 of 183 Questions
First | Prev | Next | Last Page
Sort by: 
 | 
Jump to Page: