Forum Replies Created

Viewing 15 posts - 3,151 through 3,165 (of 7,613 total)

  • RE: how can we auto increment by 1 from the max ID with an update or an insert into to the same table.

    You didn't provide enough data to know that you want to INSERT, but you likely want something along these lines:


    INSERT INTO [dbo].[SomeCause] ( SomeID, SomeType,...

    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".

  • RE: error concatenating parameter inside exec


    exec('declare @testvar nvarchar(128); select top (1) @testvar = NameSchema from #TempCommonMatchFormatted; select @testvar as testvar')

    If you want to return a value(s) to a...

    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".

  • RE: Looking for advice on error logging.

    The code looks good to me.  I think it's better to test row existence outside the TRY.

    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".

  • RE: Where would you use XACT_STATE

    You use XACT_STATE() to:
    (1) avoid attempting a ROLLBACK or COMMIT when a trans is not active
    (2) to know whether to do a ROLLBACK or COMMIT in certain cases (if...

    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".

  • RE: Select Number of Times a Product sold per minute

    I can't tell specifically what you need, but I suggest using the "standard" approach to adjust a datetime to a given boundary.  For example, the code below totals by MINUTE,...

    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".

  • RE: Table Joining

    As to the query plans for these:

    SELECT A.FirstName, A.LastName, B.Location
    FROM TableA A
    LEFT OUTER JOIN TableB B
    ON A.PersonId = B.PersonId AND B.Location = 'London'

    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".

  • RE: move sql database files to bigger drive

    my question - once sql is restarted all databases will come back online using same drive letter path? correct? 

    Yes, the E:\ paths will be the same, if...

    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".

  • RE: Compare Table Contents Procedure

    You should also look at tablediff.exe to do that. 

    Yeah, being a command-line utility it's a little quirky to get used to, but I've found it works well...

    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".

  • RE: bcp with Quote Text Qualifier and Comma Delimiter

    Use:
    -t ","

    instead of:
    -t "|"

    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".

  • RE: How can I get a set Date and Time Range between Yesterday and Today?

    drew.allen - Tuesday, September 18, 2018 11:56 AM

    This is shorter, but many people don't like it for some reason.

    SELECT DATEADD(DAY,...

    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".

  • RE: Is there a way to identify the offending column in "conversion failed when converting the varchar value to data type int"?

    I'm guessing the error was about conversion to int, based on your comments, but it would be nice to be sure.
    If so, run a pre-audit on the source data...

    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".

  • RE: How can I get a set Date and Time Range between Yesterday and Today?


    SELECT
      @StartDt = DATEADD(HOUR, 6, DATEADD(DAY, DATEDIFF(DAY, 0, GETDATE()) - 1, 0)),
      @EndDt = DATEADD(HOUR, 1, DATEADD(DAY, DATEDIFF(DAY, 0, GETDATE()), 0))

    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".

  • RE: Is there a better way to write a simple query?

    Lynn Pettis - Tuesday, September 18, 2018 7:49 AM

    Chris Wooding - Tuesday, September 18, 2018 7:11 AM

    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".

  • RE: Is there a better way to write a simple query?

    Chris Wooding - Tuesday, September 18, 2018 7:11 AM

    ScottPletcher - Monday, September 17, 2018 3:24 PM

    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".

  • RE: Why such a big log size?

    MERGE is notorious for some performance issues. You might want to try "UPSERT" -- an equivalent UPDATE followed by an INSERT.

    For overall performance,, make sure you have...

    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 - 3,151 through 3,165 (of 7,613 total)