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
 New to SQL Server Programming
 difference between inline query and stored proc?

Author  Topic 

friend
Starting Member

6 Posts

Posted - 2011-08-10 : 03:55:23
Hi all,

I am working on .net application, in my application in some places i have written query and in some places i have used stored proc.

what is the difference between inline query and stored proc.

Regards

Friend

theboyholty
Posting Yak Master

226 Posts

Posted - 2011-08-10 : 04:22:53
First of all I think you may be misusing the term 'inline query'. I think you're asking if there's a difference between using a stored proc and simply typing the query into your application code.

Essentially there's little difference. I don't think it affects performance particularly (though no doubt someone will correct me if I am wrong), but the main issues will be of maintainability and security.

If you need to change or tweak a query, its much easier to do this if its in a stored proc, and it also means you won't need to re-deploy your application code etc. In terms of security, you could expose yourself to SQL injection attacks if you use embedded code.

There are some people who will say ALWAYS USE STORED PROCS, and some that argue otherwise. Personally, I would use them for pretty much everything.

You could find that you have inadvertantly started a big argument with this question, perhaps one a bit like this one here (hope the link works). [url]http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=123776[/url]

---------------------------------------------------------------------------------
http://www.mannyroadend.co.uk A Bury FC supporters website and forum
Go to Top of Page

jcelko
Esteemed SQL Purist

547 Posts

Posted - 2011-08-10 : 11:17:06
Use the stored procedures. They are neat, clean and will protect you from SQL Injection. Since they are in the database, they can be optimized and use cached results.

--CELKO--
Books in Celko Series for Morgan-Kaufmann Publishing
Analytics and OLAP in SQL
Data and Databases: Concepts in Practice
Data, Measurements and Standards in SQL
SQL for Smarties
SQL Programming Style
SQL Puzzles and Answers
Thinking in Sets
Trees and Hierarchies in SQL
Go to Top of Page

blindman
Master Smack Fu Yak Hacker

2365 Posts

Posted - 2011-08-12 : 10:54:08
Neat and clean, yes, but merely implementing stored procedures will not protect you from SQL Injection attacks.

________________________________________________
If it is not practically useful, then it is practically useless.
________________________________________________
Go to Top of Page
   

- Advertisement -