Forum Replies Created

Viewing 15 posts - 3,001 through 3,015 (of 4,085 total)

  • RE: Stored proc Timing out halfway through - rolling back without transaction

    All SQL code is transactional. If you aren't specifically declaring transactions, you are most likely using autocommit where every statement is its own transaction. The ROLLBACK will only...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Help with Totals per half hour timeframe

    You were actually very close. The problem is here.

    order by ABS (DateAdd(Minute, 30 * (DateDiff(Minute, 0, closedate) / 30), 0)) ASC

    DATEADD() returns a date/time and ABS() takes a float,...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Asynchronous Cursor Population Slow for Large Result Sets

    Cursors generally perform horribly. If you give us more details about what you're trying to accomplish, we might be able to help you rewrite it without cursors.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: OVER clause with Aggregate function - Wierd

    Phil Parkin (7/2/2015)


    drew.allen (7/2/2015)


    If you don't specify the ROWS or RANGE, it uses RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, so the current row is always the max value in...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: OVER clause with Aggregate function - Wierd

    If you don't specify the ROWS or RANGE, it uses RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, so the current row is always the max value in that range with...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Always Return X Number of records, even if less in the recordset

    I think a much better approach is to update your Access report. It's been awhile, but there should be settings in your Access report to set minimum and maximum...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: How to pull value of query, and not value of variable when query using select top 1 @value from table

    You can actually do this without CURSORs or temp tables.

    DECLARE @sqlText nvarchar(1000)

    SELECT @sqlText = 'SELECT c.ColumnName, MIN(dt) AS EarliestDate, MAX(dt) AS MostRecentDate FROM eddsdbo.Document CROSS APPLY ('

    + STUFF((

    SELECT 'UNION SELECT...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Trying to format Hours of Operation for businneses

    You definitely don't need a cursor. Using the following setup:

    DECLARE @StoreHours TABLE

    (

    store_id int,

    MonOpen varchar(10),

    MonClose varchar(10),

    TueOpen varchar(10),

    TueClose varchar(10),

    WedOpen varchar(10),

    WedClose varchar(10),

    ThuOpen varchar(10),

    ThuClose varchar(10),

    FriOpen varchar(10),

    FriClose varchar(10),

    SatOpen varchar(10),

    SatClose varchar(10),

    SunOpen varchar(10),

    SunClose varchar(10)

    )

    insert @StoreHours

    select 1,...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Pivot, unpivot

    Unless all of your columns are the same datatype, this is a VERY BAD IDEA. In order for this to work, all of your columns in your rows would...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: order by desc and asc on same column

    If I understand what you are asking, try the following.

    SELECT *

    FROM your_table

    ORDER BY CASE WHEN <your criteria here> THEN your_date_field ELSE '9999-12-31' END ASC

    , your_date_field DESC

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Looking for a better script

    If I understand what you're trying to calculate, your data is incomplete. If you want to plan a route on a 2-dimensional surface, e.g. a plane or the surface...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Composite PK/Surrogate and Sequence/Identity questions.

    RonKyle (6/22/2015)


    I didn't see anywhere example of sequence object in composite PK

    The sequence by its nature would not need to be part of a composite key. It will be...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Working around the lack of subquery support

    ScottPletcher (6/19/2015)


    drew.allen (6/19/2015)


    By default, SQL Server joins tables in left-to-right order,

    I'm not sure it's safe to make that blanket statement. I think SQL will join in whatever order it...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Working around the lack of subquery support

    By default, SQL Server joins tables in left-to-right order, but you can override that behavior by using parentheses in your JOIN clause.

    SELECT

    artefacts.name AS DB, *

    FROM

    @artefacts artefacts

    LEFT OUTER JOIN (

    @relationships relationships

    INNER...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: CTE (?) or query help

    I realized late yesterday that my query needed some updates. With the sample data that was posted, I was able to update the script and get something that worked.

    ;

    WITH...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

Viewing 15 posts - 3,001 through 3,015 (of 4,085 total)