Showing posts with label SQL QUERY. Show all posts
Showing posts with label SQL QUERY. Show all posts

Saturday, September 14, 2013

How to get table columns in sql server

This query return columns of table in SQL Server database 

 DECLARE @TABLE_NAME VARCHAR(MAX)  
 SET @TABLE_NAME='customer_master'  
 SELECT c.name  
 FROM sys.tables AS t, sys.columns AS c  
 WHERE t.object_id= c.object_id  
 AND t.name= @TABLE_NAME