question

AakashData avatar image
AakashData asked

How would i use stored techniqes in SQL?

How would i use stored techniqes in SQL?

sqlstored-procedures
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

bansalhimani avatar image
bansalhimani answered

A stored procedure in SQL is basically statements that are collected that are used as the function. We can make these put away procedure already before using it and can execute these them wherever we require and furthermore apply some contingent rationale to it. Put away systems are additionally used to lessen arrange movement and enhance the execution.
Syntax:

  1. CREATE Technique Technique_Name
  2. (
  3. /Parameters
  4. )
  5. AS
  6. Start
  7. SQL statements in stored methods to refresh/recover records
  8. END
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Solo avatar image
Solo answered

1. Use SET NOCOUNT ON;

2. Use fully qualified procedure name;

3. sp_executesql instead of Execute for dynamic queries;

4. Using IF EXISTS AND SELECT;

5. Avoid naming user stored procedure as sp_procedurename;

6. Use set based queries wherever possible;

7. Keep transaction short and crisp.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.