Viewing 15 posts - 5,626 through 5,640 (of 7,613 total)
Something else to check:
Did you explicitly specify the schema name of the table on the ALTER?
If not, make sure you are not accidentally working with a similar table / table...
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".
November 19, 2014 at 3:37 pm
D'OH, got interrupted by work, forgot one thing.
Let's see if we can also reduce the number rows in the dates side of the JOIN. I'm assuming here that "Sunday"/"Saturday"...
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".
November 19, 2014 at 3:00 pm
Yeah, that join is not being processed well.
First, try just forcing a HASH join, i.e. writing "INNER HASH JOIN" instead of just INNER JOIN: that should be better here than...
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".
November 19, 2014 at 2:40 pm
swhetsell (11/19/2014)
ScottPletcher (11/19/2014)
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".
November 19, 2014 at 2:22 pm
Better would be an inline-table-valued-function.
If you intend to stick with a scalar function, at least get rid of the variable:
create function dbo.fu_salesTotal(@idSale int)
returns decimal(12,2)
as
begin;
return isnull((
...
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".
November 19, 2014 at 2:20 pm
Didn't see the test data when initially coding. I had to add RCN to the ORDER BY in case there are duplicate times ... although it seems odd/counterintuitive 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".
November 19, 2014 at 2:03 pm
Probably the big thing is to reduce all the gyrations around UnitLog. Please try the query below. If you tend to restrict UnitLog rows using fldDateTime range, particularly...
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".
November 19, 2014 at 1:56 pm
If you're padding a numeric value, I'd suggest using the built-in function:
STR()
I suspect that will perform better than writing the same thing out in your own 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".
November 18, 2014 at 3:13 pm
Btw, keep in mind that for multi-key-column indexes, SQL's missing index output does not consider the best order for the keys, which they freely admit. From Books Online, they...
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".
November 18, 2014 at 2:57 pm
The first thing to do with indexing is to review index usage stats and missing index stats together, at a minimum. If you're really serious, you also look at...
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".
November 18, 2014 at 2:55 pm
So is XXXXXXXXXXX by itself unique across all sites?
Or do you need the YYY and ZZZ values to get a unique key? Do you always specify YYY...
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".
November 14, 2014 at 5:03 pm
For this query:
select * from A where ReceiptTS > '2014-09-30 00:00:00.000'
SQL will use the actual date value to estimate the number of rows returned that will be returned.
For this query:
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".
November 10, 2014 at 4:08 pm
measterbro (11/7/2014)
CREATE...
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".
November 10, 2014 at 4:04 pm
I think easiest would be to keep your own table of the original name and new name, then you can search for the original name in the history.
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".
November 10, 2014 at 3:55 pm
Do you have room on the target server for two copies of the db? If so, you have plenty of time, and can bring the second db fully current...
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".
November 10, 2014 at 3:53 pm
Viewing 15 posts - 5,626 through 5,640 (of 7,613 total)