2

I am using SQLSERVER 2014 Express and I created Employee Table

I want to know the details Description for the Employee Table

like NULL or NOT NULL and Datatypes

In Oracle we have desc Employee like any syntax? Please help me

TheGameiswar
  • 27,855
  • 8
  • 56
  • 94
Hemanthkumar Naik
  • 151
  • 1
  • 3
  • 11

4 Answers4

7

SP_HELP will give info on an object:

exec sp_help 'objectName'
gofr1
  • 15,741
  • 11
  • 42
  • 52
AntDC
  • 1,807
  • 14
  • 23
3

In SSMS find table you need, right-click on it, choose Script Table As... -> CREATE To -> New Query Editor Window

That will give you creation script where you can see all details about table structure.

Another way is to use system tables:

USE MyDB

SELECT  c.name,
        s.name,
        c.max_length,
        c.is_nullable
FROM sys.columns c
LEFT JOIN sys.systypes s
    ON s.xusertype= c.system_type_id
WHERE object_id = object_id(N'Employees')

This will give you:

name            name        max_length  is_nullable
EmployeeID      int         4           0
LastName        nvarchar    40          0
FirstName       nvarchar    20          0
...etc

Or views:

USE MyDB

SELECT  TABLE_NAME, 
        COLUMN_NAME, 
        DATA_TYPE,
        IS_NULLABLE 
FROM INFORMATION_SCHEMA.COLUMNS  
WHERE TABLE_NAME = 'Employees';  

Output:

TABLE_NAME  COLUMN_NAME DATA_TYPE   IS_NULLABLE
Employees   EmployeeID  int         NO
Employees   LastName    nvarchar    NO
Employees   FirstName   nvarchar    NO
Employees   Title       nvarchar    YES

Note: also you can use EXEC sp_help 'Employees' more about this SP you can read on MSDN.

gofr1
  • 15,741
  • 11
  • 42
  • 52
1

You can use exec sp_help 'Employee' it outputs everything related to the table.

CiucaS
  • 2,010
  • 5
  • 36
  • 63
1

You can select the table in ssms and press ALT+F1 keys together and able to see the full table description along dependencies on the table.

suraj1287
  • 129
  • 1
  • 8