Forum Replies Created

Viewing 15 posts - 8,536 through 8,550 (of 8,730 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...

  • 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 ->...

  • 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...

  • 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...

  • 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...

  • 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...

  • 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(...

  • 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...

  • 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...

  • 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...

  • 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...

  • 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...

  • RE: Design pattern for Phone

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

    It's really common.

  • 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...

  • 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...

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