Viewing 15 posts - 166 through 180 (of 304 total)
Mike, a WHILE loop is not the best way to split a CSV.
Take a look at this article. It explains how a table of numbers replaces a loop.
November 13, 2008 at 2:14 pm
That's not going to work.
He needs two pivots.
One for TotalPackages and one for TotalCost.
November 13, 2008 at 7:16 am
Jeff Moden (11/12/2008)
Heh... you just didn't find what you're looking for... as with everything else, the answer is, "It Depends".
Obviously every case is going to be different. I was...
November 12, 2008 at 8:49 pm
Give this a spin. I want to make sure we're on the right track.
I know it's not perfect yet. I wasn't sure what you wanted to do with the column...
November 12, 2008 at 6:44 pm
JohnG (11/12/2008)
It just so happens that I'm coding a query for an application that was a prime candidate for a CTE as it had a complicated...
November 12, 2008 at 5:50 pm
I'm really busy at work today, I'll have to look at this tonight.
In the meanwhile, check out this article and see if you can't figure it out on your own.
http://sqlblogcasts.com/blogs/madhivanan/archive/2008/08/27/dynamic-pivot-in-sql-server-2005.aspx
The...
November 12, 2008 at 8:06 am
Jeff Moden (11/11/2008)
Thanks for the feedback... you sure you're all set?
Not really, Jeff. Thanks for asking. 🙂
What I'm really looking for is performance comparison between CTE and Derived Tables.
I haven't...
November 12, 2008 at 8:01 am
Brandie Tarvin (11/12/2008)
Okay, this code is officially going to be my new best friend. @=)Thanks, Ggraber! Cookies for you!
Yum! I'm hoping chocolate-chip :hehe:
November 12, 2008 at 7:55 am
Eric, it sounds as if you want to have variable number of columns in the output.
If that is the case you would need to make a dynamic pivot.
Let me know...
November 11, 2008 at 8:03 pm
This should get you what you need.
-- create a sample table to play with
DECLARE @SampleTable TABLE
(
UserName VARCHAR(20)
,TableName VARCHAR(20)
)
-- insert some data
INSERT INTO @SampleTable
SELECT 'JDoe', 'Table1'
UNION ALL...
November 11, 2008 at 7:55 pm
If you would post some sample DDL and DATA, it would be a lot easier to tackle your problem.
Read this article for some pointers: http://www.sqlservercentral.com/articles/Best+Practices/61537/
November 11, 2008 at 7:46 pm
This type of formatting is better done in your front end application.
November 11, 2008 at 7:43 pm
amdavis (11/10/2008)
Yes, what you described is what I am looking for... 🙂
It sounds like you need an OUTER JOIN.
For better answers, please follow the best practices outlined in the following...
November 11, 2008 at 7:38 pm
dglane (11/11/2008)
I believe the test administrator did not make a mistake and give me a PL/SQL test.
The test administrator is human and evidently made a mistake.
There is no such...
November 11, 2008 at 6:29 pm
You can create a dynamic pivot to do what you want.
This article contains a stored procedure which creates a dynamic pivot for you.
http://sqlblogcasts.com/blogs/madhivanan/archive/2008/08/27/dynamic-pivot-in-sql-server-2005.aspx
Or, if you post some sample DDL and...
November 11, 2008 at 6:24 pm
Viewing 15 posts - 166 through 180 (of 304 total)