July 10, 2014 at 3:34 pm
aochss (7/10/2014)
Please, please make the error/warning messages better and more precise...Nothing worse than something like this:Msg 8152, Level 16, State 14, Line 1
String or binary data would be truncated.
The statement has been terminated.
Come on SQL Server, you know where the error is, why not share?
Anton
Amen to that!
-- Itzik Ben-Gan 2001
July 10, 2014 at 6:51 pm
The one that I ran into today building a sproc. I have data that is imported into staging table. But depending on the customer they can give us data with an arbitrary staff_id_number or the identifier_NPI. The import routine determines which it is getting and creates ne column r the ther but not both in the same table.
So I build the sproc with an if statement that checks which column is there and use one query or the other. It parses fine, but then when trying to execute it chokes on the missing column name. I had to go to dynamic SQL to get it to run. AAARRRRGGGHHHH!!!! :crying:
----------------
Jim P.
A little bit of this and a little byte of that can cause bloatware.
July 10, 2014 at 9:08 pm
Nevermind.
July 10, 2014 at 9:23 pm
aochss (7/10/2014)
Please, please make the error/warning messages better and more precise...Nothing worse than something like this:Msg 8152, Level 16, State 14, Line 1
String or binary data would be truncated.
The statement has been terminated.
Come on SQL Server, you know where the error is, why not share?
Anton
There's actually been an MS CONNECT item open on that very subject. It almost has 800 vote-ups, has been open for years, and yet MS has done nothing with it.
--Jeff Moden
Change is inevitable... Change for the better is not.
July 10, 2014 at 9:27 pm
Jeff Moden (7/10/2014)
There's actually been an MS CONNECT item open on that very subject. It almost has 800 vote-ups, has been open for years, and yet MS has done nothing with it.
Wouldn't you love to be a fly on the wall and find out exactly how this kind of thing goes on? I can just imagine some terrible internal architecture that makes passing that object name along almost impossible... or an obstinate manager saying, "It's always been like this!"... or a revolving door of staff entering and leaving the project leaving nobody skilled enough to get the job done... or just such an influx of stupid time-draining requests combined with a management demand to see an ROI case on every change that nothing important can be done.
Which nightmare scenario is it Microsoft? One? Two? All? ๐
July 11, 2014 at 6:49 am
Jeff, did I just see you plug for Access?:-)
Nice post Phil. I wish we saw more public discussion on this.
July 11, 2014 at 10:09 am
@alan.B
After reading your comment, I've nervously put the routine in a test harness. It clocked at 0.054 Ms. per execution. I have to say that when I'm optimizing, I go after bigger fish!
@Andy Warren
It was when I saw MSDN actually warn people that IsNumeric() 'returns 1 for some characters that are not numbersโ that I blinked in astonishment and thought it was time they did some house-keeping.
Best wishes,
Phil Factor
July 14, 2014 at 9:32 am
Jeff Moden (7/10/2014)
Alan.B (7/10/2014)
Phil, you can make this more than twice as fast by turning it into an inline table value function like this:To that, I say... are you sure? Please read the following article before you answer that question.
I should have posted a different test harness but I was basing that statement on the fact that - on my system the original function runs for 10-11 seconds (11 with results on, 10 with results off). The itvf version runs for 3-5 seconds (3 with results off). Those were the times I got just by just highlighting the code and hitting F5.
If I measure the results like this:
DECLARE @Result char(4);
--===== Begin measuring duration using GETDATE
DECLARE @StartTime DATETIME;
SELECT @StartTime = GETDATE();
--===== Test the code using the "throw-away" variable
PRINT char(13)+'lefttrim:'
SELECT @result = dbo.lefttrim(string)
FROM #test;
--===== "Stop the timer" and report the duration
PRINT DATEDIFF(ms,@StartTime,GETDATE());
GO
DECLARE @Result char(4);
--===== Begin measuring duration using GETDATE
DECLARE @StartTime DATETIME;
SELECT @StartTime = GETDATE();
--===== Test the code using the "throw-away" variable
PRINT char(13)+'itvf_lefttrim:'
SELECT @result = x.string
FROM #test
CROSS APPLYdbo.itvf_LeftTrim(string) x;
--===== "Stop the timer" and report the duration
PRINT DATEDIFF(ms,@StartTime,GETDATE());
GO
Results:
lefttrim:
10703
itvf_lefttrim:
3466
This is on my laptop (4X) 2.6 ghz, 16gb ram, SQL 2014 Ent.
-- Itzik Ben-Gan 2001
July 14, 2014 at 3:33 pm
This may be what GPO noted previously.
Yep. Me and many many others.
...One of the symptoms of an approaching nervous breakdown is the belief that ones work is terribly important.... Bertrand Russell
July 14, 2014 at 3:48 pm
Andy Warren (7/11/2014)
Jeff, did I just see you plug for Access?:-)
Heh... not quite. I figure if even lowly Access can have an incredible and easy to use PIVOT function, why not SQL Server?
--Jeff Moden
Change is inevitable... Change for the better is not.
July 14, 2014 at 3:53 pm
Alan.B (7/14/2014)
Jeff Moden (7/10/2014)
Alan.B (7/10/2014)
Phil, you can make this more than twice as fast by turning it into an inline table value function like this:To that, I say... are you sure? Please read the following article before you answer that question.
I should have posted a different test harness but I was basing that statement on the fact that - on my system the original function runs for 10-11 seconds (11 with results on, 10 with results off). The itvf version runs for 3-5 seconds (3 with results off). Those were the times I got just by just highlighting the code and hitting F5.
If I measure the results like this:
DECLARE @Result char(4);
--===== Begin measuring duration using GETDATE
DECLARE @StartTime DATETIME;
SELECT @StartTime = GETDATE();
--===== Test the code using the "throw-away" variable
PRINT char(13)+'lefttrim:'
SELECT @result = dbo.lefttrim(string)
FROM #test;
--===== "Stop the timer" and report the duration
PRINT DATEDIFF(ms,@StartTime,GETDATE());
GO
DECLARE @Result char(4);
--===== Begin measuring duration using GETDATE
DECLARE @StartTime DATETIME;
SELECT @StartTime = GETDATE();
--===== Test the code using the "throw-away" variable
PRINT char(13)+'itvf_lefttrim:'
SELECT @result = x.string
FROM #test
CROSS APPLYdbo.itvf_LeftTrim(string) x;
--===== "Stop the timer" and report the duration
PRINT DATEDIFF(ms,@StartTime,GETDATE());
GO
Results:
lefttrim:
10703
itvf_lefttrim:
3466
This is on my laptop (4X) 2.6 ghz, 16gb ram, SQL 2014 Ent.
Now that's what I'm talking about. Something that others can run and something that doesn't use SET STATISTICS on a Scalar Funtion. Thanks, Alan.
--Jeff Moden
Change is inevitable... Change for the better is not.
July 14, 2014 at 3:59 pm
Phil Factor (7/11/2014)
@Alan.BAfter reading your comment, I've nervously put the routine in a test harness. It clocked at 0.054 Ms. per execution. I have to say that when I'm optimizing, I go after bigger fish!
It's just such small-fry that used to choke the server I took over because there were many such small fish that got executed hundreds of millions of times per day. If you consider the overall improvement is 3:1, that's not bad especially considering the number of executions over the course of the day.
--Jeff Moden
Change is inevitable... Change for the better is not.
July 15, 2014 at 7:19 am
These quirky functions keep us TSQL developers special. The ISNUMERIC tests a field, and CAST converts it if you want.
CASE ISNUMERIC(LEFT(a.[CHBID], 7))
WHEN 1
THEN CAST(LEFT(a.[CHBID], 7) AS INT)
ELSE 0
END AS CHBID
July 15, 2014 at 7:52 am
Jeff Moden (7/14/2014)
It's just such small-fry that used to choke the server I took over because there were many such small fish that got executed hundreds of millions of times per day.
Most .NET apps I see are spamming the database with thousands of calls a second loading and reloading data; whereby the programmers don't even know why it's happening and can't stop it.
So yeah, amen. Tiny improvements (admittedly on known hot spots) can have big improvements ๐
Viewing 15 posts - 31 through 45 (of 54 total)
You must be logged in to reply to this topic. Login to reply