Forum Replies Created

Viewing 15 posts - 4,666 through 4,680 (of 7,597 total)

  • RE: scrub data in 5 minute intervals

    It's best to delete by the clustering key.

    Therefore, what is the table clustered on? If it's clustered on identity -- gack! -- but you have an index...

  • RE: Find All Items That Call a Stored Procedure

    For SQL jobs, you could do something like this:

    SELECT j.name, js.*

    FROM msdb.dbo.sysjobsteps js

    LEFT OUTER JOIN msdb.dbo.sysjobs j ON j.job_id = js.job_id

    WHERE js.command LIKE '%sp[_]MysteryProcedure%'

  • RE: Ways to improve record deletion speed

    Jeff Moden (11/1/2015)


    Mike Good (10/16/2015)


    FWIW - We have successfully used same method proposed by Kristen-173977 for many years, for both batched DELETEs and UPDATEs. The only difference is we...

  • RE: product join - how to avoid?

    You didn't even indicate which table every columns comes from.

    Is indexdate in temp1 or temp2?

    Is transdate in temp1 or temp2?

    Why do you need DISTINCT?

  • RE: Best Practice use of Synonyms to reference Other-Database Tables

    I suggest using synonyms for all such remote tables. But use only logical names, that reflect the business purpose, not any physical attributes (server name / location / etc.)....

  • RE: Paths not well defined for databases

    It's easy to forget, but drives can, and do, fail. Sometimes they become so damaged/corrupt they cannot be read. If that happened, obviously you would lose all your...

  • RE: Index and Optimiser question.

    Again, column "F" seems to figure in every one of your searches. If that's true, cluster the table on F first. You might be able to eliminate some...

  • RE: Index and Optimiser question.

    GilaMonster (10/30/2015)


    ben.brugman (10/30/2015)


    The Question was:

    Can SQL-server use an index and then use the covering index to collect the data?

    (And therefore not using the 'main' table).

    The answer is No.

    What you'll see...

  • RE: Index and Optimiser question.

    It depends. If the nonclustered index contains all columns needed to satisfy the query, SQL will not go back to the main table.

    If you (almost) search the table by...

  • RE: Help with While Loop

    DECLARE @KEYIDVALUE varchar(30) = ''

    DECLARE @BASECODE varchar(10)

    DECLARE @ASSETUID varchar(15)

    DECLARE @CATCODE varchar(10)

    DECLARE @COMPONENTNO varchar(3)

    DECLARE @QUALRATING INT

    DECLARE @MISSIONRATING INT

    DECLARE @CURRENTDATE varchar(8)

    DECLARE cursor_assets CURSOR LOCAL FAST_FORWARD FOR

    SELECT Asset_UID + CatCode,

    ...

  • RE: Varchar invalid for sum operator

    Try this:

    select sum(cast(cast(replace(Enter_your_field_name, ',', '') as decimal(28, 6) as int)) from Table_name

  • RE: Foreign Keys

    Fwiw, here's my version of it, with an optional TRUNCATE (currently commented out) of the tables in between the DROP and ADD. I use this script, for example, to...

  • RE: Trigger and email notification

    Eugene Elutin (10/28/2015)


    Lowell (10/28/2015)


    Sergiy (10/27/2015)


    I would strongly recommend not to run sending emails or any other kind of external operations from a trigger.

    And glitch in the functionality beyond SQL Server...

  • RE: Date Function (Possibility)

    SQLPain (10/27/2015)


    Thanks Scott, I got your point and it makes sense. but somehow its still not giving me the desired result. If I run your above statement without the GROUPBY...

  • RE: Date Function (Possibility)

    The MIN and MAX need to operate on the dates in the table, not on GETDATE(), therefore more like this:

    SELECT LoanID As [Loan ID]

    FROM APayments

    Where DraftDate > DATEADD(DAY, DATEDIFF(DAY, 0,...

Viewing 15 posts - 4,666 through 4,680 (of 7,597 total)