Interview Question for Quality Assurance Engineers

Country: India

Comment hidden because of low score. Click to expand.
of 0 vote

Column names are only guaranteed to be unique within the context of a particular database, schema, and table, so the operation you're asking for is not well-defined.

If you happen to know for a fact that the column you want has a name that is unique throughout all the databases, schemas, and tables on a particular machine, you should be able to run a query on the system metadata to determine the name of the database and table containing the column. For example, in T-SQL you could try running the following query on each database where the column could be located:

select + '.' + t.Name,
from sys.columns c
join sys.tables t
on t.object_id = c.object_id
and = @VariableHoldingYourColumnName
join sys.schemas s
on t.schema_id = s.schema_id

This should give you the full name of the table containing the column. You can then dynamically build a query that queries this table.

If you don't even know the database name, you'd have to use a temp table to hold the results while using a cursor to iterate over the databases.

- eugene.yarovoi June 08, 2014 | Flag Reply

Add a Comment

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.


is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More


CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More