SQL Server security best practice

Security! This is the word comes in mind of every concerned person when it come...

Change the Collation Settings in MS SQL Server

This post will show you how to change the collation settings in MS SQL Server for specific database...

Resolve collation conflict

In this post I will show you how you can resolve collation conflict error...

Book: SQL Server 2008 High Availability

In this book I have tried to cover every single piece of information that might requires for installing and configuring SQL Server HA option like Clustering, Replication, Log Shipping and Database Mirroring...

Why to recompile Stored Procedure

Generally, we create views and stored procedures (proc here after) ...

Showing posts with label sp. Show all posts
Showing posts with label sp. Show all posts

9/29/2008

What is Stored Procedure and How to write Stored Procedure

Stored Procedure (SP, here after I will refer it as SP) is as its name indicates stored in a database . SP contains one or more then single T-SQL in it, and it is re-usable. The beauty or advantage of SP is, it will get complied and stored in Database, now when ever you required to run the T-SQL or bunch of T-SQL you don't need to write it and compile it again, just call that Stored Procedure(SP).
Whereas in case of individual T-SQL it will get complied every time you run them; so it helps to reduce your time writing T-SQL, it saves CPU and I/O times it would take to compile and to create execution plan.

There are some advantages of using SPs, they are:
1. You do not need to rewrite your T-SQL which you would required to run often
2. It will get complied and stored in DB, and this will helps you saving your CPU & I/O cycle. * In case if some modification is done in SP you would required to re-compile it.
3. Can accept parameter as input value and will return output based on it
4. You can call one SP in another
5. You can have security configured for them, i.e. can grant or deny exeecute permission for particular user/role/group
6. SP which has parameters can help you protect from SQL Injection Attack
7. SP will help you reduce your network round-trip and hence network traffic

Here are some basic instruction and input on how to write SP(s).
http://www.sql-server-performance.com/articles/dba/stored_procedures_basics_p1.aspx http://www.sql-server-performance.com/articles/dev/create_stored_procedures_tsql_p1.aspx

7/30/2007

hotfix or SP stops unexpectedly on SQL Server 2005

SQL Server 2005 Cluster which has many instances or contain many nodes may gives you error while upgrading it with hotfix or service pack; the simple procedure to update hotfix and sp has been given by Microsoft, read more on KB 936488

2/20/2007

Difference between Stored Procedure and Function (UDF)

Functions

  • can be used with Select statement

  • Not returning output parameter but returns Table variables

  • You can join UDF

  • Can not be used to change server configuration

  • Can not be used with XML FOR clause

  • Can not have transaction within function



Stored Procedure

  • have to use EXEC or EXECUTE

  • return output parameter

  • can create table but won’t return Table Variables

  • you can not join SP

  • can be used to change server configuration

  • can be used with XML FOR Clause

  • can have transaction within SP

New Version Microsoft SQL Server 2005 SP2 and Books On Line release

New version of SQL Server 2005 SP2 & SQL Server 2005 Books Online (BOL) released and now available at http://www.microsoft.com/sql/sp2.mspx