Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 Database Design and Application Architecture
 Queries, Views, Procedures : Best practice

Author  Topic 

DCZ
Starting Member

3 Posts

Posted - 2007-11-23 : 04:23:43
Hello all,

I'm looking for a best practice.
Let's say you have a report that contains out of 3 queries.

How are you going to create the report and why?

1. Just use "select * from table where p1= value" in your report
2. Save the query in your db as a view and use the view in your report
3. Create a procedure that contains all 3 queries. And use the procedure with some parameters in your report?

Kr
Karel.

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2007-11-23 : 04:38:07
Hi Karel,
Is your report a Reporting Services report?

Sprocs are generally the best practice especially for web based reporting - if your web app is written correctly then making use of sprocs will minimise security concerns like sql injection etc.

Reporting Services which is also web based - handles sprocs pretty well too.

"Select * from" type code ie freehand sql is not seen as a best practice.


Duane.
Go to Top of Page

DCZ
Starting Member

3 Posts

Posted - 2007-11-23 : 08:14:16
And why procs and not views?
Go to Top of Page

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2007-11-23 : 08:17:48
Cos if you use a view - you still have to use "Select Colnames from view" and as I said earlier, this can open you up to more possible security risks, thats just one reason, besides sprocs can be parameterised which you can't do with views.

Duane.
Go to Top of Page

DCZ
Starting Member

3 Posts

Posted - 2007-11-26 : 02:58:25
quote:
Originally posted by ditch

Cos if you use a view - you still have to use "Select Colnames from view" and as I said earlier, this can open you up to more possible security risks, thats just one reason, besides sprocs can be parameterised which you can't do with views.

Duane.




Hmm ok,

Is the use of procs more server intensive then the use of views?

Go to Top of Page

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2007-11-26 : 04:23:52
There is probably not much difference, the best way to know for sure is by testing it out.


Duane.
Go to Top of Page
   

- Advertisement -