Forum Replies Created

Viewing 15 posts - 1,366 through 1,380 (of 2,894 total)

  • RE: much worse execution plan calling stored procedure vs. query window

    This kind of question appears on SQL forums quite often...

    There are few possible reasons for this to happen, parameter sniffing is one of them.

  • RE: unique constraint

    ...

    I like the idea of having a sid (a surrogate id) on my tables, even if I do have a natural key that can serve as a primary key. ...

  • RE: "UPDATE" Is Not Updating Correctly

    In your case you can use:

    ;WITH SUM_SALES_SUMMARY

    AS

    (

    SELECT CSCODE AS CSCODE

    ...

  • RE: unique constraint

    Some people will tell you that you should always use natural keys (JC the master of them :-)) and others will tell you that you should always use surrogate keys....

  • RE: repeating value in a case statement?

    Sector7G (8/10/2012)


    Hello,

    I’d like to confirm if what I am attempting is possible. I suspect it’s not, but wanted to ask. I am trying to re-write a query that...

  • RE: "UPDATE" Is Not Updating Correctly

    You should learn about aggregate functions.

    In your case you will need to use SUM()

  • RE: Intresting Query

    I guess to answer OP given question any of T-SQL solution would do, I also think that interviewer will be looking for answer in SQL. I wouldn't go with...

  • RE: Intresting Query

    I don't have VS to test...

    try:

    using System;

    using System.Data;

    using System.Data.SqlClient;

    using System.Data.SqlTypes;

    using Microsoft.SqlServer.Server;

    using System.Text.RegularExpressions;

    public partial class UserDefinedFunctions

    {

    static readonly Regex _regex = new Regex(@"[^0][0-9]*[^0]", RegexOptions.Compiled);

    ...

  • RE: Intresting Query

    try to return

    (SqlString) s.Value.TrimStart('0').TrimEnd('0');

    instead of

    new SqlString(s.Value.TrimStart('0').TrimEnd('0'));

    what about Regex?

    Don't forget to create static Regex object instead of instance in the function.

    To remove leading and trailing...

  • RE: Intresting Query

    ...

    Possibly so, although I can confirm that PATINDEX does not.

    You cannot even remotely compare performance of PATINDEX and .NET Regex...

    PATINDEX can only find the pattern in the string, but to...

  • RE: Precedence of operator in SQL

    ...

    Wow, I'm glad I don't have to debug your code:-D

    Yeah,

    you better not

    debug my code

    without note

    it can explode!

    :hehe:

  • RE: XML Statement

    You can find a most of details about this one in BoL.

    Usually this one is used for aggregation-like string concatenation...

  • RE: Intresting Query

    dwain.c (8/10/2012)


    Eugene Elutin (8/10/2012)


    You should try CLR too...

    Hah! I was waiting to hear someone suggest that. Not surprised it was you.

    Where have you been lately Eugene? Haven't...

  • RE: Intresting Query

    You should try CLR too...

Viewing 15 posts - 1,366 through 1,380 (of 2,894 total)