Jump to content

Unique Identifiers & Select Queries to MSSQL in PHP


intergroove

Recommended Posts

Help.

This has been bugging me for a couple of days now:

I am writing a script to regularly transfer data from a MYSQL db to a MSSQL.

Being new to MSSQL I'm a bit freaked out about the UNIQUEIDENTIFER (UI) system.

I have to INSERT data to a table where I need the UI for items from 2 other tables. This negates my ability to use a JOIN. So I need to grab the UI from within PHP and the reference the variable in the query.

To test this I am using a simple SELECT:

First I need to get the UI:
SELECT CAST(CATALOGGUID as VARCHAR(36)) as CGUID FROM CATALOG WHERE CATALOGNAME='TESTCATALOG'

I then assign CGUID to $CGUID

The problem query is now:
SELECT * FROM CATALOG WHERE CATALOGGUID = '".$CGUID."';

I have tried wrapping the string with curly brackets { & }. But it won't work.

I copy the query and put it into SQL QUERY ANALYZER then it works perfectly. The problem is just from inside PHP.

Has anybody else had this problem? or knows of a solution?

The server OS is Windows 2003 Server. PHP is 5+.


Thanx in advance...
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.