DEV Community

Discussion on: Comparing SQL Views and Stored Procedures

Collapse
 
j1cordingley profile image
JCord

I rarely create views because when joining table you might have to join with table hints, or the view has more then you need. On top of this you can't use parameters.

You can create a table function that is like a SP but you call it like a table or view. And as a extra bonus you can use a cross/outer apply with a table function with a parameter and use a column from the table being connected to.

But if you have to create a SP and need to join the data you can always prefix a insert into infront of the exec command.

I would recommend when possible use with SCHEMABINDING to help with having a change brake your view or SP