Forum Replies Created

Viewing 15 posts - 6,481 through 6,495 (of 8,731 total)

  • RE: Can it change columns of a table values to rows

    You should use UNPIVOT or maybe the CROSS APPLY approach.

    http://www.sqlservercentral.com/articles/CROSS+APPLY+VALUES+UNPIVOT/91234/

    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: SQL Stored Procedure help

    You seem to have "Work" tables and "History" tables and you use UNION between them. You must realize that UNION and UNION ALL work slightly different. UNION will return a...

    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: trying to figure out join to find all records from one table that do not exist in other table, grouped by a certain column

    Scott,

    Your query returns a different result. That might be what the OP was looking or it might not. I'm not sure. I agree that it would be a better...

    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: SQL Stored Procedure help

    Removing NOLOCK won't give inaccurate results. Adding it might. You can read more in this article http://blogs.msdn.com/b/davidlean/archive/2009/04/06/sql-server-nolock-hint-other-poor-ideas.aspx and you could google for other examples on why it's a bad idea.

    I...

    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: SQL Stored Procedure help

    Wow, that's a lot of code to even try to imagine what's going on. Remember that we don't know how do your tables and data look like.

    The only tip...

    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: MySQL to MSSQL

    That means that your database doesn't have a table (or view) called events. Check that you're running the query in the correct db and that the table exists.

    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 aggregate interval data to hourly values?

    I wouldn't use the cross apply, but it's just a personal preference.

    It should be interpreted the same way as Chris M's query.

    SELECT MeteriD,

    Reading = SUM(Reading),

    DateByHour = DATEADD(hour,DATEDIFF(hour,0, ReadingDate),0)

    FROM...

    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: trying to figure out join to find all records from one table that do not exist in other table, grouped by a certain column

    You're welcome. Thank you for the feedback.

    I hope that you understand how the solution works. If not, feel free to ask any questions that you have.

    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: Insert information based on a range

    You could append enough zeros and use a RIGHT() function when integrating the n value.

    RIGHT( '0000' + CAST(N as varchar), 4)

    Here's a great explanation on how the tally table (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: error : supquery returned more than 1 value

    The query you posted shouldn't give an error on a subquery returning more than 1 value. However, we can't see the stored procedure. Your error might be in there.

    I agree...

    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 IN CLAUSE

    The problem is that you only have a single value with your variables and you need more than one.

    Using a JOIN instead of the variables, you can get it working.

    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: Help needed in join

    This might not be the best option for performance (as I haven't done real performance testing) but it's quite simple.

    SELECT c.IdCompany,

    c.CompanyName,

    ISNULL( p.CompanyCode,...

    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: Hanging WHILE loop

    Your query looks just like mine but using a while loop instead of a single operation. Why would you do that.

    Without DDL and sample data, I can't be sure why...

    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 tuning

    When you're testing one query against another, they're of great help. You'll be running both queries under the same circumstances. Of course, queries will be faster if you have 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: Replicate Schema but not table Rows

    Would it be a recurrent process? or a single-time replica?

    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 - 6,481 through 6,495 (of 8,731 total)