Forum Replies Created

Viewing 15 posts - 3,136 through 3,150 (of 4,085 total)

  • RE: Help with CASE please

    CELKO (5/23/2012)


    we do not use bit flags

    Until SQL supports a true Boolean data type, bit is the best alternative.

    * Why would I reserve 2 bytes for a...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Generate Month end records bases on Start Date

    Jeff Moden (5/23/2012)

    The day that I want is really the end of the previous month which is always 1 day less the 1st of the month. So I just...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Query Help - Grouping same domain in EmailId

    Consider adding a computed column to your CustomerMaster table to produce the domain name. If you can't update the structure, then you can use a CROSS APPLY to make...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Unnecesary subquery and top?

    CELKO (5/22/2012)


    Rows are not records. Again, this is COBOL and not SQL. Time for a total re-write .. sorry.

    Wikipedia disagrees with you

    Row (database)


    In the context of a relational database, a...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Table query

    Consider using a reporting tool, such as SSRS, to write your reports. Otherwise the crosstab/pivot already recommended is your best approach.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: SET or SELECT to assign a default value to a nullable variable

    Brandie Tarvin (5/17/2012)


    drew.allen (5/17/2012)


    I prefer this to prevent NULL values.

    DECLARE @L_ZERO INT = 0

    SELECT @L_ZERO = IdMyTable FROM MyTable WHERE ColumnRef = 1000

    Drew

    Drew, how does that prevent NULL from overriding...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: SET or SELECT to assign a default value to a nullable variable

    Nakul Vachhrajani (5/17/2012)


    How's this?

    DECLARE @L_ZERO INT

    SELECT @L_ZERO = ISNULL(IdMyTable,0) FROM MyTable WHERE ColumnRef = 1000

    SELECT @L_ZERO

    This doesn't produce the same results as the original queries. Specifically, when there is...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: SET or SELECT to assign a default value to a nullable variable

    I prefer this to prevent NULL values.

    DECLARE @L_ZERO INT = 0

    SELECT @L_ZERO = IdMyTable FROM MyTable WHERE ColumnRef = 1000

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Could not be bound...

    You have a couple of options depending on what you want. As Lynn is trying to point out you have an implicit CROSS JOIN, so you can make it...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Could not be bound...

    The problem is here:

    from GLDEFRLS

    INNER JOIN accropts AC

    ON AC.AccAccrOption = EM.EacAccrOption

    INNER JOIN empaccr...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Week of the month

    anthony.green (5/17/2012)


    This should do the trick, also dont forget the power of Google or your favourite search engine

    set datefirst 1

    DECLARE @dt DATETIME, @WeekOfMonth TINYINT

    SET @dt = '2007-07-08'

    SET @WeekOfMonth = DATEDIFF(week,...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Organically cancel a resultset from proc if rowcount is zero?

    Sean Lange (5/16/2012)


    It was a 2 minute brief example of using exists to demonstrate the task at hand. I certainly was not expecting a code review. 😀

    Your points are all...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Select Filter

    Mark-101232 (5/16/2012)


    Use LIKE

    SELECT ..

    FROM mytable

    WHERE PartNumber LIKE '[0-9][0-9][0-9][0-9][A-Za-z][0-9][0-9]'

    If your collation is case-insensitive (default ), you don't need to specify both A-Z and a-z.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Organically cancel a resultset from proc if rowcount is zero?

    Sean Lange (5/16/2012)


    Here is a simple example using exists to accomplish the type of behavior you are describing.

    alter proc MyProc

    (

    @SomethingElse int

    )

    as begin

    select top 5 * from sys.sysobjects as Something

    if exists(select...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Case Logic in Join

    You might also want to add the CASE statement as a computed column on your PART table and create an index on that computed column.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

Viewing 15 posts - 3,136 through 3,150 (of 4,085 total)