Forum Replies Created

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

  • 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?

  • 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 -...

  • 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...

  • 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!...

  • 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.

  • 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...

  • 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...

  • 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...

  • 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...

  • 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

  • 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.

  • 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...

  • 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...

  • 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...

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