Wednesday, April 24, 2013

Listing columns in SQL tables

Here is the SQL script to list columns in tables:
 
SELECT
  tab.TABLE_TYPE
, tab.TABLE_NAME
, col.COLUMN_NAME
, DATA_TYPE
, IS_NULLABLE
, CHARACTER_MAXIMUM_LENGTH
FROM
INFORMATION_SCHEMA.TABLES tab
INNER JOIN INFORMATION_SCHEMA.COLUMNS col
ON tab.TABLE_NAME = col.TABLE_NAME
WHERE
tab.TABLE_CATALOG = col.TABLE_CATALOG
AND tab.TABLE_SCHEMA = col.TABLE_SCHEMA
AND COLUMN_NAME like 'COLNAME%'
ORDER
BY
TABLE_TYPE, tab.TABLE_NAME
, COLUMN_NAME

Monday, April 15, 2013

Opereating System returned 5(Access is denied) while attempting to RestoreContainer::ValidateTargetForCreate on

I got the following error while creating a database:

Opereating System returned 5(Access is denied) while attempting to RestoreContainer::ValidateTargetForCreate on

Cause: The user running the MSSQLSERVER service does not have proper access to the path.

Solution: Give proper access to the 'user' running the MSSQLSERVER service.