Forum Replies Created

Viewing 15 posts - 8,536 through 8,550 (of 8,731 total)

  • RE: Selecting records based on count

    What worked? Lucas option doesn't seem like a great option.

    You could use something like this for the HAVING

    SELECT product, region, status

    FROM products prd

    INNER JOIN pd_status S on s.product_status_key=prd.status_key

    WHERE...

    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: Select Query

    There's no T-SQL syntax, but there are tricks in SSMS.

    You can right click on the the table in the object explorer and choose: Script Table as -> SELECT To ->...

    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: does not work with outer join or outer apply

    I'm sorry I didn't replied yesterday but we had to leave the office because of Isaac.

    Here's a query that will work as a static report. It can be easily transformed...

    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: does not work with outer join or outer apply

    I'm sorry Matt, but your query looks complicated and more expensive than a simple Cross Tab that would require only 2 tables and an inner join.

    I have the query but...

    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: Extra column with difference

    A simple modification to the code to avoid problems with missing quarters (shouldn't happen but it could), I also believe is easier to understand.

    DECLARE @test-2 TABLE( Year int,Qrtr int, GroupName...

    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: Create view with no outer joins

    I guess it was wrong for me to read the 2012 version as it is less explicit.

    But I still believe the OP won't have an option on creating the indexed...

    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 can I get all in query result into one view

    The first rule would be getting rid of that horrible while loop and use the dates intervals.

    DECLARE @Date1datetime,

    @Date2 datetime

    SET @Date1 = DATEADD( mm, DATEDIFF(mm, 0, Getdate()), 0)

    SET @Date2 = DATEADD(...

    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: Create view with no outer joins

    jdbrown239 (8/26/2012)


    Need to create view with no outer joins so I can index the view.

    I can't find a restriction for indexed views that involves outer joins http://msdn.microsoft.com/en-us/library/ms191432.aspx. Are you...

    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: Join making conflict....

    You were joining your grouped results with the original table with duplicates. You can get an even simpler version of your code like this, no need of a subquery:

    SELECT @MSGOUT...

    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: Calculating percentages of total

    I'm leaving the office now, but here's another option:

    DECLARE @Total float,

    @Total2 float

    SELECT @Total = COUNT( *),

    @Total2 = COUNT( CASE WHEN regstate = 'CA' THEN regstate END )

    FROM #Cars

    SELECT c.CarModel,

    (COUNT( 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: how to remove zero from my string

    Don't trust me, but using Lynn's code to test performance with more leading zeros (100 more) the results are consistent.

    All the methods took longer to run and the double REPLACE...

    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: Design pattern for Phone

    I might be wrong, but you could have a column called PhoneEntity so you can know which table uses that phone.

    Your "single table model" suggests a phone can be owned...

    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: Design pattern for Phone

    What happens when a location/person has more than one phone?

    It's really common.

    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 a variable to identify table in FROM statement

    You can't do that directly.

    You could do it with dynamic code, but you need to be careful of SQL injection.

    The best way to achieve it is to redesign you database...

    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 remove zero from my string

    tyson.price (8/24/2012)


    Most programmers would need to research what "'%[^'+@Char+'X]%'" means if they came across it supporting code. Why put that in place when something much more readable can be...

    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 - 8,536 through 8,550 (of 8,731 total)