(tableName: string, schema?: string)
| 440 | } |
| 441 | |
| 442 | async getTableComment(tableName: string, schema?: string): Promise<string | null> { |
| 443 | if (!this.connection) { |
| 444 | throw new Error("Not connected to SQL Server database"); |
| 445 | } |
| 446 | |
| 447 | try { |
| 448 | const schemaToUse = schema || "dbo"; |
| 449 | |
| 450 | const request = this.connection |
| 451 | .request() |
| 452 | .input("tableName", sql.VarChar, tableName) |
| 453 | .input("schema", sql.VarChar, schemaToUse); |
| 454 | |
| 455 | const query = ` |
| 456 | SELECT ep.value as table_comment |
| 457 | FROM sys.extended_properties ep |
| 458 | JOIN sys.tables t ON ep.major_id = t.object_id |
| 459 | JOIN sys.schemas s ON t.schema_id = s.schema_id |
| 460 | WHERE ep.minor_id = 0 |
| 461 | AND ep.name = 'MS_Description' |
| 462 | AND t.name = @tableName |
| 463 | AND s.name = @schema |
| 464 | `; |
| 465 | |
| 466 | const result = await request.query(query); |
| 467 | |
| 468 | if (result.recordset.length > 0) { |
| 469 | return result.recordset[0].table_comment || null; |
| 470 | } |
| 471 | return null; |
| 472 | } catch (error) { |
| 473 | return null; |
| 474 | } |
| 475 | } |
| 476 | |
| 477 | async getStoredProcedures(schema?: string, routineType?: "procedure" | "function"): Promise<string[]> { |
| 478 | if (!this.connection) { |
nothing calls this directly
no outgoing calls
no test coverage detected