Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Unsure of 70-461 prep "Flash Card" answer Expand / Collapse
Author
Message
Posted Tuesday, February 25, 2014 6:15 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, September 4, 2014 8:11 AM
Points: 2, Visits: 5
I have been working with SQL Server (2005, 2008R2 & 2012) for about six years now and have recently decided that I should start down the path of earning certifications. Part of what is available to me at work is a CBT Nuggets license, which has been wonderful, and I am currently using the Self Test feature, also great. I have been going through the flash cards focusing on the areas I need work on and I have a question I am a bit stumped with.

The actual question along with their answer is below. My question is: Why is "a stored procedure" the object type that fits the description? A stored procedure can do many things, but filtering on a primary key of a table is very rarely the main application for them. Also, why wouldn't "a view" be a possible answer? I can define a view and filter on the tables primary key, would that not be correct? Am I missing something here? Maybe I'm just not thinking about it from the right angle....

Question:
What object type is used to return certain columns from a table based on the primary key column of that table?

Answer:
A stored procedure

Thanks for your help,
Ryan
Post #1545187
Posted Wednesday, February 26, 2014 12:39 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 4:16 AM
Points: 40,194, Visits: 36,599
Weird question.

I think the key here is 'return certain columns', not return certain rows. A view or function can indeed return different rows based on a pk value, but to return different columns based on a pk value would require dynamic SQL, which neither a view nor a function can use.

That said, if I saw code from one of my devs which used a table's pk value to decide which columns a procedure should return, they'd be taking their code back to the drawing board, it's a pretty odd thing to do.



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1545233
Posted Wednesday, February 26, 2014 8:08 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, September 4, 2014 8:11 AM
Points: 2, Visits: 5
Ah, thanks, I was thinking of rows, not columns. I see what you're saying and that does seem like an odd thing to do.

I'll mark that as something to remember yet never use!

Post #1545422
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse