Forum Replies Created

Viewing 15 posts - 3,271 through 3,285 (of 8,731 total)

  • RE: Converting VARCHAR to BIGINT

    If by any chance you're working with SQL Server 2012 or later, you can use TRY_CAST or TRY_CONVERT.

    That wasn't my first suggestion because this is the 2008 forum, so...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Converting VARCHAR to BIGINT

    No need for a performance problem caused by a scalar udf. There's a simple formula explained in the following article that can help you simplify your code.

    http://www.sqlservercentral.com/articles/ISNUMERIC()/71512/

    SELECT

    ...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Best way to retrieve this sum?

    Using the OVER clause and the REPLICATE function, you could achieve this.

    SELECT WarehouseNumber,

    ItemDescription,

    Quantity = REPLICATE('?', COUNT(*) OVER( PARTITION BY WarehouseNumber,...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Use of merge under Match Found condition

    Are you merging or you're just updating? If you're just updating, use UPDATE.

    Here are some general examples:

    UPDATE t

    SET value = s.value

    FROM TargetTable t

    JOIN SourceTable s ON t.id = s.id

    ...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Are the posted questions getting worse?

    ThomasRushton (2/25/2016)


    Phil Parkin (2/25/2016)


    Luis Cazares (2/25/2016)


    Is it too early for these answers? http://www.sqlservercentral.com/Forums/Topic1764225-3411-1.aspx

    Not at all.

    At least you didn't go with LMGTFY, or JFGI...

    That would have implied additional work.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Help with Row Number

    Maybe something like this?

    select rcp.CalendarPeriodId

    ,rc.CalendarId

    ,rcp.CalendarYearId

    ,rcp.PeriodNumber

    ...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Avoid grouping twice on a query

    sys.user (2/25/2016)


    Luis Cazares (2/25/2016)


    Dodgier according to who?

    If your problem is that you have too many columns in the GROUP BY clause, you could use a different approach.

    I used a CTE...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Avoid grouping twice on a query

    Dodgier according to who?

    If your problem is that you have too many columns in the GROUP BY clause, you could use a different approach.

    WITH cteCrsSub AS(

    SELECT...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: string question

    Maybe something like this:

    SELECT String,

    SUBSTRING( String, CHARINDEX('yesterday', String), CHARINDEX('tomorrow', String) - CHARINDEX('yesterday', String) + 8 /*LEN('tomorrow')*/)

    FROM(VALUES('Learn from yesterday, live for today, hope for tomorrow. The...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Are the posted questions getting worse?

    Is it too early for these answers? http://www.sqlservercentral.com/Forums/Topic1764225-3411-1.aspx

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Connect to SQL instance on Mac

    Try this

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: how to loop without endless joins

    Lynn Pettis (2/24/2016)


    Luis Cazares (2/24/2016)


    Lynn Pettis (2/24/2016)


    How about this?

    The set-based loop might be faster. The example shown in the article is basically the same as this one and the improvement...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Today's Random Word!

    crookj (2/24/2016)


    HappyGeek (2/24/2016)


    Ed Wagner (2/24/2016)


    Champions

    Queen!!

    Dust (another one bites the...)

    Bohemian (Rhapsody)

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Are the posted questions getting worse?

    rodjkidd (2/24/2016)


    Grumpy DBA (2/24/2016)


    jasona.work (2/24/2016)


    http://www.sqlservercentral.com/Forums/Topic1763775-3412-1.aspx

    /Me leans back, grabs bucket of popcorn

    Sure sounds like Gail answered the original question, yet for some reason the OP decided to focus on the comments...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: how to loop without endless joins

    Lynn Pettis (2/24/2016)


    How about this?

    The set-based loop might be faster. The example shown in the article is basically the same as this one and the improvement was noticeable.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2

Viewing 15 posts - 3,271 through 3,285 (of 8,731 total)