There seems to be some difference's between versions of SQL Anywhere on how to get a list of columns and data types for a table. This is the SQL I use:
In some cases, it appears that it doesn't pick up all the columns for a table. Is it the join to systypes? What SQL can I use across all versions to extract the information in the above query? Thanks, Brad asked 09 Dec '09, 15:03 Brad Wery Breck Carter |
I suspect that dbo.syscolumns doesn't list columns that use custom domains. Here's an almost equivalent statement:
answered 09 Dec '09, 18:22 Graeme Perrow Thanks a lot. I'll get some people to test it out. I'v noticed that this statement runs only on version 10 and later, presumably due to changes in then structure of the system tables Comment Text Removed
1
@Reimer: Change the WHERE clause to where t.table_name='whatever' and it works for versions 5.5 through 11.0.1. Also note, if there are multiple tables with the same name but different owners, you really need to add a predicate for the owner. |
@Brad: Here's a tip: Study the Version 9 catalog tables, and NEVER EVER use any of the SYS. or DBO. view names, either in V9 or earlier, or in V10 and later (where everything changed). The old views like SYSCOLUMNS suck big wampum, lead to confusion and worse... stick to the REAL TABLES. The kicker comes in V10 and later, when all the old tables became views themselves... but these views are designed for backward compatibility and all but one of them work quite well. Bottom line, never use SYSCOLUMNS, but SYSCOLUMN is ok. An expanded rant is available on request :)
Breck, I would love a more expanded rant personally.
@Breck: Me, too:)