Forum Replies Created

Viewing 15 posts - 3,706 through 3,720 (of 4,085 total)

  • RE: Need help in writting SQL

    Garadin (6/17/2011)


    Here's one way. This is assuming that ItemName can uniquely identify the items.

    The fact that he's COPYING the records including the ItemName guarantees that the ItemName cannot uniquely...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Best way to alias column names

    Phil Parkin (6/17/2011)


    If you write a lot of T-SQL, consider doing yourself a favour and omit the readability words (AS is one) - it soon becomes second nature and as...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Displaying week by week(only week days not weekends) between two dates

    You're very long if structure can be replaced with a simple formula.

    SELECT DateAdd(Week, DateDiff(Week, 0, GetDate()), 0)

    The formula takes advantage of the fact that date 0 fell on a Monday.

    The...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: SQL Query for MI Report

    A couple of things that I wanted to point out.

    * You use this formula repeatedly in your query DATEADD(MINUTE,-@interval,DATEADD(MINUTE,N*@interval,@starttime)) I moved it into the CTE so that I...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Replace data in View Query

    bpmosullivan (6/14/2011)


    Got the following query to run but it is not applying the case argument. Any ideas appreciated ?

    WITH CTE AS (

    ...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Selecting Rows Based on condition

    It's not clear what order you want to apply your criteria, and it will affect the exact query used.

    When you have multiple records, do you want to find the last...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Verify my warning trigger

    This came up in another thread recently, but I can't find it right now.

    If it requires user interaction, it really belongs in the front end. Triggers are about as...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Modify trigger

    There are far deeper problems with the trigger than the multiple subselects.

    If you are only inserting one record, this trigger does ABSOLUTELY NOTHING. If you update column A in...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Insert query generating error

    SKYBVI (6/8/2011)


    The index key columns are

    attribgroup asc char (21)

    itemattrib asc char (21)

    seqnumber asc int

    Are these columns NULLABLE? Do they have DEFAULTs?...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Date conversion help

    npeters 86796 (6/7/2011)


    I have the query below which will be used in ssrs.

    the problem i have is that i need to query data using the month in the where clause...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Insert query generating error

    Did you change this in the main query or the subquery? Changing this in the subquery won't have any real effect on the outcome.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Extracting the db name from log file

    The last parameter in SUBSTRING() is number of characters, not the ending position. If the length of the string is 30, you're asking for 28 characters from an 8...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Insert query generating error

    You probably have duplicate values in your IV00101 table, so even though they don't exist in your target table, they produce duplicate values when they are both inserted. Try...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Increment a date T-SQL Statement

    m_cg (6/7/2011)


    Still not sure of the format, but gave it 2 ways. Does this work for you?

    [...]

    insert into monthcounter(monthid)

    values

    (1),

    (2),

    (3),

    (4),

    (5),

    (6),

    (7),

    (8),

    (9),

    (10),

    (11),

    (12)

    Since this syntax was introduced in SQL 2008 and this is a...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Sql Help with dates

    The problem here is that the tax week uses modulo arithmetic and the comparison operators don't. So when the tax week reaches 52 (or 53) it cycles back to...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

Viewing 15 posts - 3,706 through 3,720 (of 4,085 total)