SELECT table_name=sysobjects.name,
column_name=syscolumns.name,
datatype=systypes.name,
length=syscolumns.length
FROM sysobjects
JOIN syscolumns ON sysobjects.id = syscolumns.id
JOIN systypes ON syscolumns.xtype=systypes.xtype
WHERE syscolumns.name=’YourColumnName”
Archive for the 'SQL' Category
To search all tables to find a column or field name in a database
August 24, 2008Get column names of table
August 24, 2008SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.Columns where TABLE_NAME = ‘tableName’
Get column names from MSSQL
August 24, 2008SELECT table_name=sysobjects.name,
column_name=syscolumns.name,
datatype=systypes.name,
length=syscolumns.length
FROM sysobjects
JOIN syscolumns ON sysobjects.id = syscolumns.id
JOIN systypes ON syscolumns.xtype=systypes.xtype
WHERE sysobjects.xtype=’U‘
ORDER BY sysobjects.name,syscolumns.colid
SQL Error Codes
August 12, 2008This document contains SQL error messages.
For some error codes, there are two possible error messages. When possible (usually at SQL compile time), error messages include explicit references to tables, views, or other entities. For those codes with two messages, the distinct messages are separated below by “OR”.
Note:
While this document lists error codes as negative values, JDBC and ODBC clients always receive positive values. For example, if an ODBC or JDBC application returns error code 30, look up error code -30 in this table.
SQL Error Codes
| Error Code | Description |
|---|---|
| 100 | No (more) data |
| 0 | Successful Completion |
| -1 | Invalid SQL statement |
| -2 | Exponent digits missing after ‘E’ |
| -3 | Closing quote (“) missing |
| -4 | A term expected, beginning with one of the following: identifier, constant, aggregate, %ALPHAUP, %EXACT, %SQLSTRING, %SQLUPPER, %STRING, %UPPER, $$, :, +, -, (, NOT, EXISTS, or FOR |
| -5 | Column number specified in ORDER does not match SELECT list |
| -6 | ORDER must specify column number, not names, when after UNION |
| -7 | ORDER column is not in the SELECT list |
| -8 | Invalid DATEPART code for DATEPART(), DATENAME(), DATEADD(), or DATEDIFF() |
| -9 | Incompatible SELECT lists used in UNION |
| -10 | The SELECT list of the subquery must have exactly one item |
| -11 | A scalar expression expected, not a condition |
| -12 | A term expected, beginning with one of the following: identifier, constant, aggregate, $$, :, (, +, -, %ALPHAUP, %EXACT, %SQLSTRING, %SQLUPPER, %STRING, or %UPPER |
| -13 | An expression other than a subquery expected here |
| -14 | A comparison operator is required here |
| -15 | A condition expected after NOT |
| -16 | A qualifier SOME or ALL expected after the FOR in the for-expression |
| -17 | A for-condition expected after the ( in the for-expression |
| -18 | IS (or IS NOT) NULL predicate can be applied only to a field |
| -19 | An aggregate function cannot be used in a WHERE clause |
| -20 | Name conflict in the FROM list over label |
| -22 | ORDER must specify column names, not numbers, when after ‘SELECT *’ |
| -23 | Label is not listed in FROM |
| -25 | Input encountered after end of query |
| -26 | Missing FROM clause |
| -27 | Ambiguous labels for field |
| -28 | Host variable name must begin with either % or a letter |
| -29 | Field ambiguous/not found |
| -30 | Table or View not found |
| -31 | Field not (Found/Unique) in Table(s) |
| -32 | Outer-join symbol ( =* or *= ) must be between two fields |
| -33 | No field(s) found for table |
| -34 | %INORDER: FROM order inconsistent with outer join order |
| -35 | INSERT/UPDATE/DELETE not allowed for non-updatable view |
| -36 | WITH CHECK OPTION (CHECKOPTION class parameter) not allowed for non-updatable views |
| -37 | SQL Scalar/Aggregate/Unary function not supported for Stream fields |
| -38 | No master map for table |
| -39 | No RowID field for table |
| -40 | ODBC escape extension not supported |
| -41 | An extrinsic function call must have the form ‘$$tag^routine(…)’ |
| -42 | Closing quotes (“”) missing following pattern match |
| -43 | Table is ambiguous within #IMPORT schema name list |
| -44 | Duplicate method or query characteristic |
| -45 | Duplicate method in Cache’ ObjectScript query body |
| -46 | Required method missing in Cache’ ObjectScript query body |
| -47 | Invalid method or query characteristic |
| -48 | Invalid trigger REFERENCING clause for the trigger’s event |
| -49 | Trigger REFERENCING clause cannot be specified when trigger language not SQL |
| -50 | Trigger specifies UPDATE OF <fieldlist> clause when trigger language not SQL |
| -51 | SQL statement expected |
| -52 | Cursor (Already/Was Not) DECLAREd |
| -53 | Constant or variable expected as new value |
| -54 | Array designator (last subscript omitted) expected after VALUES |
| -55 | Invalid GRANT <role> TO or REVOKE <role> FROM |
| -56 | GRANT/REVOKE Action not applicable to an object of this type |
| -57 | Trigger specifies WHEN clause when trigger language not SQL |
| -58 | Duplicate field found in trigger UPDATE OF <fieldlist> clause |
| -59 | Cannot have more than one field |
| -60 | An action (%ALTER, SELECT, UPDATE, etc.) expected |
| -61 | Cursor not updatable |
| -62 | Additional new values expected for INSERT/UPDATE |
| -63 | Data Exception – invalid escape character |
| -64 | Incompatible SELECT list is used in INSERT |
| -65 | Positive integer constant or variable expected |
| -66 | Redundant Fields Found in SELECT list |
| -67 | Aggregate not valid in subquery of FROM clause |
| -68 | DISTINCT not valid in subquery of FROM clause |
| -69 | SET <field> = <value expression> not allowed with WHERE CURRENT OF <cursor> |
| -70 | Multi-Line Field only valid for LIKE, Contains ([), or NULL Comparison. |
| -71 | Multi-Line Field must be the Left operand of the Comparison. |
| -72 | Multi-Line Field not valid in ORDER BY clause. |
| -73 | Aggregates not supported in ORDER BY clause. |
| -74 | Duplicate <select-list> alias names found. |
| -75 | <trim spec> and/or <trim char> required before FROM in TRIM function. |
| -76 | Cardinality mismatch between the SELECT-list and INTO-list. |
| -77 | Qualified column reference not allowed in this JOIN context. |
| -78 | Invalid transaction state. |
| -79 | Referencing key and referenced key must be the same size |
| -80 | Integer expected |
| -81 | Column Constraint expected |
| -82 | Multiple table %DESCRIPTION definitions found |
| -83 | Multiple table %FILE definitions found |
| -84 | Multiple table %NUMROWS definitions found |
| -85 | Multiple table %ROUTINE definitions found |
| -86 | Invalid field definition, no datatype defined |
| -87 | Invalid table name |
| -88 | Invalid field name |
| -89 | Invalid index name |
| -90 | Invalid view name |
| -91 | <transaction mode> cannot be specified more than once. |
| -92 | <level of isolation> cannot be READ UNCOMMITTED if READ WRITE specified. |
| -93 | <number of conditions> for the DIAGNOSTICS SIZE must be exact numeric. |
| -94 | Unsupported usage of OUTER JOIN. |
| -95 | Operation Disallowed by Operation Table |
| -96 | Specified <level of isolation> is not supported. |
| -97 | Duplicate <select-list> names found. |
| -98 | License Violation |
| -99 | Privilege Violation |
| -101 | Attempt to open a cursor that is already open |
| -102 | Operation (FETCH/CLOSE/UPDATE/DELETE/…) attempted on an unopened cursor |
| -103 | Positioned UPDATE or DELETE attempted, but the cursor is not positioned on any row |
| -104 | Field validation failed in INSERT |
| -105 | Field validation failed in UPDATE |
| -106 | Row to DELETE not found |
| -107 | Cannot UPDATE RowID or RowID based on Fields |
| -108 | Required field missing; INSERT or UPDATE not allowed |
| -109 | Cannot find the row designated for UPDATE |
| -110 | Locking conflict in filing |
| -111 | Cannot INSERT into a ‘Default Only’ RowID or RowID based on field |
| -112 | Access violation |
| -113 | %THRESHOLD Violation |
| -114 | One or more matching rows is locked by another user |
| -115 | Cannot INSERT/UPDATE/DELETE on a read only table |
| -116 | Cardinality mismatch on INSERT/UPDATE between values list and number of table columns. |
| -117 | Aggregates not supported in Views |
| -118 | Unknown or non-unique User or Role |
| -119 | UNIQUE or PRIMARY KEY Constraint failed uniqueness check upon INSERT |
| -120 | UNIQUE or PRIMARY KEY Constraint failed uniqueness check upon UPDATE |
| -121 | FOREIGN KEY Constraint failed referential check upon INSERT of row in referencing table |
| -122 | FOREIGN KEY Constraint failed referential check upon UPDATE of row in referencing table |
| -123 | FOREIGN KEY Constraint failed referential check upon UPDATE of row in referenced table |
| -124 | FOREIGN KEY Constraint failed referential check upon DELETE of row in referenced table |
| -125 | UNIQUE or PRIMARY KEY Constraint failed uniqueness check upon creation of the constraint |
| -126 | REVOKE with RESTRICT failed. |
| -127 | FOREIGN KEY Constraint failed referential check upon creation of the constraint |
| -130 | Before Insert trigger failed |
| -131 | After Insert trigger failed |
| -132 | Before Update trigger failed |
| -133 | After Update trigger failed |
| -134 | Before Delete trigger failed |
| -135 | After Delete trigger failed |
| -136 | View’s WITH CHECK OPTION validation failed in INSERT |
| -137 | View’s WITH CHECK OPTION validation failed in UPDATE |
| -140 | Invalid length parameter passed to the SUBSTRING function |
| -141 | Invalid input value passed to the CONVERT function |
| -201 | Table or View name not unique |
| -300 | DDL not allowed on this table definition |
| -304 | Attempt to add a NOT NULL field with no default value to a table which contains data |
| -305 | Attempt to make field required when the table has one or more rows where the column value is NULL |
| -306 | Column with this name already exists |
| -307 | Primary key already defined for this table |
| -310 | Foreign key references non-existent table |
| -311 | Foreign key with same name already defined for this table |
| -314 | Foreign key references non-unique key/column collection |
| -315 | Constraint or Key not found |
| -317 | Cannot DROP Constraint – One or more Foreign Key constraints reference this Unique constraint |
| -319 | Referenced table has no primary key defined |
| -320 | Cannot DROP table – One or more Foreign Key constraints reference this table |
| -324 | Index with this name already defined for this table |
| -325 | Index cannot be dropped because it is the IDKEY index and the table has data |
| -333 | No such index defined |
| -340 | Transaction failed to start. |
| -341 | Transaction failed to COMMIT. Implicit ROLLBACK performed. |
| -342 | Transaction failed to ROLLBACK. |
| -343 | Not in a transaction. |
| -344 | Invalid Transaction Sate – Active SQL-Transaction. |
| -345 | Invalid condition number. |
| -346 | Transaction failed to COMMIT. Implicit ROLLBACK also failed. |
| -347 | Transaction failed to COMMIT |
| -358 | SQL Function (function Stored Procedure) name not unique |
| -359 | SQL Function (function Stored Procedure) not found |
| -360 | Class not found |
| -361 | Method or Query name not unique |
| -362 | Method or Query not found |
| -363 | Trigger not found |
| -364 | Trigger with same EVENT, TIME, and ORDER already defined |
| -365 | Trigger name not unique |
| -366 | Schema name mismatch between trigger name and table name |
| -370 | Embedded SQL CALL Statement can only be used for Method Procedures |
| -371 | :HVar = CALL … Specified for a Procedure which does not return a value |
| -372 | Support for extrinsic function calls are disabled |
| -373 | An extrinsic function call may not call a % routine |
| -374 | Cannot alter the datatype of a field to/from a stream type when the table contains data |
| -400 | Fatal error occurred |
| -401 | Fatal Connection error |
| -402 | Invalid Username/Password |
| -405 | Unable to read from communication device |
| -406 | Unable to Write to Server |
| -407 | Unable to Write to Server Master |
| -408 | Unable to start server |
| -409 | Invalid server function |
| -410 | Invalid Directory |
| -411 | No stream object defined for field |
| -412 | General Stream Error |
| -413 | Incompatible Client/Server Protocol |
| -415 | Fatal error occurred within the SQL filer |
| -421 | Warning: UPDATE or DELETE statement does not contain a WHERE clause |
| -422 | SELECT request processed via ODBC, JDBC, or Dynamic SQL cannot contain an INTO clause |
| -425 | Error processing Stored Procedure request |
| -426 | Error preparing Stored Procedure |
| -427 | Invalid Stored Procedure Name |
| -428 | Stored Procedure Not Found |
| -429 | Invalid number of input/output parameters for Stored Procedure |
| -430 | Cannot initialize procedure context |
| -450 | Unable to send client message |
| -451 | Unable to receive server message |
| -452 | Message sequencing error |
| -453 | Error in User Initialization Code |
| -460 | General error |
| -461 | Communication link failure |
| -462 | Memory allocation failure |
| -463 | Invalid column number |
| -464 | Function sequence error |
| -465 | Invalid string or buffer length |
| -466 | Invalid parameter number |
| -467 | Column type out of range |
| -468 | Fetch type out of range |
| -469 | Driver not capable |
| -470 | Option value changed |
| -471 | Duplicate cursor name |
| -500 | Fetch row count limit reached |
| -10050 | WinSock: Network is down |
| -10051 | WinSock: Network is unreachable |
| -10052 | WinSock: Net dropped connection or reset |
| -10054 | WinSock: Connection reset by peer (due to timeout or reboot) |
| -10055 | WinSock: No buffer space available |
| -10056 | WinSock: Socket is already connected |
| -10057 | WinSock: Socket is not connected |
| -10058 | WinSock: Cannot send after socket shutdown |
| -10060 | WinSock: Connection timed out |
| -10061 | WinSock: Connection refused |
| -10064 | WinSock: Host is down |
| -10065 | WinSock: No route to host |
| -10070 | WinSock: Stale NFS file handle |
| -10091 | WinSock: Network subsystem is unavailable |
| -10092 | WinSock: WINSOCK DLL version out of range |
| -10093 | WinSock: Successful WSASTARTUP not yet performed |
| -11001 | WinSock: Host not found |
| -11002 | WinSock: Nonauthoritative host not found |