Home > DeveloperSection > Forums > How to get field name with datatype and size In sql Query
Ankit Singh

Total Post:341

Points:2389
Posted on    March-03-2016 11:03 PM

 MSSQL Server SQL Server 
Ratings:


 1 Reply(s)
 329  View(s)
Rate this:
We want to  get field name with datatype and size In sql Query. How will do this please help me.


aditya kumar Patel

Total Post:250

Points:1782
Posted on    March-03-2016 11:05 PM

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'


Don't want to miss updates? Please click the below button!

Follow MindStick