Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    21

    Unhappy Sql statement for SPSS syntax editor

    HI does anyone know sql to import certain database fields into spss?

    It says that I am missing an operator before the frist field, can anyone help me?

    To bring the whole db I was able to do, but when I started to just select a few I really needed, it started to get wierd on me .

    Here's what I have:


    GET DATA
    /TYPE = ODBC
    /CONNECT = "DSN=MS Access Database;"
    "DBQ=C:\db1.mdb;"
    /SQL = "SELECT ZIP Code, Zip+4 Code, Census Tract Number, Census Block Number, From Latitude, From Longitude, To Latitude, To Longitude, Multiple Match Indicator FROM [001]".
    CACHE.
    EXECUTE.


    My output editor says this when I run it:

    >Warning. Command name: GET DATA
    >SQLExecDirect failed :[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'ZIP Code'.


    >Error # 105. Command name: EXECUTE
    >This command is not valid before a working file has been defined.
    >This command not executed.


    HELP ME PLZZZ!

  2. #2
    Join Date
    Sep 2003
    Posts
    1
    GET DATA
    /TYPE = ODBC
    /CONNECT = "DSN=MS Access Database;"
    "DBQ=C:\db1.mdb;"
    /SQL = "SELECT ZIP Code, Zip+4 Code, Census Tract Number, Census Block Number, From Latitude, From Longitude, To Latitude, To Longitude, Multiple Match Indicator FROM [001]".
    CACHE.
    EXECUTE.

    You need to put quotes around variables that contain a space, though realistically you shouldn't use variables that contain spaces in the first place.
    so your code should read.

    GET DATA
    /TYPE = ODBC
    /CONNECT = "DSN=MS Access Database;"
    "DBQ=C:\db1.mdb;"
    /SQL = "SELECT 'ZIP Code', 'Zip+4 Code', 'Census Tract Number', 'Census Block Number', 'From Latitude', 'From Longitude', 'To Latitude', 'To Longitude', 'Multiple Match Indicator' FROM '[001]'".
    CACHE.
    EXECUTE.

    Do you really have a table called [001] or is the table called 001 and you are thinking in access terms, you would want to reference it as '001' I beliave.


    Sorry this reply is so belated, just ran into your question while searching for spss sql info.

  3. #3
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    21
    thanx i will try that


    thanx so much


    -Trini

Posting Permissions

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