Viewing 15 posts - 31 through 45 (of 274 total)
It really is fascinating sometimes. Often do a double-take at what the optimizer is actually doing to satisfy requests.
October 29, 2010 at 9:04 am
IIRC, you should also always be careful to screen out NULL values when using IN / NOT IN (really generally you should avoid IN / NOT IN, and instead use...
October 28, 2010 at 4:26 pm
Pulling ranks, huh?
Lol, nah.
I love your technique, it's great. I like that general method -- every 7 days is always the same weekday -- rather than any method...
October 28, 2010 at 12:37 pm
Another minor point. I deeply disagree with the use of:
FROM master..spt_values
...
October 28, 2010 at 12:06 pm
Or maybe this, since PARTITION BY generally seems to be pretty fast in SQL Server:
;WITH cte1 AS (
SELECT ROW_NUMBER() OVER (PARTITION BY vSurname, cPostcode, cCoverType ORDER BY vSurname)
...
October 28, 2010 at 12:01 pm
That query will only include rows where the condition is true, so assuming 5 such rows exist, I think it will always return 5.
I assume by "last 5" you mean...
October 27, 2010 at 4:30 pm
For INNER joins only, I don't think the sequence really matters. SQL will re-arrange the joins as it needs to.
For any type of OUTER join, as you've already seen,...
October 27, 2010 at 8:17 am
"join is a relationship between two and only two tables"
That's an interesting idea. I guess it depends on one's point of view. Let's consider a more...
October 26, 2010 at 3:30 pm
Replace "4" with:
4 + SUBSTRING('0012221', DATEDIFF(DAY, '19000101',
DATEADD(month, DATEDIFF(month, 0, '20100301'), 0)) % 7 + 1, 1)
SQL's base date, 19000101, is a Monday. So the...
October 25, 2010 at 9:49 am
Typically table-based UDFs are not in themselves a performance issue.
So the issue is more likely what you and others have mentioned:
indexes, stats, or the actual code in the...
October 19, 2010 at 12:14 pm
Correction, I forgot one thing:
EXEC master.dbo.xp_cmdshell @bcp_cmd
That way you can run it from any db.
October 14, 2010 at 11:25 am
To run bcp -- or any other .exe from SQL -- you need to have an environment that the .exe can run in.
For example, you could do something like this:
EXEC...
October 14, 2010 at 10:14 am
Yeah, INs can have odd results, and are horrible for performance.
Try NOT EXISTS(), viz:
INSERT INTO contacts (email, business)
SELECT email, business
FROM scrapes s
WHERE (dbo.vaValidEmail(email) = 1)
AND (NOT EXISTS(SELECT...
October 12, 2010 at 12:44 pm
SELECT CSP.P_Degree_Name, D2.DegreeID
FROM dbo.Staging_Providers CSP
INNER JOIN dbo.Degrees D ON D.Degree_Name = CSP.Provider_Degree
LEFT OUTER JOIN dbo.Degrees D2 ON D2.Degree_Name = CSP.P_Degree
You don't really even need the CASE then because if...
October 12, 2010 at 12:08 pm
If you're using dynamic SQL anyway, why not remove all references to B3 when "B3.NameSearch" is NULL, since in that situation B3 isn't needed/used anyway?
October 4, 2010 at 4:48 pm
Viewing 15 posts - 31 through 45 (of 274 total)