Forum Replies Created

Viewing 15 posts - 6,571 through 6,585 (of 7,608 total)

  • RE: Max or Top 1 more efficient

    Just in case, IF you already have an index on ( YearValue, MonthValue ), then this should be extremely fast:

    SELECT

    MAX(YearValue) AS YearValue, MAX(MonthValue) AS MonthValue...

  • RE: Script to find specific schema_owner for all databases

    Sorry, forgot I ended up using a database-specific function in the code (was trying to avoid it). This approach should be safer overall anyway:

    EXEC sp_MSforeachdb N'

    IF ''?'' IN (''master'',...

  • RE: SQL Server equivalent for MySQL's Substring_index

    SQL Server does not have an equivalent to that function or functionality :-(.

  • RE: Database Data File Physical Fragmentation From Small Auto-Growth Setting

    Yeah, that's the official story. But I don't 100% buy it.

    With that many different fragments, if I were you, I'd run contig.exe on that(those) file(s) anyway.

  • RE: Script to find specific schema_owner for all databases

    Here's something more detailed. Btw, I avoided using I_S.SCHEMATA for the schema names because of the associated warnings in Books Online -- it's best to avoid using I_S views...

  • RE: Help with Triggers

    Dird (4/23/2013)


    Evil Kraig F (4/22/2013)


    There's no cursor in his solution.

    Is there any documentation/book which proves this? Oracle would be running implicit cursors here; I have a hard time...

  • RE: Help with Triggers

    Dird (4/22/2013)


    ScottPletcher (4/22/2013)


    unless you use cursors, and nobody wants that

    And you think that solution isn't implicitly using cursors?

    Edit: But yeah, it's a better way of doing it 😛

    Dird

    I know my...

  • RE: Help with Triggers

    SQL Server triggers only fire once per statement, no matter how many rows are INSERTed or UPDATEd (or DELETEd).

    Therefore, it's not safe to use variables to get column data (unless...

  • RE: Make a select from three columns (with case expression)

    I suggest adding a computed column to the table to determine the value: then the definition is only one place, and is thus very easy to change everywhere:

    ALTER TABLE dbo.tablename...

  • RE: Searching Database tables for a specific value within a database field

    The code's not really ready to be used in dev or QA either.

    NO reason to search the same table multiple times, esp. not once per column.

    Instead, should do a single...

  • RE: Convert IP address to Binary (32)

    Here's T-SQL code to generate the full @decode_string:

    DECLARE @decode_string char(2055)

    ;WITH

    cteDigits AS (

    SELECT 0 AS digit UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT...

  • RE: Convert IP address to Binary (32)

    The @decode_string needs a slight adjustment, moving the decode value for "255" to the end of the string.

    As there's really no need to recompute the string every time, let's just...

  • RE: Convert IP address to Binary (32)

    I don't think it's really that complex.

    I suggest a single lookup/"decode" string, with eight bytes per ip code; I'd also use a leading 7 "filler" 🙂 bytes, just to make...

  • RE: Rounding up

    dr.mannhattan (4/9/2013)


    ROUND(ISNULL ((SL2.Importe - SL2.Propina - SL2.ScAmt) -((SL2.Importe - SL2.Propina - SL2.ScAmt)/ 1.16),0), 2, 1) As ImpIVA, --the final ", 1" on the ROUND function "tells" it to truncate,...

  • RE: Rounding up

    SQL will automatically cast the result to the receiving data type; cast will automatically round.

    To prevent rounding, you can explicitly use the ROUND function yourself (kinda ironic):

    ROUND(ISNULL ((SL2.Importe - SL2.Propina...

Viewing 15 posts - 6,571 through 6,585 (of 7,608 total)