How do I get column type from table?

I have this code:

select as tableid, as tableName, as columnName,
    b.status as columnStatus,
    b.type as columnType
    from sysobjects a 
    LEFT JOIN syscolumns b
    ON =
    WHERE = 'table_name'

Now, the columType shows numbers. I want to get the name of the columnType, which resides in column 'name' in table 'systypes'. How do I do that? Simple LEFT JOIN will result in duplicate rows.


I've seen in Sybase 15.0 and this is the code that you have to use:

select [tableid], [tableName], [columnName], c.status [columnStatus] [columnType] from sysobjects o
inner join syscolumns c on =
inner join systypes t on t.usertype = c.usertype
where o.type = 'U' and in (tablename)

select [tableid], [tableName], [columnName], c.status [columnStatus], [columnType] from sysobjects o
inner join syscolumns c on =
inner join systypes t on t.type = c.type
where o.type = 'U' and = 'table_name'
and not in ('sysname', 'nid', 'uid', 'nvarchar', 'tid', 'nchar')

I add the last line from @aF. code. I don't know how to explain this. I got this answer from here:

create function dbo.GetColumnDataTypeName(@TableName TName, @ColumnName TName)
returns sysname
    declare @typeName sysname,
        @tableId int = object_id(@TableName)
    @typeName = type_name(user_type_id)
    from sys.columns sc
    where sc.[object_id] = @tableId
    and sc.Name = @ColumnName

    return @typeName

select as table_name, '' as table_description, as fileld_name,'' as field_description, as format,
    sc.length as data_length,sc.prec as decimal_places,'' as primary_key,
     case when sc.status = 8 then 'Y'
            else 'N'
     end as nulls
    from syscolumns sc
    INNER JOIN sysobjects so ON =
    inner join systypes st on sc.type = st.type
    WHERE in (/*table list*/)
    and not in ('sysname', 'nid', 'uid', 'nvarchar', 'tid', 'nchar','longsysname','usr_char')
    order by   

Need Your Help

Is it possible to advance a deadlocked thread? stuck at WaitForSingleObject

windows multithreading delphi winapi deadlock

If I have an app that is creating threads which do their work and then exit, and one or more threads get themselves into a deadlock (possibly through no fault of my own!), is there a way of

Inner Class method access to parent method's variable


Why can't method r access variable c? I know it can't access the variable but I'm trying to understand why it doesn't.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.