Forum Replies Created

Viewing 15 posts - 1,246 through 1,260 (of 8,731 total)

  • RE: Creating a temp table with dynamic SQL

    Ed Wagner - Monday, May 22, 2017 8:30 AM

    Brandie Tarvin - Monday, May 22, 2017 6:46 AM

    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: Looking for best approach

    Something like this:

    IF EXISTS(SELECT * FROM #temp1)
    AND EXISTS(SELECT * FROM #temp2)
      SELECT * FROM #temp1
      INTERSECT
      SELECT * FROM #temp2;
    ELSE
     ...

    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: User-friendly names for constraints

    I wrote a script some time ago and shared it in this site. http://www.sqlservercentral.com/scripts/constraints/133573/
    It's not perfect, but works with most options. It works for Primary Keys, Foreign...

    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: Rewriting Stored Procedure to be easier on the eye

    David92595 - Friday, May 19, 2017 1:14 PM

    Luis, you read my mind!

    Just remember that those queries will always scan the whole table....

    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: Loop to Repeat Export Process

    You can do something like this:

    SELECT CAST( created_time AS date) AS "created time",
      tlorder.origcity AS "Destination",
      COUNT(*) AS "Number ofOrders",
      SUM(total_charges)...

    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: Loop to Repeat Export Process

    ross_cunningham813 - Friday, May 19, 2017 11:45 AM

    I am looking to output approximately 100 tables to excel with the following code.
    One...

    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: query time out from .net code

    Option 1: Tune the query (recommended). This is done on SQL Server code.
    Option 2: Increase the time before the connection times out. This is done in .NET code.

    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: Rewriting Stored Procedure to be easier on the eye

    If we're already using non-SARGable expressions, then let's do it for all the conditions.

    Select *
    From ##Activity_Tracking
    WHERE Referral_C + Note_Ordered_C + Breach_Ordered_C + Breach_Recvd_C...

    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: Understanding why variable is NULL

    OceanDrop - Friday, May 19, 2017 10:43 AM

    If you want the default value  that you declared to be considered into the Case...

    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?

    Ed Wagner - Friday, May 19, 2017 8:02 AM

    Grant Fritchey - Friday, May 19, 2017 7:49 AM

    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: I have written a sql statement and know I should do it different using case statements but not sure how sugestions please

    Here's an example on how to do it. Try to complete it with the missing columns.
    Ask any questions you might have.
    SELECT past.past_15
      ,past.past_30
      ,past.past_60

    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: D@RE for SQL

    guaro5555 - Friday, May 19, 2017 7:30 AM

    Hi guru
    I I am new to sql as you can see from my previous post,...

    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: Some of my greatest mistakes

    Michael L John - Thursday, May 18, 2017 12:09 PM

    john.wb - Thursday, May 18, 2017 6:44 AM

    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: Creating a temp table with dynamic SQL

    If the seed is the only that would vary, you can avoid the dynamic sql.

    IF (SELECT OBJECT_ID('Tempdb..#tmp3')) IS NOT NULL
    DROP TABLE #tmp3;

    DECLARE...

    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: Atomic Transaction.? - Not Quite......

    I forgot to mention something.
    If you really need the PersonID to be unique, then add a UNIQUE constraint to that column

    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 - 1,246 through 1,260 (of 8,731 total)