0

I have below stored procedure in Sql server and I need to convert into My sql..Please help me how i can do that?

CREATE PROCEDURE [dbo].[Getsomething_data]  
    -- Add the parameters for the stored procedure here
    @UserID nvarchar(250),-- from 10 to 14
    @Limit varchar(10),
    @Offset varchar(10),
    @Fields varchar(max)
AS
BEGIN
declare @dynamicQuery as varchar(4000)

    set @dynamicQuery = '
    with cte
    as
    (
    SELECT  top (10000000000000)  ROW_NUMBER() over(Order By CreateddateTime Desc) as rownum ,' + @Fields + '
    FROM         SMSDetails where UserID =''' + @UserID + ''' and IsDeleted=0 and TypeOfMassage=''S'' 
    )
    select * from cte where (rownum between ' + @Offset +' and ' + @Limit + ')'
exec(@dynamicQuery)
Kappa
  • 1,007
  • 1
  • 16
  • 30
  • did you to try search for SQL to MySQL? http://stackoverflow.com/questions/6584093/conversion-from-microsoft-sql-server-to-mysql – Matthew Shine Jan 17 '14 at 17:32
  • MySQL does not support the SQL Server `WITH` clause (CTE - Common Table Expressions). See this answer for how to work around that in your code migration. http://stackoverflow.com/a/1382618/325521 – Shiva Jan 17 '14 at 17:32
  • Then just add in pagination to your query and you're all set. – tommy_o Jan 17 '14 at 22:55

0 Answers0