Viewing 15 posts - 241 through 255 (of 7,613 total)
SELECT T3.SYMBOL,
T3.TRADE_DATE,
(AB30_C + AB30_P + AB30_G + AB30_R + AB30_Y) / NULLIF(SUM(CASE WHEN AB30_C = 0 THEN 0 ELSE 1 END + CASE WHEN AB30_P = 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".
March 5, 2024 at 9:48 pm
I would think you would want four ids:
drive full path (other than drive, of course) filename extension
When new data comes in, you'd pre-add any new ids before loading 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".
March 4, 2024 at 8:12 pm
I would think you would want four ids:
drive
full path (other than drive, of course)
filename
extension
When new data comes in, you'd pre-add any new ids before loading the main table. That way...
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".
March 4, 2024 at 2:24 pm
Somewhat confusing, the right join looks odd, but, anyway, you might try this and see if it produces the result you need:
;WITH DUniques AS (
...
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".
February 29, 2024 at 4:40 pm
You've got some choices, some more annoying than others:
(1) Use an INSERT trigger to check for dups and cancel if a dup would be created.
(2) Create additional columns that are...
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".
February 27, 2024 at 7:21 pm
That's somewhat confusing. Do you want to not allow mixed case at all? Or do you just want to prevent a duplicate from being inserted, basically ignoring case in determining...
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".
February 27, 2024 at 6:53 pm
;WITH Cte_Persons AS (
SELECT *, ROW_NUMBER() OVER(PARTITION BY Name ORDER BY Id) AS Row_Num
FROM @TBLPERSON
)
SELECT
Name,
...
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".
February 26, 2024 at 7:27 pm
You can't use declared RI, but you could write your own.
As to the design, I assume the EntityIDs of the various tables -- Person, Service, Organisation, etc. -- overlap. That'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".
February 20, 2024 at 2:56 pm
I think my code would adjust as follows to check program_date for inclusion:
SELECT ca1.*
FROM dbo.cust_sales_temp cst
CROSS APPLY ...
FROM (
SELECT month#, sales, ROW_NUMBER() OVER(ORDER...
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".
February 16, 2024 at 8:12 pm
SELECT ca1.*
FROM dbo.cust_sales_temp cst
CROSS APPLY (
SELECT cst.customer_id, cst.program_date,
MAX(CASE WHEN row_num = 1 THEN sales...
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".
February 16, 2024 at 7:03 pm
Recursion is notoriously slow for iteration. Maybe use a "standard" tally table instead:
;WITH
cte_tally10 AS (
SELECT * FROM (VALUES(0),(0),(0),(0),(0),(0),(0),(0),(0),(0)) AS numbers(number)
),
cte_tally100 AS (
...
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".
February 16, 2024 at 2:41 pm
CREATE VIEW must be in a batch by itself, i.e., without GOs, you could create only one view per script.
Since GOs are likely not valid, that may be what you...
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".
February 14, 2024 at 7:22 pm
In this case it doesn't. But what is the harm in CASTing?
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".
February 13, 2024 at 10:47 pm
The first three rows in the table DO all match the first "<" condition: 00:05:xx and 00:10:xx are less than 00:15:xx. Only the second condition limits the result 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".
February 13, 2024 at 7:53 pm
For example, when the lengths are consistent, it seems to produce the desired result:
DROP TABLE IF EXISTS #xr;
CREATE TABLE #xr ( length_min varchar(8) NOT NULL, length_max varchar(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".
February 13, 2024 at 7:49 pm
Viewing 15 posts - 241 through 255 (of 7,613 total)