We help IT Professionals succeed at work.
Get Started

create stored proc in sql from mysql

151 Views
Last Modified: 2015-03-04
I have a mysql stored procedure I want to turn into a sql stored procedure
how would it be done?
CREATE PROCEDURE fill_calendar(mystart_date DATE, end_date DATE)
BEGIN
  DECLARE crt_date DATE;
  DECLARE Yr INT;
  DECLARE Mo INT;
  SET crt_date = start_date;
  SET Yr= Year(mystart_date);
  SET Mo= Month(mystart_date);
  
  WHILE crt_date < end_date DO
  
    INSERT INTO calendar(Yr,Mo) VALUES(Yr,Mo);
    
    SET crt_date = DATE_ADD(crt_date, INTERVAL 1 MONTH);
    SET Yr= Year(crt_date);
  SET Mo= Month(crt_date);
  END WHILE;

Open in new window

Comment
Watch Question
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE