Viewing 15 posts - 3,781 through 3,795 (of 7,610 total)
The first required step in getting reasonably decent table designs is to get rid of the myth that every table has to have an identity column and, far worse, should...
July 18, 2017 at 11:12 am
Table variables are almost always much slower than temp tables. I wouldn't use table variables unless I knew it was only 1 or 2 rows, ever, period, or I had...
July 14, 2017 at 11:43 am
If he is actually doing a SELECT ... INTO #temp, that could cause blocking, perhaps long blocking, but it normally wouldn't cause true "deadlocks". Is it an actual deadlock or...
July 14, 2017 at 9:26 am
That's a system-generated constraint name for an implicit DEFAULT constraint, such as:
USE tempdb;
CREATE TABLE table1 ( column1 int DEFAULT 0 );
EXEC sp_help 'table1';
DROP TABLE table1;
July 13, 2017 at 8:54 am
If you want to apply a table-valued function to a string from a table, you need to use APPLY, typically CROSS APPLY. Something like this:
SELECT *...
July 6, 2017 at 9:55 am
For that one query, try putting the variables into a (keyed) temp table (not a table variable), then joining to that table.:
CREATE TABLE #ids ( id...
July 5, 2017 at 11:46 am
There's an off chance the slowness has to do with log space, particularly if not in tempdb.
How much total space is the new table? If it's large, make...
July 5, 2017 at 11:41 am
In the real world, I've seen the method (1) style used quite a bit. Yes, it does violate 1NF, but it's pragmatic for the task at hand. Bottle size would...
July 3, 2017 at 11:23 am
Most typically in SQL Server I see this technique used:
SELECT TOP ...
FROM dbo.table_name
ORDER BY NEWID()
I presume that gives a roughly random sample. Of course...
June 29, 2017 at 9:57 am
June 27, 2017 at 12:02 pm
Most of the world uses ISO 5218 (0 = unknown, 1 = male, 2 = female, 9 = lawful person)
I've never seen that, and I've been in...
June 22, 2017 at 2:11 pm
I was in hurry so my code isn't what I'd normally do. Normally I'd calc only the first/last Monday, then simply subtract/add 7 days to that for other dates. There's...
June 22, 2017 at 8:17 am
The method below is math only, and thus very efficient; works under all date settings; and is flexible/reusable for other days / months / etc..
DECLARE...
June 21, 2017 at 2:25 pm
You can use APPLY to effectively assign alias names to expressions / results. You can even nest APPLYs so that the alias from one is used in the next one.
June 21, 2017 at 10:20 am
If you want a rolling 60 months:
WHERE OpenDate >= DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()) - 60, 0) /* or -59 if you count the current month...
June 16, 2017 at 11:27 am
Viewing 15 posts - 3,781 through 3,795 (of 7,610 total)