|
Were they getting paid by the line of code?!
This is what happens when you remove the "adult supervision" from a bunch of idiots writing code.
|
|
|
|
|
My best guess is misuse of intellisense.
Maybe the perpetrator (amongst other) is dyslexic and has invented his own spellchecker.
People say nothing is impossible, but I do nothing every day.
|
|
|
|
|
Yes, this is the first normal form of the so called "Bakers Binding". It's very robust and flexible,you know! provide excellent abstraction without too much complexity!
In the second normal form, you introduce a
public const string COLUMNSEPARATORFORSELECTSTATEMENT = ",";
To be fair, hunting down select statements when the db scheme changes is painful; you have to exercise every code paht that contains a select.
That solution is akin to smashing your toe to forget a flea bite, though.
|
|
|
|
|
...good one though
there actually exists such a seperator iuhasdfhu,gvsd.fgzdfjhb (sorry, I just had to smash my head into the keyboard... it reliefs the pain)
|
|
|
|
|
An attempt to create new, better LINQ to SQL?
|
|
|
|
|
"Internal Electromagnetic Shockwave Generator Stablizer Error"
Not sure if I should run or not.
(Don't have a screenshot, sorry. Forgot to get one)
This popped up when an error occurred while starting the debugger (it was a stack overflow).
On a similar note, I hit an error yesterday that had me going around in circles for several hours.
I have a service manager class that contains a method GetService. I overrode a property from the base class to provide a logging service implementation, and left the message service property alone.
Well, that message service property called a method, which called the GetService method, which returned the message service property...... I think you can figure out where this one is going.
The problem that caused the strange error message above is a different thing, caused by a goof I made while using CassiniDev.
Baboom.
Bob Dole The internet is a great way to get on the net.
2.0.82.7292 SP6a
|
|
|
|
|
<context>SQL Server 2008 R2</context>
Someone added a function to my database! Well OK, it's a team effort so that's fine, but it's incorrect and not well-written.
What I think the purpose is is to take a column name in PascalCase and make it look more presentable by adding a SPACE before each capital (uppercase) letter. That's what I understand from the name and it's a reasonable thing to do and it does that.
Buuut... what it really does is add a SPACE before each non-lowercase letter (e.g. digits, symbols, whitespace).
Aside from producing unexpected output it's also hard to read and difficult to maintain -- I opted to rewrite it rather than try to fix it. Here's the original:
CREATE FUNCTION [dbo].[SpaceBeforeCap]
(
@str nvarchar(max)
)
returns nvarchar(max)
as
begin
declare @i int, @j int
declare @returnval nvarchar(max)
set @returnval = ''
select @i = 1, @j = len(@str)
declare @w nvarchar(max)
while @i <= @j
begin
if substring(@str,@i,1) = UPPER(substring(@str,@i,1)) collate Latin1_General_CS_AS
begin
if @w is not null
set @returnval = @returnval + ' ' + @w
set @w = substring(@str,@i,1)
end
else
set @w = @w + substring(@str,@i,1)
set @i = @i + 1
end
if @w is not null
set @returnval = @returnval + ' ' + @w
return ltrim(@returnval)
end
And here's mine (I added the fn wart because that's the standard I inherited ):
CREATE FUNCTION [dbo].[fnSpaceBeforeCap]
( @str NVARCHAR(MAX)
)
RETURNS NVARCHAR(MAX)
AS
BEGIN
DECLARE @offset INTEGER
SET @offset = PATINDEX ( '%[^ ][A-Z]%' , @str COLLATE Latin1_General_BIN )
WHILE ( @offset > 0 )
BEGIN
SET @str = STUFF ( @str , @offset + 1 , 0 , ' ' )
SET @offset = PATINDEX ( '%[^ ][A-Z]%' , @str COLLATE Latin1_General_BIN )
END
RETURN @str
END
It uses PATINDEX to find a non-SPACE followed by an uppercase letter then STUFFs a SPACE between them.
I'd like to say that mine is more efficient, but I don't feel like doing any testing. What I will point out is that the original uses SUBSTRING (twice!) to test each character and SUBSTRING to form the new value, whereas mine has that kind of thing hidden in black boxes. What I don't like about mine is that PATINDEX doesn't allow a parameter to tell it where to start so it always starts over from the beginning -- see also Schlemiel the painter's Algorithm[^].
|
|
|
|
|
it's ok to insert a spece on the begining of the string? it seems that both are doing that...
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)
|
|
|
|
|
No, the original inserts one there then uses LTRIM to remove it. Which means it will also remove any pre-existing SPACEs, which may not be as intended.
Mine will neither add nor remove a leading SPACE.
|
|
|
|
|
now i get why your's doesn't insert a space there, i'm not that good with sql =p
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)
|
|
|
|
|
PIEBALDconsult wrote: PATINDEX doesn't allow a parameter to tell it where to start so it always starts over from the beginning
Not only that, but the repeated use of stuff creates the same kind of inefficiency as you'd see in C# with the repeated use of "+" to concatenate strings. There is no StringBuilder in SQL, but there are workarounds. If you really want performance, this is what I'd do (describing rather than writing out, because I'm lazy)...
Create a while loop to visit each character in the string. Perform PATINDEX only on single characters (or two-character sequences, if you like). Output the strings to a local table variable then combine them using the FOR XML PATH technique (I haven't tried it myself, but it seems like it'd avoid repeat concatenations).
|
|
|
|
|
AspDotNetDev wrote: stuff creates the same kind of inefficiency as you'd see in C# with the repeated
use of "+" to concatenate strings
It is to be hoped that the STUFF function isn't implemented in SQL.
My main concern is correctitude; after that, readability and maintainability; efficiency isn't a primary concern -- the source values will generally be short (column names) with few (if any) STUFFs.
AspDotNetDev wrote: visit each character in the string
You mean SUBSTRING on each character? You think that's better?
AspDotNetDev wrote: a local table variable
I'd rather keep instantiating/destructing strings than tables.
Were I really concerned I'd write a CLR function instead.
|
|
|
|
|
PIEBALDconsult wrote: You mean SUBSTRING on each character? You think that's better?
PIEBALDconsult wrote: the source values will generally be short (column names) with few (if any) STUFFs
It would be if you were dealing with lots of string operations, but since you won't be then you are right to KISS.
|
|
|
|
|
I have been working for the last TWO HOURS on trying to figure out why a post build event in Visual Studio kept failing!
Here is what failed:
echo f | xcopy /Y "$(ProjectDir)GryphonSoft.NetPad.addin" $(SolutionDir)AddIns\GryphonSoft.NetPad.addin"
Can you spot the goof?
Bob Dole The internet is a great way to get on the net.
2.0.82.7292 SP6a
|
|
|
|
|
missing quote (")
Independent ACN Business OwnerNeed a new cell phone? We supply most of the major carriers. Telus in Canada. Flash, Verizon, T-Mobile and Sprint in the USA. O 2, talkmobile, tmobile, orange, three, and vodafone in Europe. See my website for details.
Within you lies the power for good - Use it!
|
|
|
|
|
Yup. Not sure how I missed that one for so long.
Bob Dole The internet is a great way to get on the net.
2.0.82.7292 SP6a
|
|
|
|
|
Well, it was a missing quote, you know?
|
|
|
|
|
GROAN! <---- We really need a groan smiley! :groan:
Bob Dole The internet is a great way to get on the net.
2.0.82.7292 SP6a
|
|
|
|
|
Mismatched quotes. You've got 3 in there.
2 hours?? You really need a vacation! It took me 5 seconds to see it.
|
|
|
|
|
|
That's why working in a team is good ... you spend 10 minutes feeling increasingly stupid and then give up and ask your colleague, who comes over and sees it in 5 seconds.
|
|
|
|
|
I usually forget to use CALL with multiple BAT files.
|
|
|
|
|
I'm guilty of that one often. Too used to scripting for sensible command lines like Linux...
|
|
|
|
|
It's one of those errors that's a lot easier for others to find.
Because you know that you wouldn't miss something as silly as that, right?
Happens to me a lot more often than I'd like to admit.
People say nothing is impossible, but I do nothing every day.
|
|
|
|
|