Forum Replies Created

Viewing 15 posts - 5,011 through 5,025 (of 8,731 total)

  • RE: what would be the proper way to add this to my where clause

    Zingiber (4/14/2015)


    What about joining the two tables?

    SELECT DISTINCT SO.omlSalesOrderID

    FROM m1_dc.dbo.SalesOrders AS SO

    LEFT OUTER JOIN m1_dc.dbo.SalesOrderLines AS SOI

    ON SO.ompSalesOrderID = SOI.ompSalesOrderID

    WHERE SO.ompShippingMethodID='JBFM'

    OR SOI.omlPartID='finalmile'

    You'll need a FULL OUTER JOIN which...

    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 Avoid Dynamic SQL

    Either you write the 10 queries or you use Dynamic SQL. You could use a procedure called sp_MSforeachdb (which is undocumented) or Aaron Bertrand's version http://sqlblog.com/blogs/aaron_bertrand/archive/2010/12/29/a-more-reliable-and-more-flexible-sp-msforeachdb.aspx

    What limitations are you concerned...

    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: can someone give me tips on how to use the cast function to display words?

    CAST is not needed. At least for what you posted.

    SELECT *,

    'the freight cost is ' + REPLACE(cost, '.', ' dollars and ') + ' cents'

    FROM (VALUES(65.83))...

    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: what would be the proper way to add this to my where clause

    ScottPletcher (4/13/2015)


    Go ahead and add DISTINCT to each separate query on which it's applicable:

    SELECT DISTINCT omlSalesOrderID

    FROM m1_dc.dbo.SalesOrderLines

    WHERE omlPartID='finalmile'

    UNION

    SELECT ompSalesOrderID

    FROM m1_dc.dbo.SalesOrders

    WHERE ompShippingMethodID='JBFM'

    Why? :unsure:

    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 by date of the week

    Something like this could help.

    SELECT

    ISNULL( t.Amount, 0) Amount,

    t1.TranDate

    FROM #Test1 t1

    LEFT JOIN

    (

    SELECT SUM(Amount) AS Amount,

    CASE WHEN DATENAME(DW,...

    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: what would be the proper way to add this to my where clause

    Something like this?

    SELECT omlSalesOrderID

    FROM m1_dc.dbo.SalesOrderLines

    WHERE omlPartID='finalmile'

    UNION

    SELECT ompSalesOrderID

    FROM m1_dc.dbo.SalesOrders

    WHERE ompShippingMethodID='JBFM'

    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: string query help

    cooljagadeesh (4/13/2015)


    thanks boss

    Do you understand the solution that Eirikur provided? There's at least one question that I'd ask.

    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: Find double records within DateTime range

    I'm not sure if this more simple option would fit you.

    What happens if a row falls into the following 24 hours but it's on a different date? This option...

    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: Are the posted questions getting worse?

    WayneS (4/10/2015)


    Luis Cazares (4/10/2015)


    Someone just mentioned that you could have 2 clustered indexes on a table. But I'm sure he's high. 😀

    http://www.sqlservercentral.com/Forums/FindPost1676220.aspx

    But, think about it, what if you're in situation...

    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 COUNT(*) vs DMVs to get row count

    Alan.B (4/10/2015)


    Ok, quick update... I did some research on this - it appears that sys.partitions does not guarantee an accurate row count. According to Microsoft, the rows column in sys.partitions...

    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 add a trigger that inserts original data from 1 table to another. With getdate() appended to 2nd table.

    Not exactly. They're more like :old and :new

    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 add a trigger that inserts original data from 1 table to another. With getdate() appended to 2nd table.

    As it has been noticed, on a trigger you should use inserted and deleted virtual tables.

    I'd use a different approach to be sure that the value on the column changed.

    CREATE...

    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: Are the posted questions getting worse?

    SQLRNNR (4/10/2015)


    Luis Cazares (4/10/2015)


    Someone just mentioned that you could have 2 clustered indexes on a table. But I'm sure he's high. 😀

    http://www.sqlservercentral.com/Forums/FindPost1676220.aspx

    But, think about it, what if you're in situation...

    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 Server 2008 Query Help needed

    Basically, you need a cross tabs solution with an additional row_number to define the order of your columns.

    Here's an article on cross tabs: http://www.sqlservercentral.com/articles/T-SQL/63681/

    And here's an example:

    WITH SampleData (PERSON, ACCOUNT,...

    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: Are the posted questions getting worse?

    Someone just mentioned that you could have 2 clustered indexes on a table. But I'm sure he's high. 😀

    http://www.sqlservercentral.com/Forums/FindPost1676220.aspx

    But, think about it, what if you're in situation where, if 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

Viewing 15 posts - 5,011 through 5,025 (of 8,731 total)