Forum Replies Created

Viewing 15 posts - 151 through 165 (of 582 total)

  • RE: Brutal Query

    if exists(

    select fk from tbl group by fk having count(distinct id) != (select count(distinct id) from tbl)

    )

    select @retval = 0

    Tim Wilkinson

    "If it doesn't work in practice, you're using the wrong theory"
    - Immanuel Kant

  • RE: Very Poor Performance - Identical Databases Yield Different Performance

    Maybe the production environment is using a suboptimal stored plan. You can get rid of all plans with DBCC FREEPROCCACHE, but that could cause temporary performance problems on the prod...

    Tim Wilkinson

    "If it doesn't work in practice, you're using the wrong theory"
    - Immanuel Kant

  • RE: Variable versus explicit value

    Nice one, Pam!

    Tim Wilkinson

    "If it doesn't work in practice, you're using the wrong theory"
    - Immanuel Kant

  • RE: Variable versus explicit value

    I don't think this happens in SQL9, as individual statements have their own plans. I stand to be corrected of course.

    Tim Wilkinson

    "If it doesn't work in practice, you're using the wrong theory"
    - Immanuel Kant

  • RE: How do you do a WHERE NOT IN using multiple columns?

    Yes, it is unclear. The column needs to be a column in the outer table (i.e. the one to the right of the left join) which cannot be null. You...

    Tim Wilkinson

    "If it doesn't work in practice, you're using the wrong theory"
    - Immanuel Kant

  • RE: Variable versus explicit value

    Better post the execution plans then.

    Tim Wilkinson

    "If it doesn't work in practice, you're using the wrong theory"
    - Immanuel Kant

  • RE: Variable versus explicit value

    Is your variable the right datatype?

    Tim Wilkinson

    "If it doesn't work in practice, you're using the wrong theory"
    - Immanuel Kant

  • RE: Variable versus explicit value

    It may be that SQL server has a suboptimal plan based on an atypical value for this param. Try DBCC FREEPROCCACHE and then run the procedure twice with a typical...

    Tim Wilkinson

    "If it doesn't work in practice, you're using the wrong theory"
    - Immanuel Kant

  • RE: How do you do a WHERE NOT IN using multiple columns?

    Here's previous post on the same topic:

    http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=8&messageid=289159

    you should use a left join and check for NULL in a join column of the outer table. The alternaitive is concatenation but...

    Tim Wilkinson

    "If it doesn't work in practice, you're using the wrong theory"
    - Immanuel Kant

  • RE: Stored Procedures and Arrays

    To expand on the above, you need to create parameter objects and add them to the parameters collection of the command object, which should be of 'stored procedure' type.

    Tim Wilkinson

    "If it doesn't work in practice, you're using the wrong theory"
    - Immanuel Kant

  • RE: Converting varchar to datetime in select statement

    Yes, wasn't sure and didn't look it up. Largely irrelevant to the issue though.

    Tim Wilkinson

    "If it doesn't work in practice, you're using the wrong theory"
    - Immanuel Kant

  • RE: Converting varchar to datetime in select statement

    I wouldn't combine data cleansing with ordinary DML. Check the values using a SELECT with ISDATE() first, then fix any corrupt values, then move the data.

    If you have mixed date formats,...

    Tim Wilkinson

    "If it doesn't work in practice, you're using the wrong theory"
    - Immanuel Kant

  • RE: Need help with a Conditional Insert or Update statement

    Yes, I was wondering about that. At the point in time at which you insert a new record, there oughtn't to be any records referencing it - what did they reference...

    Tim Wilkinson

    "If it doesn't work in practice, you're using the wrong theory"
    - Immanuel Kant

  • RE: Help me: position of column instead of name or alias column name

    Ask this joker what he means by product-oriented. It sounds as though he means 'trying to use rows as columns'.

    You need to give us a little more background. Your current...

    Tim Wilkinson

    "If it doesn't work in practice, you're using the wrong theory"
    - Immanuel Kant

  • RE: query: reference query columns from within query

    Since your issue is maintenance/code reuse, a view would be the best solution, rather than a derived table (inline view).

    It's not particularly useful here since the calculations are simple...

    Tim Wilkinson

    "If it doesn't work in practice, you're using the wrong theory"
    - Immanuel Kant

Viewing 15 posts - 151 through 165 (of 582 total)