Forum Replies Created

Viewing 15 posts - 5,356 through 5,370 (of 7,614 total)

  • RE: Mortgage amortization table

    Change to money rather than more decimal places. I believe the law now restricts to 4 decimal places when calculating most interest accumulation.

  • RE: String as primary key

    Also, let's look at SQL's missing index and index usage stats for the table:

    USE [<your_db_name_here>] --change to desired db if not already there

    SET DEADLOCK_PRIORITY LOW --probably irrelevant, but just in...

  • RE: Insert data into Table variable but need to insert 1 or 2 rows depending on data

    Insert Into @OFBDATA

    (ShiftStartdate,

    ProdShiftcolor,

    Line,

    DieNo,

    Goodparts,

    ScrapParts)

    Select

    scrapdata.Rundate,ScrapData.ProdShiftcolor,ScrapData.Line,ScrapData.DieNo,

    case when which_row = 'F' then scrapdata.[Good parts F ] else scrapdata.[Good parts R ] END,

    case when which_row = 'F'...

  • RE: String as primary key

    Either cluster directly on the string itself. Or, if you don't want to do, encode the string into an int (or smallint if you have less than ~20,000 values)...

  • RE: Querying Last Quarter's data

    I think something roughly like this:

    (SELECT COUNT(DISTINCT daysworked) AS 'Days Worked'

    FROM (SELECT CAST(DATEPART(MM, DATEADD(HOUR, -8, ActualEnd)) AS VARCHAR) + '/' + CAST(DATEPART(DD, DATEADD(HOUR, -8, ActualEnd)) AS VARCHAR) + '/'...

  • RE: DEADLOCK PRIORITY issue

    That's interesting. I didn't realize SQL would convert that. Not sure exactly the optimizer knows when it's "safe" to do that.

  • RE: DEADLOCK PRIORITY issue

    mbhandari (2/25/2015)Thanks for your invaluable comments. I looked at the execution plans for IF( SELECT COUNT(*)... ) and IF EXISTS options and its giving me identical plan. But I am...

  • RE: DEADLOCK PRIORITY issue

    All true. However, you can improve the coding of the second query:

    Instead of:

    IF

    (

    SELECTCOUNT(*)

    FROMMY_CODE

    ) > 0 </frame>

    Use:

    IF EXISTS(SELECT TOP (1) 1 FROM MY_CODE)

    You're having...

  • RE: Default constraint?

    It is described in BOL. Under "ALTER TABLE", "table constraints". Notice that the text "[CONSTRAINT constraint_name]" is optional, followed by the required "DEFAULT constant_expression FOR column". Viz:

    ALTER...

  • RE: Using an expression in a GROUP BY clause

    Assuming you don't have a "TimeGroup" (as calc'd below) of 0, maybe this code will give you the exact result you want:

    SELECT

    Time_Min * 100 AS Time_Min,

    ...

  • RE: The Real World: Rebuilding Index - 1 Instance, 106 Databases

    No; in fact, you should not do that. The rebuild will use full statistics from the entire table, whereas updating the stats would just use a sampling of rows....

  • RE: MAXDOP, CPU Processors question!!!

    Hmm, the way I read it, you have only two physical processors, therefore MAXDOP should not exceed two.

  • RE: Find all tables used in any stored procedure

    smitty-1088185 (2/15/2015)


    Eirikur Eiriksson (2/14/2015)


    Quick suggestion, query the sys.sql_dependencies view

    😎

    SELECT

    OBJECT_NAME(SD.object_id) AS OBJ_NAME

    ,OBJECT_NAME(SD.referenced_major_id) AS DEPENDENT_NAME

    ...

  • RE: How would you set up your server?

    I assumed backups were going to a different drive.

    But the backup only gets you to the last backup time. To recover forward to the current time, you need either:...

  • RE: Efficient way to insert from foreign key lookups.

    INSERT INTO dbo.LiveTable

    (Information, MachineId, StatusId)

    SELECT s.Information,

    (SELECT m.MachineId

    FROM dbo.Machine m

    WHERE

    ...

Viewing 15 posts - 5,356 through 5,370 (of 7,614 total)