USE [Gaf]
GO
/****** Object: View [dbo].[viewMeta_TableColumns] Script Date: 12/01/2009 08:11:48 ******/
IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[viewMeta_TableColumns]'))
DROP VIEW [dbo].[viewMeta_TableColumns]
GO
USE [Gaf]
GO
/****** Object: View [dbo].[viewMeta_TableColumns]
Script Date: 12/01/2009 08:11:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE VIEW [dbo].[viewMeta_TableColumns]
AS
-- Action !!!
SELECT top 100000
SO.NAME AS 'TableName',
SC.NAME AS 'ColumnName',
st.name as 'DataType' ,
sc.is_nullable as 'IsNullable' ,
sc.is_identity as 'IsPrimaryKey' ,
sc.max_length AS 'MaxLength' ,
SC.is_computed as 'IsComputed' ,
sm.text as 'DefaultValue'
FROM dbo.sysobjects SO
INNER JOIN sys.all_columns SC ON SO.id = SC.object_id
INNER JOIN sys.types st on st.system_type_id = sc.system_type_id
LEFT JOIN syscomments sm on SO.id = sm.id
--LEFT JOIN dbo.syscomments SM ON SC.cdefault = SM.id
--inner join sys.types st
--on sc.xtype = st.system_type_id
WHERE SO.xtype = 'U'
--and SO.name = @TableName --uncomment this line while debugging
ORDER BY SO.[name], SC.object_id
GO
/*
select * from viewMeta_TableColumns
*/
No comments:
Post a Comment
- the first minus - Comments have to be moderated because of the spammers
- the second minus - I am very lazy at moderating comments ... hardly find time ...
- the third minus - Short links are no good for security ...
- The REAL PLUS : Any critic and positive feedback is better than none, so your comments will be published sooner or later !!!!