Forum Replies Created

Viewing 15 posts - 706 through 720 (of 1,473 total)

  • RE: Creating custom pivot-like output against 2 or more tables

    The good thing about the above example is most of the pieces are derived tables that can be run individually so you can see what they're doing.

    This relies...

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • RE: Creating custom pivot-like output against 2 or more tables

    It was, sorry, I missed a section when I copy/pasted. It's there now.

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • RE: Creating custom pivot-like output against 2 or more tables

    I added an integer field named PairID to your data, each pair increments the int by 1. Here is some code to generate that result set. This wasn't...

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • RE: Creating custom pivot-like output against 2 or more tables

    Much better, thank you.

    Now, before I make this thing needlessly complex, is there anything that can link an Orig value to a New Value beyond the fact that they're sequential?...

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • RE: Show data with decimal places

    SELECT CAST(5 AS DECIMAL(9,2))

    SELECT CAST(3.2 AS DECIMAL(9,2))

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • RE: parameters in openrowset

    Ugh, having so many issues posting lately. I wonder if it's just me.

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • RE: parameters in openrowset

    Not real familiar with openrowset, but ordinarily in a situation like this I'd sugest dynamic sql to solve this issue.

    Something like:

    declare @sql varchar(500),

    @path varchar(50),

    @sheet varchar(50)

    set @path...

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • RE: Creating custom pivot-like output against 2 or more tables

    Please see the link in my signature about how to post sample data.

    I'm making many assumptions here, but you could possibly do something along the lines of

    SELECT 'Table1' TableName, Field1,...

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • RE: Must declare the scalar variable '%s'.

    New2SQL (9/9/2009)


    Hi All,

    Declare @table1 as Table(cID bigint,Uid bigint)

    insert into @table1 select 23,40

    insert into @table1 select 20,50

    insert into @table1 select 23,60

    declare @groupid nvarchar(10)

    set @groupid = '40,50'

    declare @sql nvarchar(1000)

    set @sql...

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • RE: SQL SubQuery Help

    Jeff Moden (9/9/2009)


    Like this...

    SELECT e.*

    FROM dbo.Employees e

    INNER JOIN dbo.Students s

    ON e.Name = s.Name

    AND e.Age...

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • RE: Months between two dates

    Yeah, Tally table is a viable option here.

    Here's a couple hints to get you started.

    SELECT DATEADD(mm,N,StartDate)

    WHERE DATEADD(mm,N,StartDate) < EndDate

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • RE: Months between two dates

    It depends on how exactly you need the output. If you just need to see if a date is between the start and end date, it's a simple check....

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • RE: SQL SubQuery Help

    [Edit] Read that a bit too quickly the first time.

    The way you are doing it should work. Perhaps if you share your end goal, we can come up...

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • RE: computed column from date range

    My guess is that writing your query to use correlated subqueries in that fashion is going to be obnoxiously slow.

    You might consider restructuring that query to be something like this:

    SELECT...

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • RE: Calling a SP in a SQL Statement

    You can insert the results into a table and then work with the table.

    CREATE TABLE x(

    the fields and datatypes your sp returns...

    )

    INSERT INTO x(fields)

    EXEC getservicecontractsinfo 'ALL', '2009-09-01', '2009-09-30'

    SELECT ...

    FROM x

    WHERE...

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

Viewing 15 posts - 706 through 720 (of 1,473 total)