Viewing 15 posts - 1,216 through 1,230 (of 7,616 total)
Not much to go on, but, in general, just put the appropriate conditions in the WHERE clause:
DECLARE @key_value ...
DECLARE @col_value ...
SET @key_value = ...
SET @col_value = ...
UPDATE...
October 11, 2021 at 1:40 pm
Keep in mind, too, that the point of naming is to give accurate business names to objects, not to make things easier for developers. That is, just because a naming...
October 11, 2021 at 1:20 pm
With stored procedures, I like a 2-3 letter acronym at the start to define the process (adm for admin, fin for finance, etc) followed by _ and then what...
October 9, 2021 at 12:42 am
Give your databases names that reflect their business purpose. Don't use prefixes or suffixes in the name to indicate "database". MS got this half right: MS has dbs "master", "model",...
October 9, 2021 at 12:38 am
Make sure the D_Date table is uniquely clustered on Date (it should already be, but verify, just in case). I'd stick with a scalar function for now, but get rid...
October 7, 2021 at 2:54 pm
Actually, for an even number of rows, the median is the avg of the middle two (IIRC).
For example, for values:
1, 2, 3, 101, 200, 500 :: median is 52 (...
October 6, 2021 at 8:15 pm
Agreed, we need to see the code.
And, do you have a table with non-workdays in it? We'll need to know the DDL for that table to properly determine business days.
October 6, 2021 at 6:49 pm
That's not an accurate method to get a median value.
For example, if you have these values:
SELECT (MAX(value) - MIN(value)) / 2 + MIN(value)
FROM ( VALUES(1),(2),(3),(1000),(3000) ) AS data(value)
the median (middle) value...
October 6, 2021 at 6:46 pm
;WITH cte_add_row_nums AS (
SELECT *, ROW_NUMBER() OVER(PARTITION BY Id ORDER BY Branch) AS row_num
FROM #temp
)
SELECT id, branch, city
FROM cte_add_row_nums
WHERE...
October 6, 2021 at 12:57 am
You might be able to use a login trigger to deny the connection for those specific users if they were not coming from a linked server. You'd have to review...
October 5, 2021 at 3:30 pm
NTILE specifies the number of groups, not the size of each group. So in your example it should be 100 not 800.
For the sample data shown, 10 groups makes more...
October 5, 2021 at 1:55 pm
I agree with Phil. I would use a "holding" table to contain the data prior to it being summarized in 15-minute "packets" to be added to the main table.
October 5, 2021 at 1:44 pm
Scott, fyi...I do have a clustered index defined for the column that is the primary key - an IDENTITY column.
[UserId] [int] IDENTITY(1,1) NOT NULL,
CONSTRAINT [PK_User] PRIMARY KEY CLUSTERED (...
October 5, 2021 at 1:34 am
I
[1] To log in, I request a User Name. Should I have a non-clustered index on that column?
[2] Also, in another table, I query on the email address, should...
October 4, 2021 at 8:19 pm
Maybe something like this?:
ALTER TABLE dbo.your_table_name ADD REPORT_DATE AS CAST(DATEADD(DAY, CASE WHEN CREATE_TIME >= '18:00:00' THEN 1 ELSE 0 END, CREATE_DATE) AS date) PERSISTED;
...
WHERE REPORT_DATE = CAST(GETDATE() AS date)
October 4, 2021 at 5:39 pm
Viewing 15 posts - 1,216 through 1,230 (of 7,616 total)