• andrexcobar (3/14/2014)


    Sean Lange (3/14/2014)


    First of all I want to confirm that you are actually using sql 2000.

    I can't use CTE, TEMP Tables or SPs, I have to resolve this in the SELECT query (I can use subqueries).

    This is a rather strange requirement. If you are truly using sql 2000 then I understand the restriction on cte since they didn't exist yet. No temp table or SP sounds like an artificial restriction that is often found in homework assignments.

    Hi Sean,

    First all all: thanks for your quick reply.

    The problem is that I have to place the SQL query in the report interface of Business Object. That's why I can't use SPs, CTE or Temp Tables.

    In SSRS, You can work with CTEs and Temp Tables. But in Business Objects you can only run one query. You can use subqueries and the UNION operator, and you can build a huge SQL query that will run, but you can't create multiple queries that will feed one last query.

    I'm working with SQL Server 2005. And also, I don't have permissions to modify the DB. I can only run SELECT queries. The DBA can do all the operations.

    Ahh gotcha. I wanted to be sure because you posted in the sql 2000 forum. Since you are working in 2005 you can very easily do this. Take a look at my signature about splitting strings.

    Your query will end up something like this.

    SELECT s.Item as Code,

    @PromptFromBusinessObjects AS ValuesSelected

    FROM Table

    inner join dbo.DelimitedSplit8K(@PromptFromBusinessObjects, ',') s on s.Item = Table.Code

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/