SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Oct 2002
    Posts
    146
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    MySQL to Microsoft SQL Server

    I am making a site for a society at my university. I'm writing it in PHP as usual, and at the moment am testing it using MySQL. However, the servers it'll be deployed on use only Microsoft SQL, not MySQL. I was wondering what changes I'd have to make to my queries to get it to run.

    (I'm using database abstraction, so I won't have to change the actual PHP commands...)

    Any ideas?

    Amorya
    KickRSS - free web-based RSS aggregator.

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,016
    Mentioned
    53 Post(s)
    Tagged
    2 Thread(s)
    you [strike]will[/strike] may have to change [strike]all[/strike] many of the sql statements
    r937.com | rudy.ca | Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Zealot
    Join Date
    Oct 2002
    Posts
    146
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can no-one give me a clue as to where they differ in SQL syntax?
    KickRSS - free web-based RSS aggregator.

  4. #4
    SitePoint Addict StephenBauer's Avatar
    Join Date
    Apr 2004
    Location
    USA
    Posts
    263
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    For just checking syntax difference (hopefully there are not too many for the most common SQL commands), you could take the various SQL commands from mySQL and paste them into an MS SQL Server Query Analyzer window and then instead of "running" them, "parse" them. It will spit out errors. Correct some of them and retry. This should work even if you do not have the DB schema setup yet...I just tried parsing:

    select * from bob where candy = 1

    in the [master] database and it returned that all was okay (this means that even though the table [bob] and the column [candy] do not exist, it still parsed the SQL for syntax errors).
    I forced an error (changed "from" to "fromd" and it found it).

    Now onto the semantical differences!

    This technique will highlight constructs that are not the same between the two, so it will help some here too. I cannot say much in this regard as I usually only use mySQL to host security databases for vpopmail and other Linux services that rock.



    Quote Originally Posted by Amorya
    Can no-one give me a clue as to where they differ in SQL syntax?
    Last edited by StephenBauer; May 26, 2004 at 11:21.

  5. #5
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,016
    Mentioned
    53 Post(s)
    Tagged
    2 Thread(s)
    come on, amorya, it's not that hard

    they differ in countless ways, some overt, some subtle, some with regards to standards support, in the different proprietary syntax variations they have, even something as simple as string concatenation, e.g. sql server says foo + bar while mysql says concat(foo,bar)

    if you plan to support both databases, you will just have to roll up your sleeves and get down and nasty with the syntax yourself

    nobody can possibly tell you where your queries will be different if we can't see them

    and no, please don't list them all

    r937.com | rudy.ca | Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •