Forum Replies Created

Viewing 15 posts - 8,461 through 8,475 (of 8,731 total)

  • RE: Combining multiple rows into one row for each id number

    Can you take a look at this article so we can help?

    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    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: Incorrect Syntax near ... when running a top SQL looking for performance issues

    Can you check the compatibility level of the database you're running the query on?

    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: Deriving a new DATETIME field column from an existing DayOfMonth column

    If it takes more than one day to arrive.

    SELECTFlightNumber,

    ScheduleDeptDate,

    ActualArrivalDay,

    ActualArrivalDate,

    CASE WHEN ActualArrivalDay >= DAY(ScheduleDeptDate)

    THEN DATEADD( dd, ActualArrivalDay - 1, DATEADD( mm, DATEDIFF( mm, 0, ScheduleDeptDate), 0))

    ELSE DATEADD( dd, ActualArrivalDay -...

    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: Order by a column keeping the families together

    Eugene Elutin (9/6/2012)


    Luis Cazares (9/6/2012)


    CELKO (9/6/2012)


    Most of the work (80-95%) in SQL is done in the DDL. Messy, complicated DML is almost always the result of poor DDL. This...

    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: Order by a column keeping the families together

    CELKO (9/6/2012)


    Most of the work (80-95%) in SQL is done in the DDL. Messy, complicated DML is almost always the result of poor DDL. This is what he needs!...

    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: Order by with case

    You're right, I missed that point.

    I wasn't aware of your second post when I wrote mine, that's why my solution is so similar.

    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: Order by a column keeping the families together

    CELKO (9/6/2012)


    SELECT CONVALESCE (upc, family_upc) AS item_upc, purchase_date

    FROM Inventory

    ORDER BY item_upc, purchase_date;

    CONVALESCE? I can't find these on any SQL books, just medicine.

    The design is poor? it...

    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: UNION vs LEFT JOIN...

    That's not exactly the same result.

    This might do it, but I can't test it:

    SELECT Movimentos.Id,

    Movimentos.Conta,

    Movimentos.ValorAlt,

    Movimentos.Dia,

    Movimentos.Diario,

    Movimentos.NumDiario,

    Movimentos.Documento,

    Movimentos.NumDoc,

    Movimentos.ContaOrigem,

    Movimentos.Descricao AS DescMov,

    Movimentos.Valor,

    Movimentos.Natureza,

    Movimentos.Iva,

    Movimentos.Selo,

    Movimentos.TipoConta,

    Movimentos.Entidade,

    Movimentos.Moeda,

    Movimentos.ClassOrgan,

    Movimentos.ContaOrc,

    Movimentos.Ano,

    --Change in here

    COALESCE( PlanoContas.Descricao, PlanoCentros.Descricao, PlanoFuncional.Descricao) AS DescConta,

    Diarios.Descricao AS DescDiario,

    DocumentosCBL.Descricao AS DescDoc,

    Movimentos.Cambio,

    Movimentos.CambioOrigem,

    Movimentos.ValorOrigem,

    Movimentos.TipoAfectacao,

    Movimentos.CambioMAlt,

    Movimentos.Linha,

    Movimentos.Mes,

    Movimentos.IdCabec,

    Movimentos.PercNdedutivel,

    Movimentos.IvaAutoLiquidacao,

    Movimentos.TipoLancamento,

    TiposLancamento.Descricao AS DescTipoLancamento

    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: Order by with case

    Using Eugene suggestion (@index is declared int to prevent injection, but might create errors):

    declare @index int = 2

    DECLARE @sql varchar(MAX)

    IF @index = 4

    select CityInternalID, CityDefaultName, CityCountryID...

    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: Deleting duplicate record

    That might be because Eugene already had a #demo table and didn't want to drop ti and create a new one.

    You can change the name to #demo.

    If you avoid windowing...

    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 find a Query in all stored procedure

    IMO, different queries, same result. Just like:

    SELECT CAST(SUBSTRING(CAST(FLOOR(NULLIF(ISNULL(COALESCE(1,NULL),NULL),NULL)) AS CHAR(1)),1,1) AS INT) AS one

    and

    SELECT 1 one

    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: CASE STATEMENTS

    Do you need both values?

    Or you're just adding them at the end?

    If you're just adding them, you just need to drop the filter and keep one 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: How to find a Query in all stored procedure

    I would say that those are different queries.

    It's not the same thing to have

    SELECT col1 FROM TableA

    or

    SELECT a.col1 AS mycol FROM TableA a

    Even comments would make a query different, but...

    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 find a Query in all stored procedure

    Eugene is right, there's no way to have accurate results.

    This are meant to be tools to help, not to automate a process.

    I was going to suggest you to generate 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: APPLY - 1

    Stewart "Arturius" Campbell (9/6/2012)


    Good question, Ron, thanks.

    There's an extra "=", other than that is valid.

    It was a good question, but I still can't find a great use of APPLY in...

    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 - 8,461 through 8,475 (of 8,731 total)