Forum Replies Created

Viewing 15 posts - 541 through 555 (of 1,193 total)

  • RE: Creating Combined Queries

    Phil Parkin (3/29/2016)


    Alan.B (3/29/2016)


    You would use AND.

    SELECT vend_id, prod_id, pro_price

    FROM products

    WHERE prod_price <=5

    AND vend_id IN (1001, 1002);

    Disagree. This requires an OR.

    select a from b where condition1

    union (should probably be union...

  • RE: Question related to Query plan for AdventureWorks2012 DB

    The original table has a computed column (LineTotal) in it.

    When you created the copy of the table with SELECT...INTO, only the data for that column was moved to the...

  • RE: Running Totals with window function

    DesNorton (3/28/2016)


    Thank you Sachin and Jacob. From my initial dev testing, this appears to do the trick. Now we see if the QA team can break it ......

  • RE: Running Totals with window function

    Alan.B (3/25/2016)


    Jacob Wilkins (3/25/2016)


    Sachin Nandanwar (3/25/2016)


    ...But again it looks to cumbersome with all those conditions in the CASE expression.Your original solution is more subtle.

    Your version doesn't have to be that...

  • RE: Running Totals with window function

    Sachin Nandanwar (3/25/2016)


    ...But again it looks to cumbersome with all those conditions in the CASE expression.Your original solution is more subtle.

    Your version doesn't have to be that complicated.

    It could just...

  • RE: Running Totals with window function

    Sachin Nandanwar (3/24/2016)


    DECLARE @TranTable TABLE (

    AccountID INT NOT NULL

    , TranDate ...

  • RE: Running Totals with window function

    Not sure that this is the most efficient method, but I think it does what you're looking for:

    WITH CTE AS

    (

    SELECT AccountID,

    ...

  • RE: Advice on query optmization - Multiple Unions

    Hugo Kornelis (3/23/2016)


    ...

    WHERE LEN(ISNULL(sfl.ConvertedContactId, '')) < 1

    Alan already commented on this. I see this type of WHERE clause more often and it always me angers me. Just think about it....

  • RE: Error Assitance

    Michael L John (3/22/2016)


    rcooper 78099 (3/22/2016)


    Msg 156, Level 15, State 1, Line 15

    Incorrect syntax near the keyword 'join'.

    Michael L John (3/22/2016)


    Select

    pc.accountnbr 'account number',

    qf.description 'Fund Name',

    pc.checknbr 'Check Number',

    ...

  • RE: Finding best matched/covering time period/s against a time period search

    jewel.sacred (3/22/2016)


    Yes, I can fully understand this as I have experienced it as well in past. 🙂 I really appreciate the help been provided. But I already mentioned this criteria...

  • RE: I don't understand why I'm getting an "invalid column name" error when creating this SP

    Alternatively, you could CROSS APPLY the calculations; those aliases could then be used in the column list.

    The FROM clause would become something like this:

    FROM dbo.fnItemsIssuedToLocBetwDatesNeedItemType(@DrugOrSupply, @BeginDate, @EndDate) fcnItems

    INNER JOIN vwItemQtysOnHandAllItems_SQLViews...

  • RE: Are the posted questions getting worse?

    Steve Jones - SSC Editor (3/22/2016)


    Alan.B (3/21/2016)


    Quick question: I got the standard email saying that someone replied to a comment on one of the forum threads but when I go...

  • RE: sys.dm_exec_requests question

    To pile on to what Grant said, yeah, there's probably something else going on there. Those queries,table names, and deadlock issues are eerily familiar, so I'm guessing the "something else"...

  • RE: Getting values which dont join

    John Mitchell-245523 (3/17/2016)


    So you want to match every job with every status? Just use a CROSS JOIN.

    John

    To elaborate on this, it sounds like you're looking for something like:

    SELECT ...

  • RE: Count of records in all tables, specify DB

    You would just need to use dynamic TSQL, which you're already doing.

    Something like this:

    CREATE PROCEDURE test_use

    @db_name sysname

    AS

    DECLARE @sql nvarchar(max);

    SET @sql='USE '+QUOTENAME(@db_name)+'; ';

    SET @sql=@sql+'

    SELECT table_name=OBJECT_NAME(o.object_id),

    ...

Viewing 15 posts - 541 through 555 (of 1,193 total)