views:

25

answers:

1

I have a database table where columns are in multiple schemas. Example:

SomeTable
SomeSchema.Column1
SomeSchema.Column2
AnotherSchema.ColumnA
AnotherSchema.ColumnB

I have code using a DataTable.Rows[r][c].ToString() syntax and it looks like only the Column1 or ColumnA part is being returned. I need to get the full name SomeSchema.Column1 as right now it seems the code is throwing a Sql Exception with Column1 not found. I'm assuming that if I can reference it as SomeSchema.Column1 that this will correct the exception. Can I get this using a DataTable or DataColumn or is there another approach I need to take for this? Any ideas? I have searched Google and this site with such keywords as "C# datatable datacolumn schema table dbo" and have not had much luck.

A: 

LMAO, I've been working on this too long without a break I think... it's not the columns that have the schema, it is the table, so I think I can tweak my query to get the table name with the schema which I think will feed right in to my existing code and all will be good... I'll post back after it's done and tested... sigh...

Jason
Yeah, sorry... I changed my query to get all tables in database from select name from sys.tables to select schema_name(schema_id) + '.' + name from sys.tables and I'm now getting the full table name which should avoid the exception. Going to bed now... thanks and sorry for the confusion...Jason
Jason