Forum Replies Created

Viewing 15 posts - 706 through 720 (of 7,619 total)

  • Reply To: Performance on large table -Index Creation

    Drop the existing index.

    Assuming that the column is datetime and not just time, create a clustered index on the datetime column.

    It would be better to use datetime2 type to reduce...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • Reply To: Purging / deleting ExternalMailQueue which has around 700,000 records

    Maybe try:

    EXEC msdb.dbo.sysmail_delete_mailitems_sp

     

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • Reply To: Import Agent job history from another server

    No problem.  Let me know if you need help on getting the correct job_id to add to the sysjobhistory table.

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • Reply To: Import Agent job history from another server

    You can't restore an older version msdb over another msdb anyway, no matter what.

    You could, however, restore the msdb db to a different db name (e.g. msdb_old).

    I think you could...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • Reply To: search index

    It doesn't.  You're wayyyy over-analyzing this.  Again, it's a simple q with a simple answer.  Save the big analysis for a more significant q.

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • Reply To: Query Help

    select T.*, T2.VAL

    from @T T

    outer apply (

    select top (1) t2.*

    from @T t2

    where t2.ID <= T.ID and

    t2.VAL is not null

    order by t2.ID desc

    ) as T2

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • Reply To: Date vs Datetime recommendation

    2.  If the value is a date only, use a date data type, period.

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • Reply To: search index

    Jeff Moden wrote:

    Who says?  It didn't specify anything about the table.  Consider it to be "most convenient". 😀

    The OP said:

    you want to search for all users who have an email "@gmail"'

    The...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • Reply To: Extracting first three words from Address field

    SELECT [FIRST_THREE_WORDS] = LEFT(ADDRESS + ' ', CHARINDEX(' ', ADDRESS + ' ', CHARINDEX(' ', ADDRESS, CHARINDEX(' ', ADDRESS + ' ', 0)+1)+1))

    FROM ( SELECT '123 Main Street' ) AS...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • Reply To: search index

    Jeff Moden wrote:

    ScottPletcher wrote:

    That is a simple q, I say give it a simple answer.  There's no need to over-analyze every q or nit pick its wording.

    You're missing the point, Scott. ...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • Reply To: search index

    That is a simple q, I say give it a simple answer.  There's no need to over-analyze every q or nit pick its wording.  Of course interview qs don't contain...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • Reply To: Missing Data(finding the root problem)

    If there's any possibility that the NOT IN column checked can be NULL, then you need to explicitly exclude NULL(s).  It doesn't sound like it could be NULL for this...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • Reply To: search index

    Naturally b is the answer to that specific question.

    As to why:

    (1) the table has 1M rows; therefore, creating an index with only the columns you need will typically drastically cut...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • Reply To: Record with same process id > 1

    SELECT User, ProcessId, COUNT(*) AS ProcessDupCount

    FROM dbo.table_name

    GROUP BY User, ProcessId

    WHERE ProcessId > 1

    HAVING COUNT(*) > 1

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • Reply To: Issue "Error converting data type varchar to numeric."

    This should give you the data type of the column:

    SELECT TOP (1) wf.SMP_FLAG

    INTO #temp

    FROM WF_SMP wf

    EXEC tempdb.sys.sp_help #temp

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

Viewing 15 posts - 706 through 720 (of 7,619 total)