Reporting Services with multiple companies

kfuglsangkfuglsang Member Posts: 26
edited 2008-10-27 in SQL General
Hi all,

I'm doing a few experiments with Reporting Services. I've stumbled upon a question regarding multiple companies in one database.

How would I, dynamically, create a SELECT statement that would give me e.g. all records from T79 "Company Information"?

Something like:
SELECT * FROM [*$Company Information]

Thanks in advance.

Best regards
Kenneth Fuglsang
Denmark

Comments

  • ara3nara3n Member Posts: 9,256
    Create a View that combines (outer Join) the tables in each company and adds a new column Company Name to the column.

    That way when you run the query you can set a where clause

    Where CompanyName = UserFilter
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • kfuglsangkfuglsang Member Posts: 26
    Hm yeah, I had that thought. I was hoping for something easier, as I have quite a lot of companies spread throughout several databases.
  • WaldoWaldo Member Posts: 3,412
    In this postI talk about a way to do it by Stored Procedures. May be it can help ...

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • kfuglsangkfuglsang Member Posts: 26
    Great Waldo. I think I should be able to get something working with the concept described on your blog \:D/
  • WaldoWaldo Member Posts: 3,412
    8)
    Great. Let us know how you solved it :).

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • kfuglsangkfuglsang Member Posts: 26
    Will do. Hope I'll get some time to give it a try today.
  • mstallmannmstallmann Member Posts: 138
    Did you ever sucessfully implement dynamic table names with reporting services?
  • kfuglsangkfuglsang Member Posts: 26
    I managed to get a test working with a stored procedure that on-the-fly created a view for my tables.
    The view consisted of a SELECT string with UNION ALL in it.
  • WaldoWaldo Member Posts: 3,412
    kfuglsang wrote:
    I managed to get a test working with a stored procedure that on-the-fly created a view for my tables.
    The view consisted of a SELECT string with UNION ALL in it.

    That's indeed the main idea that I implemented... .
    But I didn't create a view to just do a SELECT on it. My view was necessary as some kind of company-related distinct.
    I just build my SELECT with UNION in my Stored Procedure, and execute that SQLString at the end of the SP.

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • mstallmannmstallmann Member Posts: 138
    Can you provide a sample SQL statement that might communicate specifically what you did?
  • WaldoWaldo Member Posts: 3,412
    I would refer you to my blog, but it's offline at the moment, ... .

    Just bookmark this :).

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
Sign In or Register to comment.