Forum Replies Created

Viewing 15 posts - 1,531 through 1,545 (of 6,036 total)

  • RE: Convert a string with an array of variables?

    mceventphoto (3/31/2016)


    Drew,

    I like your solution better. It is short and clean.

    Thanks,

    MC

    Which one are you talking about?

    I can't find any solution posted by Drew in this thread.

  • RE: Convert a string with an array of variables?

    drew.allen (3/31/2016)


    It's actually MUCH faster to create a table using the VALUES expression, because most of the cost is writing and reading the temp table to tempdb. If you...

  • RE: Convert a string with an array of variables?

    Alan.B (3/31/2016)


    How would this be applied against a column in a table?

    It depends.

    Simplest way would be to add a new column, create a scalar function out of the script...

  • RE: Convert a string with an array of variables?

    drew.allen (3/31/2016)


    It's actually MUCH faster to create a table using the VALUES expression, because most of the cost is writing and reading the temp table to tempdb. If you...

  • RE: Convert a string with an array of variables?

    Phil Parkin (3/31/2016)


    Nice solution, Sergiy. You taught me a new trick!

    The execution plan is interesting: 75% on a 'clustered index update'. Of what?

    You welcome.

    Takes a twisted mind to come up...

  • RE: Convert a string with an array of variables?

    Solution is suprisingly simple.

    1. Create a "translation" table:

    CREATE TABLE #Mapping (

    FromChar NCHAR(1) PRIMARY KEY,

    ToChar NCHAR(1)

    )

    INSERT INTO #Mapping ( FromChar, ToChar )

    SELECT 1, 'A'

    UNION ALL

    SELECT 2, 'B'

    UNION ALL

    SELECT 3,...

  • RE: Creating a Dynamic Temp Table

    JediSQL (3/28/2016)


    Yes, there is a lot of dynamic SQL involved, but given that new views I need data from are constantly being crated in the remote database, I do not...

  • RE: Elementary ? regarding distinct select query

    ...

    INNER JOIN #distinctSubscriptionKeys d ON s.sub_id = d.distinctSubscriptionKey

    INNER JOIN (

    select sub_id, country_code, sub_user_number

    from PHONENUMBERS

    WHERE e.comm_type = 'v'

    GROUP BY sub_id, country_code, sub_user_number) e ON s.sub_id = e.sub_id

    LEFT JOIN sirens t

    ...

  • RE: Type conversion may affect CardinalityEstimate

    drew.allen (3/30/2016)


    Sergiy (3/29/2016)


    You're inserting varchar values 'DY1' DayNo into nvarchar(4) column.

    It causes an implicit conversion and consequently, the warning.

    If you either change the datatype to varchar(4) or use N'DY1'...

  • RE: Error in dynamic sql

    sks_989 (3/29/2016)


    Thanks but i still have issue after 43667 char.

    3. 43667 char is way beyond 8000 bytes limitation.

    What would be the character 43668?

  • RE: Error in dynamic sql

    1. Restore PRINT commands for "in sql" variables and see what do they return.

    Look especially for single quotes or square brackets.

    2. Get rid of the cursor and replace it with...

  • RE: Type conversion may affect CardinalityEstimate

    You're inserting varchar values 'DY1' DayNo into nvarchar(4) column.

    It causes an implicit conversion and consequently, the warning.

    If you either change the datatype to varchar(4) or use N'DY1' DayNo instead,...

  • RE: Creating a Dynamic Temp Table

    JediSQL (3/23/2016)


    Then I can do something like this where the added columns are dynamically constructed instead of being hard coded:

    OK, let's pretend you've achieved what you want.

    Like in the last...

  • RE: Strange behaviour

    The question, as it's been asked, has a very simple answer:

    remove that column you added recently from the index - everything should be back where it was before.

  • RE: Date Format

    set edatetime=dateadd(mi,datediff(mi, 0, getdate()) + 50, 0)

Viewing 15 posts - 1,531 through 1,545 (of 6,036 total)