Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.spt_columns_view_managed

  No additional text.


Syntax

CREATE VIEW sys.spt_columns_view_managed AS
SELECT
	o.object_id									AS OBJECT_ID,
	DB_NAME()									AS TABLE_CATALOG,
	SCHEMA_NAME(o.schema_id)					AS TABLE_SCHEMA,
	o.name										AS TABLE_NAME,
	c.name										AS COLUMN_NAME,
	ColumnProperty(c.object_id, c.name, 'ordinal')		AS ORDINAL_POSITION,
	convert(nvarchar(4000), object_definition(c.default_object_id))			AS COLUMN_DEFAULT,
	convert(varchar(3),
		CASE c.is_nullable
		WHEN 1 THEN
			'YES'
		ELSE
			'NO'
		END)									AS IS_NULLABLE,
	ISNULL(type_name(c.system_type_id), t.name)		AS DATA_TYPE,
	ColumnProperty(c.object_id, c.name, 'charmaxlen')	AS CHARACTER_MAXIMUM_LENGTH,
	ColumnProperty(c.object_id, c.name, 'octetmaxlen')	AS CHARACTER_OCTET_LENGTH,
	convert(tinyint, CASE -- int/decimal/numeric/real/float/money
		WHEN c.system_type_id IN (48, 52, 56, 59, 60, 62, 106, 108, 122, 127) THEN
			c.precision
		END)									AS NUMERIC_PRECISION,
	convert(smallint, CASE	-- int/money/decimal/numeric
		WHEN c.system_type_id IN (48, 52, 56, 60, 106, 108, 122, 127) THEN
			10
		WHEN c.system_type_id IN (59, 62) THEN
			2
		END)									AS NUMERIC_PRECISION_RADIX,	-- real/float
	convert(int, CASE	-- datetime/smalldatetime
		WHEN c.system_type_id IN (40, 41, 42, 43, 58, 61) THEN
			NULL
		ELSE
			odbcscale(c.system_type_id, c.scale)
		END)									AS NUMERIC_SCALE,
	convert(smallint, CASE -- datetime/smalldatetime
		WHEN c.system_type_id IN (40, 41, 42, 43, 58, 61) THEN
			odbcscale(c.system_type_id, c.scale)
		END)									AS DATETIME_PRECISION,
	convert(sysname, null)							AS CHARACTER_SET_CATALOG,
	convert(sysname, null)							AS CHARACTER_SET_SCHEMA,
	convert(sysname, CASE
		WHEN c.system_type_id IN (35, 167, 175) THEN	-- char/varchar/text
			CollationProperty(c.collation_name, 'sqlcharsetname')
		WHEN c.system_type_id IN (99, 231, 239) THEN	-- nchar/nvarchar/ntext
			N'UNICODE'
		END)									AS CHARACTER_SET_NAME,
	convert(sysname, null)							AS COLLATION_CATALOG,
	convert(sysname, null)							AS COLLATION_SCHEMA,
	c.collation_name								AS COLLATION_NAME,
	convert(sysname, CASE
		WHEN c.user_type_id > 256 THEN
			DB_NAME()
		END)									AS DOMAIN_CATALOG,
	convert(sysname, CASE
		WHEN c.user_type_id > 256 THEN
			SCHEMA_NAME(t.schema_id)
		END)									AS DOMAIN_SCHEMA,
	convert(sysname, CASE
		WHEN c.user_type_id > 256 THEN
			type_name(c.user_type_id)
		END)						AS DOMAIN_NAME,
	c.is_sparse						AS IS_SPARSE,
	c.is_column_set					AS IS_COLUMN_SET,
	c.is_filestream						AS IS_FILESTREAM

FROM
	sys.objects o JOIN sys.columns c ON
		(
			c.object_id = o.object_id and
			o.type in ('U', 'V')  -- limit columns to tables and views
		)
	LEFT JOIN sys.types t ON c.user_type_id = t.user_type_id
WHERE
	has_perms_by_name(quotename(schema_name(o.schema_id)) + '.' + quotename(o.
name), 'object',

		 'select',
		c.name,
		'column') = 1

 
Last revision SQL2008SP1
See also

  sp_columns_managed (Procedure)
       



News

  Query a named instance
Sybase+ASE+silent+install
SQL 2008 R2
Deprecated procedures in SQL2008
Reporting Services item-level role definitions
Create all your missing indexes
Converting datetime field
Start MSSQL Server Profiler at time
Replicating MSSQL Server views
Exploring Microsoft Sharepoint
The OLE DB provider "SQLNCLI10" for linked server indicates.
Mobile solar charger
Oracle to SQL Server replication
Cannot insert the value NULL into column
Undocumented Microsoft SQL Server 2008
VMware
Zoekmachine optimalisatie
SQL Servers hidden objects
FckEditor
Flash in Ajax
De hype die AJAX heet
Barcode scannen
MySQL; Gratis, makkelijk en snel!
PHP
sIFR; de combinatie tussen HTML en Flash