Forum Replies Created

Viewing 15 posts - 14,776 through 14,790 (of 14,953 total)

  • RE: Group By Issue

    Not an elegant solution, but what happens if you wrap the whole thing in an outer query and select the sum of that column?

  • RE: Query to find data over range of years

    Just ran some tests.

    Mark's solution was much faster than derived tables. Tried it on 50k rows of data. Difference of 14 seconds average (derived tables) vs a maximum...

  • RE: Query to find data over range of years

    The other thing that's probably hurting the performance is the Distinct operator in the derived tables. That's a lot of extra work for the database engine, but doesn't actually...

  • RE: SQL 2005 Maintenance Plans - Indexes

    Yes.

  • RE: variable return from Select

    The format is:

    SELECT @MyValue= ParameterValue FROM PARAMETERS WHERE ParameterName='AlarmLevel0'

    That will assign the value from the table.

  • RE: Query to find data over range of years

    The simplest solution I can think of uses derived tables or CTEs and joins to them. But you said you don't want to do that. Any particular reason...

  • RE: UDF to create a counter

    checksum doesn't guarantee unique results. It'll probably be unique, but it's not guaranteed. More likely to be unique than Rand() is, though.

  • RE: Search query fluctuation in exection

    I'm not entirely clear on what you're asking. Please post the code you have a question about (both CTE and the other version), and we can take a look...

  • RE: If Then logic

    If you don't want to use a Case statement, use:

    coalesce(nullif(name, ''), 'Unknown')

    The nullif will make the name null if name = ''.

  • RE: Cross Tab or Pivot Question

    Try this:

    declare @Start_Date datetime, @Weeks int

    declare @MaxDate datetime

    select @maxdate = dateadd(week, 1, getdate()),

    @start_date = dateadd(day, 2, dateadd(day, -1 * datepart(weekday, @start_date), @start_date))

    ;with Weeks (WStart datetime, WEnd datetime) as

    (select dateadd(week, num-1,...

  • RE: SQL 2005 Maintenance Plans - Indexes

    Rebuild does more than Reorganize. Microsoft recommends rebuilding if fragmentation is over 30%, and reorganizing if fragmentation is between 5% and 30%, and leaving the index alone if fragmentation...

  • RE: UDF to create a counter

    There isn't an exact solution that I know of. Since a view can't pass parameters to a table-value function, you might have trouble doing this.

    If you can use a...

  • RE: Search query fluctuation in exection

    This is normal behavior in SQL databases.

    The first time you run it, it has to come up with an execution plan, so that takes the longest.

    After that, the first time...

  • RE: Strange failing of Convert (varchar to decimal)

    Makes sense. Try running it on the string function, just without the final convert to numeric. That should give you what you need.

    Definitely feel for you on that...

  • RE: Cross Tab or Pivot Question

    Add a derived table to the From statement:

    From Numbers

    cross join

    (select distinct sales_owner

    from dbo.op_opportunity) SubOwner

    Then add "and sales_owner = subowner.sales_owner", to the sub-query.

    That should give you what you want.

    Note that the...

Viewing 15 posts - 14,776 through 14,790 (of 14,953 total)