RSS

Tag Archives: Sql

MS SQL rename column

exec sp_rename ‘tableName.ColumnName’, ‘newColumnName’, ‘COLUMN’

EXEC sp_rename 'LeadTracking.cSource', 'cSourceLookupId', 'COLUMN'

Original source

http://dotnetcoderoom.wordpress.com/2008/09/02/rename-a-table-column-in-ms-sql/

 
Leave a comment

Posted by on May 19, 2011 in SQL

 

Tags:

Get all columns of a certain type from database

How do you get all the tables and columns in your database where the type is like money?

select
     o.name as tableName,
    c.name as ColumnName,
    t.Name as ColumnType,
    o.type as ObjectType,
    u.name as SchemaName
from syscolumns c
inner join sysobjects o
    on o.id=c.id
inner join sysusers u
    on u.uid= o.uid
inner join sys.types t
    on t.system_type_id = c.xtype
where t.Name like '%money%'

 
Leave a comment

Posted by on April 12, 2011 in SQL

 

Tags: