Forum Replies Created

Viewing 15 posts - 6,496 through 6,510 (of 7,619 total)

  • RE: Remembering that it is good to "get back to basics" every now and then

    code goes on to split the logic path based on @RecordCount = 0 vs. @RecordCount > 0.

    You shouldn't do a full count of the table for that either, btw; use...

    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 ... INTO NewTable without nulls

    mister.magoo (8/5/2013)


    Amy.G (8/5/2013)


    I am creating a table by using the

    SELECT column1, column2

    INTO NewTable

    FROM OldTable

    method. Is there a way of creating a table in this manner and saying if the columns...

    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: RECONFIGURE inside trigger

    Agreed, a trigger is not at all the best place for this type of thing.

    RECONFIGURE is not allowed to be part of a transaction. A modification trigger is inherently...

    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: Identifying SQL Agent Job Name based on the job id.

    The function below will return the job_id when you pass in the string with the "Job 0x...." (I've since discovered a perhaps better way, but can't find that code right...

    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: Moving Database That Has a Schema

    First, you have to be careful with terminology in SQL Server -- a login and a user are not the same thing.

    The login is at the server level, the user...

    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: Replace database with same database id

    Yeah, that's crazy.

    Is there any way you can "spoof" the database id so it can be something else in the real server but report back to the software what it...

    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: Grouping by columns to create single record

    Luis Cazares (8/1/2013)


    You could find this article useful

    http://www.sqlservercentral.com/articles/T-SQL/88244/

    SELECT AttribID

    FROM MyTable

    WHERE FormatID IN (12,15)

    GROUP BY AttribID

    HAVING COUNT(DISTINCT FormatID ) = 2

    EXCEPT

    SELECT...

    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: String Manipulation

    Technically it should be:

    LEFT(myString, CHARINDEX(' ', myString + ' ') - 1)

    unless you want a trailing space in the result :-).

    Adding the "+ ' '" will cause the code to...

    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: Find the last 6 Tuesdays or Wed or Whatever day.

    You can use the general calc shown below to get the nearest day of any day:

    SELECT

    date,

    DATEADD(DAY, DATEDIFF(DAY, '19000101', date) / 7 *...

    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: Index Fill Factor

    FILLFACTOR can have a major impact on performance, depending on the table and the data usage patterns.

    However, a FILLFACTOR of "80" is not necessarily good or bad in and of...

    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: Audit log for INSTEAD OF DELETE trigger

    webrunner (7/25/2013)


    Thanks, Scott,

    By "prevents the actual statement from running" do you mean the original DELETE statement? And then any code in the trigger after the ROLLBACK does get run? That...

    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: Audit log for INSTEAD OF DELETE trigger

    Eugene Elutin (7/25/2013)


    webrunner (7/25/2013)


    Thanks, Eugene, I see. I had commented out the ROLLBACK for my INSTEAD OF trigger so didn't understand the behavior you just posted with the test code....

    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: Audit log for INSTEAD OF DELETE trigger

    Easy enough to demonstrate that:

    USE tempdb --you can use a "real" db if you prefer

    GO

    IF EXISTS(SELECT 1 FROM sys.tables WHERE name = 'table1' AND schema_id = 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".

  • RE: Audit log for INSTEAD OF DELETE trigger

    Eugene Elutin (7/25/2013)


    Alexander Suprun (7/24/2013)


    Eugene Elutin (7/24/2013)


    RAISERROR cause transaction to rollback, so your log insert is rollbacked as well as delete...

    It's so untrue...

    RAISERROR has nothing to do with the transaction.

    It's...

    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: Audit log for INSTEAD OF DELETE trigger

    webrunner (7/24/2013)


    Alexander Suprun (7/24/2013)


    Remove ROLLBACK from the trigger and lower severity of RAISERROR to 10, in this case SSMS won't show any errors, rows will disappear from the UI (but...

    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 - 6,496 through 6,510 (of 7,619 total)