Forum Replies Created

Viewing 15 posts - 121 through 135 (of 166 total)

  • RE: Pad table rows with zeros for the last 5 years

    Let's see if I understand correctly.

    1 - You want data in the "detail" section for the last five years only, 2008 - 2012.

    2 - Any gifts prior to five years...

  • RE: Get next 1st thursday

    Jonathan,

    Nearly but not quite, that just gets next thursday. Not the next first thursday of the month.

    I misread the original post. I thought the goal was to find...

  • RE: Pad table rows with zeros for the last 5 years

    Having the desired output as a sample would be helpful. I see the 2006 data in the table but I don't see it in the output of the query...

  • RE: t-sql ,sql server 2000

    The easiest way to compound rows is to CROSS JOIN to another set. The query below returns one row for each record from the system table that stores object...

  • RE: Is there an accurate script for datediff format in years:months:days?

    I think we use the day of the month as the "anniversary", and crossing an anniversary increments the year or the month. For example, if I was married on...

  • RE: Table Archiving Questions

    One way to archive data in a single step is to use the OUTPUT clause of the DELETE statement. The procedure takes @MaxRows as a parameter, stating the maximum...

  • RE: Get next 1st thursday

    Here is an alternate version using a Tally table.

    DECLARE@SelectedDateDATE = '2012-02-01' --GETDATE()

    DECLARE@DesiredDayTINYINT = 5

    SELECTTOP 1 NextDay, DATENAME(WEEKDAY, NextDay) AS NameOfDay

    FROM(

    SELECTDATEADD(DAY, N, @SelectedDate) AS NextDay

    FROMTally

    WHEREN <= 14

    ) x

    WHEREDATEPART(WEEKDAY, NextDay) = @DesiredDay

    ORDER...

  • RE: Importing an existing Excel file into a table

    You can also open the Excel document directly from SQL Server and SELECT from it just like using a table.

    From: http://support.microsoft.com/kb/321686

    SELECT * INTO XLImport4 FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',

    'Excel 8.0;Database=C:\test\xltest.xls', [Customers$])

    SELECT *...

  • RE: A Tough One, At Least For Me

    Sean Lange (1/18/2012)


    How can you get a value from an insert that isn't in the inserted table? If you insert it, it is in the inserted table. The inserted table...

  • RE: A Tough One, At Least For Me

    We are not trying to do an UPDATE or a DELETE, so using the OUTPUT clause with those statements does not help.

    We want to get the value of a column...

  • RE: BYOD

    In most professions, the "tools" do not become obsolete in two years. The screwdriver I made 25 years ago still works in every flathead screw in my house. ...

  • RE: Populate new record data based on previous month record data

    I'm going to suggest a different strategy because of the complexity of the need. You need to bring forward each row from the prior month, meaning that if a...

  • RE: A Tough One, At Least For Me

    The OUTPUT clause is going to work only with the MERGE statement.

    CREATE-- DROP -- TRUNCATE

    TABLECompOrgReference

    (

    [CompanyID]INTEGERNOT NULL,

    [Organization_ID]INTEGERNOT NULL

    )

    MERGEOrganizationRecords u

    USING(

    SELECTr.Organization_ID, c.CompanyID, c.CompanyName

    FROMCompanyRecords c

    LEFT JOIN CompOrgReference r

    ONr.CompanyID = c.CompanyID

    WHEREr.CompanyID IS NULL

    ) x

    ONx.Organization_ID =...

  • RE: Populate new record data based on previous month record data

    Two questions:

    1 - Are you saying that DerivedFact is a view, not a table?

    2 - Why is CMP1001 copied from two months prior (2011/11) rather than one month prior (2011/12)?...

  • RE: Is there a better way to set local variables in a stored procedure?

    CELKO (1/17/2012)


    The ANSI syntax is: SET <variable list> = <expression list>;

    SET (a,b,c) = (1,2,3),

    But another way is the row value constructor:

    VALUES (1,2,3) AS X ( a,b,c)

    Joe seems to...

Viewing 15 posts - 121 through 135 (of 166 total)