Subselect problem in SQLCE!!!

  • The following code must return a row number of the selected Project, the id2 (Parameter) is the ID of the selected Project.

    The query is working correct under SQL Server 2005 but not on the compact version.

    I get this error:

    There was an error parsing the query. [ Token line number = 1,Token line offset = 10,Token in error = SELECT ]

    Can someone help me find a correct solution.

    SELECT

    (

    SELECT COUNT (*) FROM

    (

    SELECT

    Project.id AS id ,

    Project.name AS name

    FROM Project

    WHERE

    (Project.id = @id OR @id IS NULL )

    AND ( Project.name LIKE '%'+ @name + '%' OR @name IS NULL )

    ) Temp1

    WHERE

    ((Temp2.name > Temp1.name))

    ) AS SORT_ORDER

    FROM

    (SELECT

    Project.id AS id ,

    Project.name AS name

    FROM Project

    WHERE

    ( Project.id = @id OR @id IS NULL )

    AND ( Project.name LIKE '%'+ @name + '%' OR @name IS NULL )

    ) Temp2

    WHERE (Temp2.id = @id2)

  • Can you post the DDL and sample data so we can possibly try to duplicate the error and test any solution?

  • An example is added in attatchment.

    Example:

    A Listbox is populated from Database on Window_Loaded.

    When ListboxItem is clicked -> the Guid of the selected object is used in a Query, to get the current position (in the database) of the selected row.

    In the Query a Subselect is used and throws an error in SQL CE (Compact).

    Can someone help me with a good solution.

    PS: SQL Server 2005 Compact Edition must be installed (v3.5 SP1)

  • This is one of the many things we cannot do in SQL Server CE. Nested SELECTs are legal in SQL Server (including Express), but not in SSCE.

  • is there any other way of reaching the same result for:

    ex:

    SELECT rs1, rs2, (select count(*) from table2) FROM TABLE1

    ?

    Thanks

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply