Forum Replies Created

Viewing 15 posts - 5,026 through 5,040 (of 7,619 total)

  • RE: Running DBCC CHECKIDENT ('shema.table', RESEED, 0) from a Stored Proc?

    With this method, the web login/user can use only procs that you're explicitly given the web app authority to execute. I don't know how to lessen the risk. ...

    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: Running DBCC CHECKIDENT ('shema.table', RESEED, 0) from a Stored Proc?

    You could try this:

    1) create a separate "power user" that has ddladmin authority in that db

    2) create a stored proc that runs under the power user account (EXEC AS 'power_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: scalar function returning zero when it shouldn't

    For best performance, get rid of all unnecessary variables in functions.

    Edit: Changed COUNT to COUNT_BIG based on return data type.

    CREATE FUNCTION dbo.spGet_Rec_Count

    (

    @source_tbl varchar(100)

    )

    RETURNS bigint

    AS

    BEGIN

    RETURN (

    ...

    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 Clause, Indexes and and Calculations

    I'd put it all in the JOIN clause, since that's what those conditions effectively are:

    DELETE x

    FROM TableX x

    INNER JOIN TableY y ON (x.Id = y.Id) AND

    ...

    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 appointments within 7 days, excluding weekends.

    Sure. 8 works for 7 days, and 1 should work for 2 days. The weekend adjustment is the same.

    SELECT *

    FROM Test

    WHERE DATEDIFF(DAY, DischargeDate, ApptDate) <= ( 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: Find appointments within 7 days, excluding weekends.

    Original code, for easy reference:

    SELECT *

    FROM Test

    WHERE DATEDIFF(DAY, DischargeDate, ApptDate) <= ( 8 +

    CASE DATEDIFF(DAY, 0, DischargeDate) % 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: How to batch delete large table?

    I think you're adding enormous amounts of overhead to this process. How about something like below? I'm not 100% sure on the logic for EventDate being NULL, so...

    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: Confused about what function to create

    I'd stick with a straightforward scalar function for that. For any column that can't have NULL values, naturally you can remove the IS NULL conditions.

    CREATE FUNCTION dbo.Compare_User_Settings_To_Profile

    (

    ...

    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 appointments within 7 days, excluding weekends.

    I don't like to use WEEKDAY as it has dependencies on @@DATEFIRST. Maybe this setting-independent method instead:

    SELECT *

    FROM Test

    WHERE DATEDIFF(DAY, DischargeDate, ApptDate) <= ( 8 +

    ...

    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: Problem in procedure

    No, an explicit COMMIT will lock in the transactions.

    But if an explicit BEGIN TRANS was issued and either:

    1) a COMMIT has not yet been issued for that trans

    or

    2) a ROLLBACK...

    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: Problem in procedure

    Is there a possibility the transactions for table Purchase Order not have been committed, so when the second procedure is running does not select correctly?

    It's certainly possible, particularly if 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".

  • RE: Problems with TRANSACTIONS after moving to a new server

    Get rid of @TransactionActive. And don't use @@TRANCOUNT either. And since you're not using SAVE TRANSACTION, the names on the TRANSACTION statement are superfluous and can be removed.

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

  • RE: Need Help with SELECT Statement

    The syntax is actually perfect.

    You might need to use A.User_ID rather than A.EffectedUser_ID in the CASE statement, I'm not sure which one you need based on your description, but other...

    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: Question regarding database architecture

    That's a valid point, but, from what I've seen, it will just not be possible to force all clients to the current version. They delay for all sorts 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: Question regarding database architecture

    Our company has that exact situation. Just accept that you will have different "versions" of the product in effect for different clients at different times. It's just too...

    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 - 5,026 through 5,040 (of 7,619 total)