Link to home
Start Free TrialLog in
Avatar of Jhovyn Marcos
Jhovyn Marcos

asked on

PHP - How to insert data using sqlsrv on stored procedure?

Good Day! Do you have any basic tutorials or idea on "How to insert data using SQLSRV on stored procedure?"..I did search on this but no luck..
Please help me :(
Avatar of Nitin Sontakke
Nitin Sontakke
Flag of India image

Search:

using stored procedure to insert data sql server
What is SQLSRV? SQL Server?
If so, explain why do you need a stored procedure and not a simple INSERT command?
Here is a simple Stored Procedure that inserts data. Please provide more information
CREATE PROCEDURE dbo.InsertExample
       @data1 VARCHAR(30)      = NULL  , 
       @data2 VARCHAR(30)      = NULL
AS 
BEGIN 
     SET NOCOUNT ON 

     INSERT INTO dbo.SomeData
          ( 
            Data1                      ,
            Data2                  
          ) 
     VALUES 
          ( 
            @data1                     ,
            @data2    
          ) 
END 

GO

Open in new window

Avatar of Jhovyn Marcos
Jhovyn Marcos

ASKER

What is SQLSRV? SQL Server?
Yes sir..PHP to SQL via sqlsrv on stored procedure approach
Ok. Now the 2nd part of my question:
"explain why do you need a stored procedure and not a simple INSERT command? "
Thank you sir @Vitor Montalvão
"explain why do you need a stored procedure and not a simple INSERT command? "

Because I need to do some UPSERT(Update Insert) using sqlsrv wich is not availbale in ms sql...I do search some of these but it was very complex for me..Unlike mysql there is ON DUPLICATE KEY used for UPSERT...
ASKER CERTIFIED SOLUTION
Avatar of Vitor Montalvão
Vitor Montalvão
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial