Forum Replies Created

Viewing 15 posts - 6,391 through 6,405 (of 8,731 total)

  • RE: dynamic pivot troubles :/

    manssourianm (5/29/2014)


    Luis,

    Thanks for your help.

    Changing the datatype to (max) in both places helped. Now I get the correct crosstab columns and rows, but the data part is completely blank.

    I had...

    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 statement to only return records where joined records all meet condition

    That seems as a good approach. I'll leave 2 alternatives which might not be better.

    WITH VLeaders AS(

    SELECT l.LeaderID,

    ...

    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: Unable to figure out SQL Script

    You can add more conditions to your JOIN using AND. I did part of the job here. You need to work on the rest.

    SELECT Projects, Hours

    FROM Projects

    LEFT JOIN ProjTime

    ...

    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: dynamic pivot troubles :/

    Did you change both values to nvarchar(max)?

    One is in the variable declaration and one is in the query.

    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: Unable to figure out SQL Script

    You need to use a LEFT JOIN between Projects and ProjTime.

    If you put the month condition in the WHERE clause, it will become an INNER JOIN, so change it 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: dynamic pivot troubles :/

    This is well explained on the following article by Jeff Moden. You should read it (and maybe the first part as well) to fully understand how to do it.

    http://www.sqlservercentral.com/articles/Crosstab/65048/

    This is...

    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 2008

    Try printing your @sql variable to know how the string is formed and identify syntax errors more easily.

    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: Comparing performance of two versions of a query

    Maybe you could use SQL Server Profiler with the correct filters and use the option "Discard results after execution" (Options->Query Results->SQL Server->Results to Grid).

    Maybe someone else can give 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: Sum a Column by Client and Group by date 4 weeks apart!

    That might give you a semi cross join which will lead to incorrect results. Date calculations can prevent that but you might get some inconsistencies. Check the following:

    CREATE TABLE #table1...

    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 add column in specific position

    Putting aside the fact that this is a really old thread.

    You could prevent the errors using format files and staging tables. That's basically the same rule as using 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: combining two rows of data into 1

    You can use a staging table where you insert the values in 2 rows and then use the code to insert them into the final table with a single row.

    How...

    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: Joining two tables and dealing with null values

    I'm not sure if it will work the same way. If r.BankID will always be 26 characters long this should be equivalent and SARGable. If not, there's a risk for...

    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: COALESCE to replace multiple CASE statements

    Alvin Ramard (5/28/2014)


    ChrisM@Work (5/28/2014)


    Alvin Ramard (5/28/2014)


    Luis Cazares (5/27/2014)


    Alvin,

    The code makes clear that there's a concatenation based on multiple values on a single column.

    CASE WHEN A.[COL_1] LIKE '%cricket%' THEN 'ck'...

    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: Sum a Column by Client and Group by date 4 weeks apart!

    This is why I wanted sample data. That way I could try the code. :hehe:

    The problem is that I used the columns wrong in the OVER clause. It should read...

    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: COALESCE to replace multiple CASE statements

    This is just an idea that might work and a shot in the dark at most. Maybe a nested replace will perform better.

    Something like this:

    DECLARE @CSV varchar(100)...

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