Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

How to Check Columns name and their types using Store Procedure

Author: DevASP
Download Source Code : 315_Store Procedure.zip

This article is about how you can get the information about the table store in your database made in sql server 2000.

Call the following function and pass the table name as parameter to this store procedure:

CREATE PROCEDURE CheckTable
 @TableName varchar(50)
 AS


 BEGIN
 SELECT name AS [Column Name], --length,xtype, 
 CASE xtype
   WHEN 56 THEN 'int'
   WHEN 167 THEN 'varchar(' + convert(varchar(10),length) + ')'
   WHEN 61 THEN 'dateTime'
   WHEN 104 THEN 'bit'
   WHEN 52 THEN 'smallint'
   WHEN 175 THEN 'char(' + convert(varchar(10),length) + ')'
   END AS [Column Type] 
   FROM syscolumns
   WHERE id IN ( SELECT id FROM sysobjects where name = @TableName )
   RETURN
end

GO

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< Delete All Procedures from a database using a Stored procedure in SQL Server

Disclaimer - Privacy
© 2002-2017 DevASP.net