Monday 17 April 2023

Paytmmoney signup coupon 500rs and free account opening charge(open free demat account)

 Paytmmoney coupon and promo code: open free demat account

Register paytm money with below and free account opening charges and get 500rs bonus

https://paytmmoney.page.link/QWaS3reeqrncchKb8


Saturday 3 October 2020

Avatar 2 subtitle

Avatar 2 is an upcoming movie directed by James Cameron. It is the second film in the Avatar franchise. 

Movie is planed yo release on 2021, die to covid-19 release date has not finalised yet. 

Meanwhile Avatar 3 production is going . 

Check the below link for Avatar 2 subtitle:
Link will be Updated here once movie is released. 


Friday 17 July 2020

Git on Windows: How do you set up a mergetool?

I've tried msysGit and Git on Cygwin. Both work just fine in and of themselves and both run gitk and git-gui perfectly.

Now how the heck do I configure a mergetool? (Vimdiff works on Cygwin, but preferably I would like something a little more user-friendly for some of our Windows-loving coworkers.)


Answers:


git mergetool is fully configurable so you can pretty much chose your favourite tool.

The full documentation is here: http://www.kernel.org/pub/software/scm/git/docs/git-mergetool.html

In brief, you can set a default mergetool by setting the user config variable merge.tool.

If the merge tool is one of the ones supported natively by it you just have to set mergetool.<tool>.path to the full path to the tool (replace <tool> by what you have configured merge.tool to be.

Otherwise, you can set mergetool.<tool>.cmd to a bit of shell to be eval'ed at runtime with the shell variables $BASE, $LOCAL, $REMOTE, $MERGED set to the appropriate files. You have to be a bit careful with the escaping whether you directly edit a config file or set the variable with the git config command.

Something like this should give the flavour of what you can do ('mymerge' is a fictional tool).

git config merge.tool mymerge
git config merge.mymerge.cmd 'mymerge.exe --base '$BASE' '$LOCAL' '$REMOTE' -o '$MERGED''

Once you've setup your favourite merge tool, it's simply a matter of running git mergetool whenever you have conflicts to resolve.

The p4merge tool from Perforce is a pretty good standalone merge tool.


Answers:


As already answered here (and here and here), mergetool is the command to configure this. For a nice graphical frontend I recommend kdiff3 (GPL).


Answers:


To follow-up on Charles Bailey's answer, here's my git setup that's using p4merge (free cross-platform 3way merge tool); tested on msys Git (Windows) install:

git config --global merge.tool p4merge
git config --global mergetool.p4merge.cmd 'p4merge.exe '$BASE' '$LOCAL' '$REMOTE' '$MERGED''

or, from a windows cmd.exe shell, the second line becomes :

git config --global mergetool.p4merge.cmd 'p4merge.exe '$BASE' '$LOCAL' '$REMOTE' '$MERGED''

The changes (relative to Charles Bailey):

  • added to global git config, i.e. valid for all git projects not just the current one
  • the custom tool config value resides in 'mergetool.[tool].cmd', not 'merge.[tool].cmd' (silly me, spent an hour troubleshooting why git kept complaining about non-existing tool)
  • added double quotes for all file names so that files with spaces can still be found by the merge tool (I tested this in msys Git from Powershell)
  • note that by default Perforce will add its installation dir to PATH, thus no need to specify full path to p4merge in the command

Download: http://www.perforce.com/product/components/perforce-visual-merge-and-diff-tools


EDIT (Feb 2014)

As pointed out by @Gregory Pakosz, latest msys git now 'natively' supports p4merge (tested on 1.8.5.2.msysgit.0).

You can display list of supported tools by running:

git mergetool --tool-help

You should see p4merge in either available or valid list. If not, please update your git.

If p4merge was listed as available, it is in your PATH and you only have to set merge.tool:

git config --global merge.tool p4merge

If it was listed as valid, you have to define mergetool.p4merge.path in addition to merge.tool:

git config --global mergetool.p4merge.path c:/Users/my-login/AppData/Local/Perforce/p4merge.exe
  • The above is an example path when p4merge was installed for the current user, not system-wide (does not need admin rights or UAC elevation)
  • Although ~ should expand to current user's home directory (so in theory the path should be ~/AppData/Local/Perforce/p4merge.exe), this did not work for me
  • Even better would have been to take advantage of an environment variable (e.g. $LOCALAPPDATA/Perforce/p4merge.exe), git does not seem to be expanding environment variables for paths (if you know how to get this working, please let me know or update this answer)

Answers:


I had to drop the extra quoting using msysGit on windows 7, not sure why.

git config --global merge.tool p4merge
git config --global mergetool.p4merge.cmd 'p4merge $BASE $LOCAL $REMOTE $MERGED'

Answers:


If you're doing this through cygwin, you may need to use cygpath:

git config --global merge.tool p4merge
git config --global mergetool.p4merge.cmd 'p4merge `cygpath -w $BASE` `cygpath -w $LOCAL` `cygpath -w $REMOTE` `cygpath -w $MERGED`'

Answers:


Under Cygwin, the only thing that worked for me is the following:

git config --global merge.tool myp4merge
git config --global mergetool.myp4merge.cmd 'p4merge.exe '$(cygpath -wla $BASE)' '$(cygpath -wla $LOCAL)' '$(cygpath -wla $REMOTE)' '$(cygpath -wla $MERGED)''
git config --global diff.tool myp4diff
git config --global difftool.myp4diff.cmd 'p4merge.exe '$(cygpath -wla $LOCAL)' '$(cygpath -wla $REMOTE)''

Also, I like to turn off the prompt message for difftool:

git config --global difftool.prompt false

Answers:


Bah, this finally worked for me (Windows 7 + Cygwin + TortoiseMerge):

In .git/config:

cmd = TortoiseMerge.exe /base:$(cygpath -d '$BASE') /theirs:$(cygpath -d '$REMOTE') /mine:$(cygpath -d '$LOCAL') /merged:$(cygpath -d '$MERGED')

Thanks to previous posters for the tip to use cygpath!


Answers:


I'm using Portable Git on WinXP (works a treat!), and needed to resolve a conflict that came up in branching. Of all the gui's I checked, KDiff3 proved to be the most transparent to use.

But I found the instructions I needed to get it working in Windows in this blog post, instructions which differ slightly from the other approaches listed here. It basically amounted to adding these lines to my .gitconfig file:

[merge]
    tool = kdiff3

[mergetool 'kdiff3']
    path = C:/YourPathToBinaryHere/KDiff3/kdiff3.exe
    keepBackup = false
    trustExitCode = false

Working nicely now!


Answers:


setting mergetool.p4merge.cmd will not work anymore since Git has started trying to support p4merge, see libexec/git-core/git-mergetool--lib.so we just need to specify the mergetool path for git,for example the p4merge:

git config --global mergetool.p4merge.path 'C:Program FilesPerforcep4merge.exe'
git config --global merge.tool p4merge

Then it will work.


Answers:


i use an app called WinMerge ( http://winmerge.org/ ) info from their manual ( http://manual.winmerge.org/CommandLine.html )

this is the bash script i use from the mergetool directive via .gitconfig

#!/bin/sh
# using winmerge with git
# replaces unix style null files with a newly created empty windows temp file

file1=$1
if [ '$file1' == '/dev/null' ] || [ '$file1' == '\.
ul' ] || [ ! -e '$file1' ]
    then 
       file1='/tmp/gitnull'
       `echo ''>$file1`
fi
file2=$2
if [ '$file2' == '/dev/null' ] || [ '$file2' == '\.
ul' ] || [ ! -e '$file2' ]
    then 
       file2='/tmp/gitnull'
       `echo ''>$file2`
fi
echo diff : $1 -- $2
'C:Program files (x86)WinMergeWinMergeU.exe' -e -ub -dl 'Base' -dr 'Mine' '$file1' '$file2'

basically the bash accounts for when the result of the diff in an empty file and creates a new temp file in the correct location.


Answers:


It seems that newer git versions support p4merge directly, so

git config --global merge.tool p4merge

should be all you need, if p4merge.exe is on your path. No need to set up cmd or path.


Answers:


For beyond compare on Windows 7

git config --global merge.tool bc3
git config --global mergetool.bc3.path 'C:Program Files (x86)Beyond Compare 3BCompare.exe'

Answers:


You may want to add these options too:

git config --global merge.tool p4mergetool
git config --global mergetool.p4merge.cmd 'p4merge $BASE $LOCAL $REMOTE $MERGED'
git config --global mergetool.p4mergetool.trustExitCode false
git config --global mergetool.keepBackup false

Also, I don't know why but the quoting and slash from Milan Gardian's answer screwed things up for me.


Answers:


If anyone wants to use gvim as their diff tool on TortoiseGit, then this is what you need to enter into the text input for the path to the external diff tool:

path	ogvim.exe -f -d -c 'wincmd R' -c 'wincmd R' -c 'wincmd h' -c 'wincmd J'

Answers:


To setup p4merge, installed using chocolatey on windows for both merge and diff, take a look here: https://gist.github.com/CamW/88e95ea8d9f0786d746a


Answers:


For IntelliJ IDEA (Community Edition) 3-way git mergetool configuration in Windows environment (~/.gitconfig)

Cygwin

[mergetool 'ideamerge']
     cmd = C:/Program\ Files\ \(x86\)/JetBrains/IntelliJ\ IDEA\ Community\ Edition\ 14.1.3/bin/idea.exe merge `cygpath -wa $LOCAL` `cygpath -wa $REMOTE` `cygpath -wa $BASE` `cygpath -wa $MERGED`
[merge]
     tool = ideamerge

Msys

[mergetool 'ideamerge']
cmd = '/c/Program\ Files\ \(x86\)/JetBrains/IntelliJ\ IDEA\ Community\ Edition\ 14.1.3/bin/idea.exe' merge `~/winpath.sh $LOCAL` `~/winpath.sh $REMOTE` `~/winpath.sh $BASE` `~/winpath.sh $MERGED`
[merge]
 tool = ideamerge

The ~/winpath.sh is to convert paths to Windows on msys and is taken from msys path conversion question on stackoverflow

#! /bin/sh                                                               

function wpath {                                                         
    if [ -z '$1' ]; then                                                 
        echo '$@'                                                        
    else                                                                 
        if [ -f '$1' ]; then                                             
            local dir=$(dirname '$1')                                    
            local fn=$(basename '$1')                                    
            echo '$(cd '$dir'; echo '$(pwd -W)/$fn')' | sed 's|/|\|g';  
        else                                                             
            if [ -d '$1' ]; then                                         
                echo '$(cd '$1'; pwd -W)' | sed 's|/|\|g';              
            else                                                         
                echo '$1' | sed 's|^/(.)/|1:\|g; s|/|\|g';          
            fi                                                           
        fi                                                               
    fi                                                                   
}                                                                        

wpath '$@' 

Answers:


If you're having problems opening p4merge from SourceTree look for you local configuration file named config under MyRepo.git and delete any merge configuration. In my case it was trying to open Meld which I just uninstalled


Answers:


I found two ways to configure 'SourceGear DiffMerge' as difftool and mergetool in github Windows.

The following commands in a Command Prompt window will update your .gitconfig to configure GIT use DiffMerge:

git config --global diff.tool diffmerge
git config --global difftool.diffmerge.cmd 'C:/Program Files/SourceGear/Common/DiffMerge/sgdm.exe  '$LOCAL' '$REMOTE''

git config --global merge.tool diffmerge
git config --global mergetool.diffmerge.cmd  'C:/Program Files/SourceGear/Common/DiffMerge/sgdm.exe  -merge  -result='$MERGED' '$LOCAL' '$BASE' '$REMOTE''

[OR]

Add the following lines to your .gitconfig. This file should be in your home directory in C:UsersUserName:

[diff]
    tool = diffmerge
[difftool 'diffmerge']
    cmd = C:/Program\ Files/SourceGear/Common/DiffMerge/sgdm.exe '$LOCAL' '$REMOTE'

[merge]
    tool = diffmerge
[mergetool 'diffmerge']
    trustExitCode = true
    cmd = C:/Program\ Files/SourceGear/Common/DiffMerge/sgdm.exe -merge -result='$MERGED' '$LOCAL' '$BASE' '$REMOTE'

Answers:


For kdiff3 you can use:

git config --global merge.tool kdiff3
git config --global mergetool.kdiff3.path "C:/Program Files/KDiff3/kdiff3.exe"
git config --global mergetool.kdiff3.trustExitCode false

git config --global diff.guitool kdiff3
git config --global difftool.kdiff3.path "C:/Program Files/KDiff3/kdiff3.exe"
git config --global difftool.kdiff3.trustExitCode false

Answers:


SVG Positioning

I'm having a play with SVG and am having a few problems with positioning. I have a series of shapes which are contained in the g group tag. I was hoping to use it like a container, so I could set its x position and then all the elements in that group would also move. But that doesn't seem to be possible.

  1. How do most people go about positioning a group of elements which you wish to move in tandem?
  2. Is there any concept of relative positioning? e.g. relative to its parent

Answers:


Everything in the g element is positioned relative to the current transform matrix.

To move the content, just put the transformation in the g element:

<g transform='translate(20,2.5) rotate(10)'>
    <rect x='0' y='0' width='60' height='10'/>
</g>

Links: Example from the SVG 1.1 spec


Answers:


As mentioned in the other comment, the transform attribute on the g element is what you want. Use transform='translate(x,y)' to move the g around and things within the g will move in relation to the g.


Answers:


There is a shorter alternative to the previous answer. SVG Elements can also be grouped by nesting svg elements:

<svg xmlns='http://www.w3.org/2000/svg'
  xmlns:xlink='http://www.w3.org/1999/xlink'>
  <svg x='10'>
    <rect x='10' y='10' height='100' width='100' style='stroke:#ff0000;fill: #0000ff'/>
  </svg>
  <svg x='200'>
    <rect x='10' y='10' height='100' width='100' style='stroke:#009900;fill: #00cc00'/>
  </svg>
</svg>

The two rectangles are identical (apart from the colors), but the parent svg elements have different x values.

See http://tutorials.jenkov.com/svg/svg-element.html.


Answers:


There are two ways to group multiple SVG shapes and position the group:

The first to use <g> with transform attribute as Aaron wrote. But you can't just use a x attribute on the <g> element.

The other way is to use nested <svg> element.

<svg id='parent'>
   <svg id='group1' x='10'>
      <!-- some shapes -->
   </svg>
</svg>

In this way, the #group1 svg is nested in #parent, and the x=10 is relative to the parent svg. However, you can't use transform attribute on <svg> element, which is quite the contrary of <g> element.


Answers:


I know this is old but neither an <svg> group tag nor a <g> fixed the issue I was facing. I needed to adjust the y position of a tag which also had animation on it.

The solution was to use both the and tag together:

<svg y="1190" x="235">
   <g class="light-1">
     <path />
   </g>
</svg>

Answers:


What is a stored procedure?

What is a 'stored procedure' and how do they work?

What is the make-up of a stored procedure (things each must have to be a stored procedure)?


Answers:


Generally, a stored procedure is a 'SQL Function.' They have:

-- a name
CREATE PROCEDURE spGetPerson
-- parameters
CREATE PROCEDURE spGetPerson(@PersonID int)
-- a body
CREATE PROCEDURE spGetPerson(@PersonID int)
AS
SELECT FirstName, LastName ....
FROM People
WHERE PersonID = @PersonID

This is a T-SQL focused example. Stored procedures can execute most SQL statements, return scalar and table-based values, and are considered to be more secure because they prevent SQL injection attacks.


Answers:


Stored procedures are a batch of SQL statements that can be executed in a couple of ways. Most major DBMs support stored procedures; however, not all do. You will need to verify with your particular DBMS help documentation for specifics. As I am most familiar with SQL Server I will use that as my samples.

To create a stored procedure the syntax is fairly simple:

CREATE PROCEDURE <owner>.<procedure name>

     <Param> <datatype>

AS

     <Body>

So for example:

CREATE PROCEDURE Users_GetUserInfo

    @login nvarchar(30)=null

AS

    SELECT * from [Users]
    WHERE ISNULL(@login,login)=login

A benefit of stored procedures is that you can centralize data access logic into a single place that is then easy for DBA's to optimize. Stored procedures also have a security benefit in that you can grant execute rights to a stored procedure but the user will not need to have read/write permissions on the underlying tables. This is a good first step against SQL injection.

Stored procedures do come with downsides, basically the maintenance associated with your basic CRUD operation. Let's say for each table you have an Insert, Update, Delete and at least one select based on the primary key, that means each table will have 4 procedures. Now take a decent size database of 400 tables, and you have 1600 procedures! And that's assuming you don't have duplicates which you probably will.

This is where using an ORM or some other method to auto generate your basic CRUD operations has a ton of merit.


Answers:


A stored procedure is a set of precompiled SQL statements that are used to perform a special task.

Example: If I have an Employee table

Employee ID  Name       Age  Mobile
---------------------------------------
001          Sidheswar  25   9938885469
002          Pritish    32   9178542436

First I am retrieving the Employee table:

Create Procedure Employee details
As
Begin
    Select * from Employee
End

To run the procedure on SQL Server:

Execute   Employee details

--- (Employee details is a user defined name, give a name as you want)

Then second, I am inserting the value into the Employee Table

Create Procedure employee_insert
    (@EmployeeID int, @Name Varchar(30), @Age int, @Mobile int)
As
Begin
    Insert Into Employee
    Values (@EmployeeID, @Name, @Age, @Mobile)
End

To run the parametrized procedure on SQL Server:

Execute employee_insert 003,’xyz’,27,1234567890

  --(Parameter size must be same as declared column size)

Example: @Name Varchar(30)

In the Employee table the Name column's size must be varchar(30).


Answers:


A stored procedure is mainly used to perform certain tasks on a database. For example

  • Get database result sets from some business logic on data.
  • Execute multiple database operations in a single call.
  • Used to migrate data from one table to another table.
  • Can be called for other programming languages, like Java.

Answers:


A stored procedure is used to retrieve data, modify data, and delete data in database table. You don't need to write a whole SQL command each time you want to insert, update or delete data in an SQL database.


Answers:


A stored procedure is a named collection of SQL statements and procedural logic i.e, compiled, verified and stored in the server database. A stored procedure is typically treated like other database objects and controlled through server security mechanism.


Answers:


A stored procedure is a group of SQL statements that has been created and stored in the database. A stored procedure will accept input parameters so that a single procedure can be used over the network by several clients using different input data. A stored procedures will reduce network traffic and increase the performance. If we modify a stored procedure all the clients will get the updated stored procedure.

Sample of creating a stored procedure

CREATE PROCEDURE test_display
AS
    SELECT FirstName, LastName
    FROM tb_test;

EXEC test_display;

Advantages of using stored procedures

  • A stored procedure allows modular programming.

    You can create the procedure once, store it in the database, and call it any number of times in your program.

  • A stored procedure allows faster execution.

    If the operation requires a large amount of SQL code that is performed repetitively, stored procedures can be faster. They are parsed and optimized when they are first executed, and a compiled version of the stored procedure remains in a memory cache for later use. This means the stored procedure does not need to be reparsed and reoptimized with each use, resulting in much faster execution times.

  • A stored procedure can reduce network traffic.

    An operation requiring hundreds of lines of Transact-SQL code can be performed through a single statement that executes the code in a procedure, rather than by sending hundreds of lines of code over the network.

  • Stored procedures provide better security to your data

    Users can be granted permission to execute a stored procedure even if they do not have permission to execute the procedure's statements directly.

    In SQL Server we have different types of stored procedures:

    • System stored procedures
    • User-defined stored procedures
    • Extended stored Procedures
  • System-stored procedures are stored in the master database and these start with a sp_ prefix. These procedures can be used to perform a variety of tasks to support SQL Server functions for external application calls in the system tables

    Example: sp_helptext [StoredProcedure_Name]

  • User-defined stored procedures are usually stored in a user database and are typically designed to complete the tasks in the user database. While coding these procedures don’t use the sp_ prefix because if we use the sp_ prefix first, it will check the master database, and then it comes to user defined database.

  • Extended stored procedures are the procedures that call functions from DLL files. Nowadays, extended stored procedures are deprecated for the reason it would be better to avoid using extended stored procedures.


Answers:


A stored procedure is nothing but a group of SQL statements compiled into a single execution plan.

  1. Create once time and call it n number of times
  2. It reduces the network traffic

Example: creating a stored procedure

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE GetEmployee
      @EmployeeID int = 0
AS
BEGIN
      SET NOCOUNT ON;

      SELECT FirstName, LastName, BirthDate, City, Country
      FROM Employees 
      WHERE EmployeeID = @EmployeeID
END
GO

Alter or modify a stored procedure:

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE GetEmployee
      @EmployeeID int = 0
AS
BEGIN
    SET NOCOUNT ON;

    SELECT FirstName, LastName, BirthDate, City, Country
    FROM Employees 
    WHERE EmployeeID = @EmployeeID
END
GO

Drop or delete a stored procedure:

DROP PROCEDURE GetEmployee

Answers:


Think of a situation like this,

  • You have a database with data.
  • There are a number of different applications needed to access that central database, and in the future some new applications too.
  • If you are going to insert the inline database queries to access the central database, inside each application's code individually, then probably you have to duplicate the same query again and again inside different applications' code.
  • In that kind of a situation, you can use stored procedures (SPs). With stored procedures, you are writing number of common queries (procedures) and store them with the central database.
  • Now the duplication of work will never happen as before and the data access and the maintenance will be done centrally.

NOTE:

  • In the above situation, you may wonder 'Why cannot we introduce a central data access server to interact with all the applications? Yes. That will be a possible alternative. But,
  • The main advantage with SPs over that approach is, unlike your data-access-code with inline queries, SPs are pre-compiled statements, so they will execute faster. And communication costs (over networks) will be at a minimum.
  • Opposite to that, SPs will add some more load to the database server. If that would be a concern according to the situation, a centralized data access server with inline queries will be a better choice.

Answers:


  • A stored procedure is a precompiled set of one or more SQL statements which perform some specific task.

  • A stored procedure should be executed stand alone using EXEC

  • A stored procedure can return multiple parameters

  • A stored procedure can be used to implement transact


Answers:


In a DBMS, a stored procedure is a set of SQL statements with an assigned name that's stored in the database in compiled form so that it can be shared by a number of programs.

The use of a stored procedure can be helpful in

  1. Providing a controlled access to data (end users can only enter or change data, but can't write procedures)

  2. Ensuring data integrity (data would be entered in a consistent manner) and

  3. Improves productivity (the statements of a stored procedure need to be written only once)


Answers:


'What is a stored procedure' is already answered in other posts here. What I will post is one less known way of using stored procedure. It is grouping stored procedures or numbering stored procedures.

Syntax Reference

enter image description here

; number as per this

An optional integer that is used to group procedures of the same name. These grouped procedures can be dropped together by using one DROP PROCEDURE statement

Example

CREATE Procedure FirstTest 
(
    @InputA INT
)
AS 
BEGIN
    SELECT 'A' + CONVERT(VARCHAR(10),@InputA)
END
GO

CREATE Procedure FirstTest;2
(
    @InputA INT,
    @InputB INT
)
AS 
BEGIN
    SELECT 'A' + CONVERT(VARCHAR(10),@InputA)+ CONVERT(VARCHAR(10),@InputB)
END
GO

Use

exec FirstTest 10
exec FirstTest;2 20,30

Result

enter image description here

Another Attempt

CREATE Procedure SecondTest;2
(
     @InputA INT,
    @InputB INT
)
AS 
BEGIN
    SELECT 'A' + CONVERT(VARCHAR(10),@InputA)+ CONVERT(VARCHAR(10),@InputB)
END
GO

Result

Msg 2730, Level 11, State 1, Procedure SecondTest, Line 1 [Batch Start Line 3] Cannot create procedure 'SecondTest' with a group number of 2 because a procedure with the same name and a group number of 1 does not currently exist in the database. Must execute CREATE PROCEDURE 'SecondTest';1 first.

References:

  1. CREATE PROCEDURE with the syntax for number
  2. Numbered Stored Procedures in SQL Server - techie-friendly.blogspot.com
  3. Grouping Stored Procedures - sqlmag

CAUTION

  1. After you group the procedures, you can't drop them individually.
  2. This feature may be removed in a future version of Microsoft SQL Server.

Answers:


for simple,

Stored Procedure are Stored Programs, A program/function stored into database.

Each stored program contains a body that consists of an SQL statement. This statement may be a compound statement made up of several statements separated by semicolon (;) characters.

CREATE PROCEDURE dorepeat(p1 INT)
BEGIN
  SET @x = 0;
  REPEAT SET @x = @x + 1; UNTIL @x > p1 END REPEAT;
END;

Answers:


Stored procedures in SQL Server can accept input parameters and return multiple values of output parameters; in SQL Server, stored procedures program statements to perform operations in the database and return a status value to a calling procedure or batch.

The benefits of using stored procedures in SQL Server

They allow modular programming. They allow faster execution. They can reduce network traffic. They can be used as a security mechanism.

Here is an example of a stored procedure that takes a parameter, executes a query and return a result. Specifically, the stored procedure accepts the BusinessEntityID as a parameter and uses this to match the primary key of the HumanResources.Employee table to return the requested employee.

> create procedure HumanResources.uspFindEmployee    `*<<<---Store procedure name`*
@businessEntityID                                     `<<<----parameter`
as
begin
SET NOCOUNT ON;
Select businessEntityId,              <<<----select statement to return one employee row
NationalIdNumber,
LoginID,
JobTitle,
HireData,
From HumanResources.Employee
where businessEntityId =@businessEntityId     <<<---parameter used as criteria
end

I learned this from essential.com...it is very useful.


Answers:


Stored Procedure will help you to make code in server.You can pass parameters and find output.

create procedure_name (para1 int,para2 decimal)
as
select * from TableName

Answers:


In Stored Procedures statements are written only once and reduces network traffic between clients and servers. We can also avoid Sql Injection Attacks.

  • Incase if you are using a third party program in your application for processing payments, here database should only expose the information it needed and activity that this third party has been authorized, by this we can achieve data confidentiality by setting permissions using Stored Procedures.
  • The updation of table should only done to the table it is targeting but it shouldn't update any other table, by which we can achieve data integrity using transaction processing and error handling.
  • If you want to return one or more items with a data type then it is better to use an output parameter.
  • In Stored Procedures, we use an output parameter for anything that needs to be returned. If you want to return only one item with only an integer data type then better use a return value. Actually the return value is only to inform success or failure of the Stored Procedure.

Answers:


Preface: In 1992 the SQL92 standard was created and was popularised by the Firebase DB. This standard introduced the 'Stored Procedure'.

** Passthrough Query: A string (normally concatenated programatically) that evaluates to a syntactically correct SQL statement, normally generated at the server tier (in languages such as PHP, Python, PERL etc). These statements are then passed onto the database. **

** Trigger: a piece of code designed to fire in response to a database event (typically a DML event) often used for enforcing data integrity. **

The best way to explain what a stored procedure is, is to explain the legacy way of executing DB logic (ie not using a Stored Procedure).

The legacy way of creating systems was to use a 'Passthrough Query' and possibly have triggers in the DB. Pretty much anyone who doesn't use Stored Procedures uses a thing call a 'Passthrough Query'

With the modern convention of Stored Procedures, triggers became legacy along with 'Passthrough Queries'.

The advantages of stored procedures are:

  1. They can be cached as the physical text of the Stored Procedure never changes.
  2. They have built in mechanisms against malicious SQL injection.
  3. Only the parameters need be checked for malicious SQL injection saving a lot of processor overhead.
  4. Most modern database engines actually compile Stored Procedures.
  5. They increase the degree of abstraction between tiers.
  6. They occur in the same process as the database allowing for greater optimisation and throughput.
  7. The entire workflow of the back end can be tested without client side code. (for example the Execute command in Transact SQL or the CALL command in MySQL).
  8. They can be used to enhance security because they can be leveraged to disallow the database to be accessed in a way that is inconsistent with how the system is designed to work. This is done through the database user permission mechanism. For example you can give users privileges only to EXECUTE Stored Procedures rather that SELECT, UPDATE etc privileges.
  9. No need for the DML layer associated with triggers. ** Using so much as one trigger, opens up a DML layer which is very processor intensive **

In summary when creating a new SQL database system there is no good excuse to use Passthrough Queries.

It is also noteworthy to mention that it is perfectly safe to use Stored Procedures in legacy systems that already uses triggers or Passthrough Queries; meaning that migration from legacy to Stored Procedures is very easy and such migration need not take a system down for long if at all.


Answers: