Viewing 15 posts - 5,011 through 5,025 (of 7,610 total)
drew.allen (6/19/2015)
By default, SQL Server joins tables in left-to-right order,
I'm not sure it's safe to make that blanket statement. I think SQL will join in whatever order it deems...
June 19, 2015 at 2:54 pm
Is the owning account a single user account? Or did it get changed into a group account or role?
When you use "EXECUTE AS OWNER" the owner cannot be a...
June 19, 2015 at 2:51 pm
UPDATE Sales
SET Sales.price = P.price
FROM Sales
CROSS APPLY (
SELECT TOP (1) price
FROM Price
WHERE Sales.itemId = Price.itemId AND
...
June 18, 2015 at 3:42 pm
That trigger is way too much overhead. The trigger itself cannot be dynamic. Instead, dynamic code should be used to generate a static trigger, which will need regenerated...
June 18, 2015 at 3:07 pm
I created minimum sample data, which I've included after the main code. I assumed you have a table that has a list of IDs -- if not, just uncomment...
June 18, 2015 at 3:03 pm
Please try this and see if it's right, or at least very close :-D. Btw, please add appropriate table aliases to all columns (scope_id, firstName (presumably CUS but not...
June 18, 2015 at 1:39 pm
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. ...
June 18, 2015 at 9:26 am
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')...
June 17, 2015 at 2:31 pm
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 (
...
June 17, 2015 at 12:01 pm
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
...
June 17, 2015 at 11:57 am
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 +...
June 17, 2015 at 9:38 am
Original code, for easy reference:
SELECT *
FROM Test
WHERE DATEDIFF(DAY, DischargeDate, ApptDate) <= ( 8 +
CASE DATEDIFF(DAY, 0, DischargeDate) % 7
...
June 17, 2015 at 9:23 am
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...
June 16, 2015 at 4:55 pm
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
(
...
June 16, 2015 at 3:55 pm
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 +
...
June 16, 2015 at 3:44 pm
Viewing 15 posts - 5,011 through 5,025 (of 7,610 total)