Re: how to join dynamic SQL results with another query



CELKO, You've given me good advice in the past, but I don't see what
advice you're offering here. I agree that dynamic SQL should be the
last option, but I disagree that it means the schema is bad. I'll
entertain the possibility that I could just be a bad SQL programmer if
you can tell me how to write a pivot query that will dynamically
decide column names in the results as the months pass. In other
words, "Month 1," Month 2," and "Month 3" aren't viable column names;
the last three full months are valid column names, but how to set them
in a pivot query? I'm using this page as a guide: <a href="http://
www.tsqltutorials.com/pivot.php">http://www.tsqltutorials.com/pivot.php</a>.
What is the correct approach, since my approach is wrong?
.



Relevant Pages

  • Re: how to join dynamic SQL results with another query
    ... the joins in the pivot query from the start--worked terrifically. ... was pulling out of a customer activity table when I should have been ... pulling static info from the customer table itself. ... advice has helped me before, but this time I can hardly consider his ...
    (microsoft.public.sqlserver.programming)
  • Re: Dynamic columns for Pivot Query
    ... Without using Dynamic SQL like EXEC @sqlString ... ... in a pivot query? ... WHERE sd.DateAddressed Between @RangeStart And @RangeEnd ... FROM ServiceCallsMonth SCM1 ...
    (microsoft.public.sqlserver.programming)
  • Dynamic columns for Pivot Query
    ... Without using Dynamic SQL like EXEC @sqlString ... ... in a pivot query? ... inner join ServiceProblems_V2 sp ON sd.ComplaintID = sp.ProblemID ... ServiceCalls ...
    (microsoft.public.sqlserver.programming)
  • Re: Help with performance of sql construct - reduced version
    ... stupid of me - that should do the trick then. ... listened to your advice and build something in dynamic sql to populate a ...
    (microsoft.public.sqlserver.programming)