Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6856279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:51:54+00:00 2026-05-27T01:51:54+00:00

I’m working on a project where I need to analyze Apache logs using SSAS.

  • 0

I’m working on a project where I need to analyze Apache logs using SSAS. I’ve already loaded data into temporary table. I created dimension tables (primary key and attibute_name), empty fact table (foreign keys for each dimension table and fact_attribute) and created relations between them. Then I split data from that table into dimension tables using

INSERT INTO DimIP (IP) SELECT DISTINCT RemoteHostName FROM tmp

…and so on.

Now I need to populate Fact table with foreign keys, but I don’t have any idea how to do this with single query. I tried something like this:

INSERT INTO Facts (DimDateID, DimIPID, DimRefererID, DimRequestID, DimStatusCodeID, DimUserAgentID)
SELECT DimDate.ID WHERE (DimDate.Data = tmp.DateTime)
SELECT DimIP.ID WHERE (DimIP.IP = tmp.RemoteHostName)
SELECT DimReferer.ID WHERE (DimReferer.Referer = tmp.Referer)
SELECT DimRequest.ID WHERE (DimRequest.Request = tmp.Request)
SELECT DimStatusCode.ID WHERE (DimStatusCode.StatusCode = tmp.StatusCode)
SELECT DimUserAgent.ID WHERE (DimUserAgent.UserAgent = tmp.UserAgent)

But it doesn’t work (it says insert list contains fewer items than select list), probably I can’t use such syntax.

I tried doing it one by one, like this:

INSERT INTO Facts (DimDateID)
SELECT DimDate.ID WHERE (DimDate.Data = tmp.DateTime)

But sometimes it says that other column can’t be NULL (ex. DimUserAgentID), so query fails, sometimes it executes query, says “806000 rows affected” but nothing is inserted.

I will appreciate your help, cause I already ripped half of my hair from my head and don’t know how the way to populate fact table with foreign keys from dimension tables.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:51:55+00:00Added an answer on May 27, 2026 at 1:51 am

    I believe what you need to do is reference those other tables in your query. Below I use the tmp as the main driver of the query and then attempted to look up the resulting ID based on the logic you provided. Those lookups are via LEFT OUTER JOINs which implies the relationship may not be there in which case NULL will go into your fact table. If you’d rather have the row filtered out of hitting the fact table, substitute an INNER JOIN for all of the occurrences. I also assumed your tables were all in dbo schema.

    INSERT INTO
        dbo.Facts 
    (
        DimDateID
    ,   DimIPID
    ,   DimRefererID
    ,   DimRequestID
    ,   DimStatusCodeID
    ,   DimUserAgentID
    )
    SELECT
        DimDate.ID 
    ,   DimIP.ID 
    ,   DimReferer.ID
    ,   DimRequest.ID 
    ,   DimStatusCode.ID
    ,   DimUserAgent.ID 
    FROM
        TMP T
        LEFT OUTER JOIN
            dbo.DimDate 
            ON DimDate.Data = T.DateTime
        LEFT OUTER JOIN
            dbo.DimIP
            ON DimIP.IP = T.RemoteHostName
        LEFT OUTER JOIN
            dbo.DimReferer
            ON DimReferer.Referer = T.Referer
        LEFT OUTER JOIN
            dbo.DimRequest
            ON DimRequest.Request = T.Request
        LEFT OUTER JOIN
            dbo.DimStatusCode
            ON DimStatusCode.StatusCode = T.StatusCode
        LEFT OUTER JOIN
            dbo.DimUserAgent
            ON DimUserAgent.UserAgent = T.UserAgent
    

    Finally, it seems you’re missing something measurable, unless you’re just counting rows in the Facts table.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have thousands of HTML files to process using Groovy/Java and I need to
That's pretty much it. I'm using Nokogiri to scrape a web page what has
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I need to clean up various Word 'smart' characters in user input, including but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.