/* JAJ Input: TableName OR null. IF param IS null THEN lists ALL the tables Otherwise return all the fields of the of the table passed */ CREATE PROC [dbo].[sp_Get_Tables] @qxTablename varchar(50)=NULL As DECLARE @TableName varchar(40),@ColumnName nvarchar(30),@Type nvarchar(20),@Nullable nvarchar(5) DECLARE @strLength nvarchar(10) DECLARE @objid int ,@Length int DECLARE @SNoTable tinyint DECLARE @SNo tinyint DECLARE @strSNo AS nvarchar(5) IF @qxTablename IS NOT NULL /* If there is no table passed */ begin SELECT Name AS 'Column_Name',type_name(xusertype) as 'Type', convert(int, length) as 'Length', CASE WHEN isnullable = 0 THEN 'no' ELSE 'yes' END as 'Nullable' FROM syscolumns WHERE id =object_id (@qxTablename) AND number = 0 end IF @qxTablename IS NULL Begin SELECT Name as TableName FROM Sysobjects where xtype ="U" End /* BANG */ GO
"If ye love wealth better than liberty, the tranquility of servitude better than the animated contest of freedom, go home from us in peace. We ask not your counsel or arms. Crouch down and lick the hands which feed you. May your chains set lightly upon you, and may posterity forget that ye were our countrymen."
~Samuel Adams