Viewing 15 posts - 811 through 825 (of 1,246 total)
Something like this...
IF OBJECT_ID('tempdb..#temp', 'U') IS NOT NULL
DROP TABLE #temp;
SELECT
x.Date,
x.Type,
x.Value
INTO #temp
FROM ( VALUES
('2016-09-16 00:00:00.000', 'Schema', 'dbo'),
('2016-09-16 00:00:00.000', 'Table', 'Employer'),
('2016-09-16 00:00:00.000', 'Index', 'EmployerIdx'),
('2016-09-16 00:00:00.000', 'fragmentation', '43.851409052'),
('2016-09-16 00:00:00.000', 'page_count', '23420'),
('2016-09-16 00:00:00.000',...
September 26, 2016 at 8:00 pm
Good call Scott... I wasn't even thinking of the "“approximate number of rows for this partition” gotcha...
Thanks for the reminder. 🙂
September 23, 2016 at 1:23 pm
Here's an easy option to clean up the existing empty tables...
DECLARE @DropTables VARCHAR(8000) = '';
SELECT
@DropTables = CONCAT(@DropTables, CHAR(13), 'DROP TABLE ', s.name, '.', o.name, ';')
FROM
sys.objects o
JOIN sys.schemas s
ON o.schema_id =...
September 23, 2016 at 12:54 pm
If you're making the jump a version previous to 2012 to a version that 2012 or later...
The newly added windowing functions and the addition of window frames...
September 23, 2016 at 12:03 pm
Are these tables going to be repopulated after they're truncated? If not, why would you keep these tables at all (truncate rather than drop)?
September 23, 2016 at 11:54 am
Here's another option...
DECLARE @StartTime1 TIME = '17:41:00.0000000';
DECLARE @StartTime2 DATETIME = '2016-09-22 17:41:14.810';
if @StartTime1 = CAST(DATEADD(mi, DATEDIFF(mi, 0, @StartTime2), 0) AS TIME)
select 'Times match'
else
select 'Times do not...
September 23, 2016 at 10:31 am
mike.jones 60369 (9/23/2016)
I have two tables A and B below and I wish...
September 23, 2016 at 10:21 am
Luis Cazares (9/22/2016)
Jason A. Long (9/22/2016)
...
SET @FunctionSQL = 'IF OBJECT_ID(''[dbo].[itvf_Model_Name_Compare]'',...
September 22, 2016 at 9:13 am
I like Luis' approach better... The one thing I would add is code to drop the existing function if it exists...
...
SET @FunctionSQL = 'IF OBJECT_ID(''[dbo].[itvf_Model_Name_Compare]'', ''IF'') IS NOT NULL
DROP...
September 22, 2016 at 8:45 am
One issue that I would take with Sergiy's suggestion is that it can't be used in an iTVF. The resulting function will either be a scalar function or mTVF.
September 22, 2016 at 6:48 am
Sergiy (9/22/2016)
gvoshol 73146 (9/22/2016)
I like Sergiy's solution too. But what happens when you need to insert a new replacement code between priority 3 and 4?
Increase priority value in all...
September 22, 2016 at 6:32 am
It's easy enough to break up an input string with a string splitter...
DECLARE @States VARCHAR(255) = 'NY,NJ,FL,OK,OH,MD';
SELECT
s.StateAbbr
FROM
dbo.LK_States s
JOIN dbo.DelimitedSplit8k(@States, ',') ds
ON s.StateAbbr = ds.Item;
September 22, 2016 at 6:24 am
Here's a potential solution using a recursive CTE. It's not likely to as fast as a nested replace solution in terms of performance but it would allow for easier maintenance...
September 21, 2016 at 10:29 am
Just for the fun of it... Performance is about the same as what Alan posted previously...
DECLARE
@String VARCHAR(250) = '123,346,abc,def,ghi,123,jkl,345,678,mno,901,234,567,pqr',
@Delimiter CHAR(1) = ',';
WITH
n (n) AS (SELECT 1 FROM (VALUES...
September 20, 2016 at 1:03 pm
Viewing 15 posts - 811 through 825 (of 1,246 total)