Forum Replies Created

Viewing 15 posts - 5,341 through 5,355 (of 7,597 total)

  • 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

    ...

  • RE: How would you set up your server?

    Ideally you want to be able to recover the db if either drive fails, or is completely destroyed even.

    Currently only "A" gives you that.

    In theory "B" might work, if every...

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

    There is no such thing as an accurate, global freespace percentage. Freespace needs to be set index by index. Thus, a generic rebuild should never specify a fillfactor,...

Viewing 15 posts - 5,341 through 5,355 (of 7,597 total)