Forum Replies Created

Viewing 15 posts - 1,591 through 1,605 (of 6,036 total)

  • RE: Extracting time from datetime adds a second? Why?

    Orlando Colamatteo (2/28/2016)


    Try this instead of going straight to a string:

    DECLARE @D DATETIME = '2016-02-28 19:04:51.997';

    SELECT CAST(CAST(@D AS TIME(3)) AS VARCHAR(8));

    It returns exactly the same result as the original conversion:DECLARE...

  • RE: Merge 2 identical table based on timestamp and column values

    INSERT INTO Table3 (MachineID, Timestamp, Account, BiosID, Serial number, Hostname )

    select MachineID, Timestamp, Account, BiosID, Serial number, Hostname

    FROM Table1

    WHERE NOT EXISTS (select * from Table3 where Table3.UniqueKeyCol1 = Table1.UniqueKeyCol1...

  • RE: Need help optimizing this stored proc

    Oh yeah, and this:

    (SELECT P.DateID FROM ADW.dim.Period P WHERE P.[Date] = IGY.DOS) AS Date_ID,

    (SELECT P.DateID FROM ADW.dim.Period P WHERE P.[Date] = IGY.PostDate) AS PostDate,

    ...

  • RE: Need help optimizing this stored proc

    First, you need to replace this strange piece of code:

    LEFT join ADW.DIM.Modality M

    ON SO.ModalityCode = M.ModalityCode

    JOIN ADW.dim.Department D

    ON D.DepartmentID = CASE WHEN M.departmentID is null then...

  • RE: CHECKING specific values

    patrickmcginnis59 10839 (2/24/2016)I got 2 rows if I set xact_abort on, maybe that's his default?

    Yep, spot on.

    Isn't it anyone's default?

    Same as ANSI_NULLS?

  • RE: CHECKING specific values

    The answer is plainly wrong.

    Did anyone of you guys who think "3" is a correct answer actually run the script in a batch?

    The question repeats the word "batch" so many...

  • RE: Using Parameters in a Query is Killing Performance

    If you cannot change the indexes than you can maximise the effect of existing ones.

    I may assume that ID's are generally inline with upsrt_dttm.

    There might be some deviations, but they...

  • RE: Using Parameters in a Query is Killing Performance

    Loner (2/19/2016)


    As I said before, the database is created from the software company, I cannot create any index.

    When a faulty part or design fault is discovered in certain model of...

  • RE: Inconsistent subquery results

    Agree with Hugo, you're using probably the worst possible way for the task.

    You better retrieve the list of all files in one go, using, say, xp_dirtree:

    EXEC master.sys.xp_dirtree 'C:\aaa\contracts\', insert...

  • RE: Multi-valued Parameter Query issue

    For non-delimited string you don't need a splitter, use just a Tally table:

    DECLARE @prmCallType VARCHAR(8000) = 'ABC';

    SELECT N, SUBSTRING(@prmCallType, N,1)

    FROM dbo.TallyGenerator(1, LEN(@prmCallType), 1) tg

  • RE: order of execution problem

    Can you see how many rows are actually updated by the first statement?

  • RE: Using Parameters in a Query is Killing Performance

    Phil Parkin (2/18/2016)


    As I'm sure you know, the clustered index actually does have to be unique. If the user-specified columns are not unique in themselves, SQL Server will add a...

  • RE: Using Parameters in a Query is Killing Performance

    Alan.B (2/17/2016)


    Sergiy (2/17/2016)


    Make the PK on UserID non-clustered and create a clustered index on UpdateDt.

    Unless UpdateDt is not unique. Then perhaps a clustered index on composite key consisting of UpdateDt...

  • RE: Sub query where clause returns nothing

    Jacob Wilkins (2/17/2016)


    Sergiy (2/17/2016)


    Since you're not returning anything from table t2 there is no point in using a JOIN.

    Check for existence would do just fine:

    select t1.[StockCode],t1.[SalesOrder],t1.[SalesOrderLine],t1.[LotNumber],t1.[Customer],

    t2.[ShipDate][/i],

    from table t1

    WHERE EXISTS...

  • RE: Sub query where clause returns nothing

    Since you're not returning anything from table t2 there is no point in using a JOIN.

    Check for existence would do just fine:

    select t1.[StockCode], t1.[SalesOrder], t1.[SalesOrderLine], t1.[LotNumber], t1.[Customer], t2.[ShipDate],

    from table...

Viewing 15 posts - 1,591 through 1,605 (of 6,036 total)