Coldfusion blog - by phil porter
   

fearlessFusion.com is my Blog and Online portfolio; I am currently the Director of Visualweb Ltd. Read More


SQL - getting table info

Sometimes I've had the need to use SQL to go and get table information i.e is a field varchar or int etc.

For MS SQL server you can use the following to get info on a table

SELECT RIGHT(syscolumns.name, LEN(syscolumns.name)) AS dbFieldName, systypes.name AS typename, syscolumns.length AS maxlength, syscolumns.xprec AS [precision], syscolumns.xscale AS scale, syscolumns.isnullable AS isnullable
FROM syscolumns INNER JOIN
sysobjects ON sysobjects.id = syscolumns.id INNER JOIN
systypes ON syscolumns.xtype = systypes.xtype
WHERE (sysobjects.name = THE_TABLE_NAME)
ORDER BY syscolumns.colorder


Comments (Comment Moderation is enabled. Your comment will not appear until approved.)

Sponsored Links

 

 




Calendar

« July 2008 »
M T W T F S S
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      


Recent Comments

Multiple SQL inserts: Oracle, Mysql, Mssql

JAYESH TALSANIYA said: in mssql u cannot use parentheses in select statement. use as below: INSERT INTO [TABLE] (column1,... [More]

Multiple SQL inserts: Oracle, Mysql, Mssql

JD said: I found with MSSQL, I couldn't use parentheses in my select statements for insert. So, from your ex... [More]

BlogCFC ping list and timeouts

Will Wilson said: Nice :) that will come in handy, thanks! [More]

Is this a Coldfusion 8 BUG

Barb said: I'm having the same problem . . . when I start CF8, it seems to hang during or just after the user M... [More]

Is this a Coldfusion 8 BUG

João Fernandes said: Phil, when you install CF8 they give you an option to install LCDS within CF. The messageBrokerServl... [More]





W3C Design Gallery

natalia ventre CSSWerk
holgerkoenemann.com 2Creative
Roy Arellano - Web Designer Nick Dewar Illustration