SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Unsure of 70-461 prep "Flash Card" answer


Unsure of 70-461 prep "Flash Card" answer

Author
Message
Ryan Lambert
Ryan Lambert
SSC Journeyman
SSC Journeyman (77 reputation)SSC Journeyman (77 reputation)SSC Journeyman (77 reputation)SSC Journeyman (77 reputation)SSC Journeyman (77 reputation)SSC Journeyman (77 reputation)SSC Journeyman (77 reputation)SSC Journeyman (77 reputation)

Group: General Forum Members
Points: 77 Visits: 48
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
GilaMonster
GilaMonster
SSC Guru
SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)

Group: General Forum Members
Points: 86116 Visits: 45229
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, MVP, M.Sc (Comp Sci)
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


Ryan Lambert
Ryan Lambert
SSC Journeyman
SSC Journeyman (77 reputation)SSC Journeyman (77 reputation)SSC Journeyman (77 reputation)SSC Journeyman (77 reputation)SSC Journeyman (77 reputation)SSC Journeyman (77 reputation)SSC Journeyman (77 reputation)SSC Journeyman (77 reputation)

Group: General Forum Members
Points: 77 Visits: 48
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! :-D
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search