HOW TO GET FIELD NAME WITH DATATYPE AND SIZE IN SQL QUERY

Ankit Singh

Total Post:341

Points:2389
Posted by  Ankit Singh
 622  View(s)
Ratings:
Rate this:
We want to  get field name with datatype and size In sql Query. How will do this please help me.
  1. aditya kumar Patel

    Post:254

    Points:1810
    Re: How to get field name with datatype and size In sql Query

    CREATE TABLE [dbo].[Employee] (

    [EmpNo] INT IDENTITY (1, 1) NOT NULL,

    [EmpName] VARCHAR (50) NOT NULL,

    [Salary] DECIMAL (18) NOT NULL,

    [DeptName] VARCHAR (50) NOT NULL,

    [Designation] VARCHAR (50) NOT NULL,

    PRIMARY KEY CLUSTERED ([EmpNo] ASC)

    );

    SELECT column_name as 'Column Name', data_type as 'Data Type',

    character_maximum_length as 'Max Length'

    FROM information_schema.columns

    WHERE table_name = 'Employee'

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!