2

Just some extract from the code:

cmd.CommandText = "SELECT TABLE_TYPE, TABLE_NAME FROM INFORMATION_SCHEMA.TABLES";

using (dataReader = cmd.ExecuteReader())
{
     string tableName = (string)dataReader["TABLE_NAME"];
}

Should I use "table_schema" column of th INFORMATION_SCHEMA.TABLES like this:

dbo.string fullname = dataReader["table_schema"]+"."+dataReader["table_name"];

Or should I use another method? I need to insert this fullname in a script for insertion table data.

1
  • No need to downvote him. This is IMHO a fair question. In fact, he is asking for the schema information, but it seems he doesn't know the term. Upvote from my side, because this is a good question. Commented Nov 20, 2015 at 11:21

1 Answer 1

3

Try something like this:

SELECT 
    SchemaName = s.Name,
    TableName = t.Name,
    FullName = s.Name + '.' + t.Name
FROM 
    sys.tables t
INNER JOIN 
    sys.schemas s ON s.schema_id = t.schema_id

This should give you the schema, the table name, and the combined (schema).(table name) notation

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.