Forum Replies Created

Viewing 9 posts - 1 through 9 (of 9 total)

  • RE: SQLServerCentral apologizes and you can win a book

    SELECT

    [object_idx] = ROW_NUMBER() OVER (ORDER BY [type_desc]),

    [group_idx] = DENSE_RANK() OVER (ORDER BY [type_desc]),

    [group_name] = [type_desc],

    [group_object_idx] = ROW_NUMBER() OVER (PARTITION BY [type_desc] ORDER BY [name]),

    [object_name] =...

  • RE: Need a 2nd opinion on a query

    Assuming that omsid and Recordtype form a unique composite index, he is trying to find a count of omsid's that have both a 'promo' and an 'event' Recordtype.

  • RE: Variable Default Values to a Stored Procedure (SQL Spackle)

    Hugo, that's why I suggested having one column per parameter in my previous post - so that they can be strongly typed rather than stored as strings as in the...

  • RE: Variable Default Values to a Stored Procedure (SQL Spackle)

    The parameters for a stored procedure have to be declared at design time and, presumably, you need to know how those parameters will be used within the procedure. So, if...

  • RE: Sorting Months By Number (SQL Spackle)

    Thanks for including my solution in the test results 🙂 I know it's not the fastest but it feels more "real world" because you usually need to take the year...

  • RE: Sorting Months By Number (SQL Spackle)

    Haven't read through all the replies so apologies if this has already been posted!

    You could do use this code to group and sort by month AND year:-

    ;WITH [Data] AS (

    ...

  • RE: How to get monthly YTD data

    Try this ...

    ;WITH [Period] ([StartDate]) AS (

    SELECT DATEADD(month, DATEDIFF(month, 0, GETDATE()) - [number], 0)

    FROM [master]..[spt_values]

    WHERE [type] = 'P'

    AND [number] BETWEEN 0...

  • RE: A simple math expression solver

    If the specification is for a single operation with an integer on either side ...

    CREATE FUNCTION [SimpleMath](@expression VARCHAR(max))

    RETURNS INT

    AS

    BEGIN

    DECLARE

    @position INT,

    @operator CHAR(1),

    @left INT,

    @right INT,

    @result INT

    SELECT

    @position = PATINDEX('%[*/+-]%', @expression),

    @operator = SUBSTRING(@expression, @position,...

  • RE: Thinking Time

    Unfortunately, when you're working for a consultancy firm, thinking time is usually unaccountable and non-chargeable.

    Most of my thinking time happens when I'm asleep. I actually wake up with fully-fledged portions...

Viewing 9 posts - 1 through 9 (of 9 total)