December 5, 2008 at 11:23 am
You might want to be more lazy. You only needed five words in that last sentence.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
December 5, 2008 at 11:27 am
Sorry:
lazy not 2 spell "PLZ"?
...and Steve, can we get the post button to reject anything in all caps and make the poster re-type it?
December 5, 2008 at 11:42 am
Actually, I meant:
It is also pretty lazy ...
I thought you summed it up nicely with those five.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
December 5, 2008 at 11:50 am
I definitely dislike the shorthand that so many people are using, but I think it's a bit of a fact of life for newer generations.
I was slightly torqued about the question, hope I wasn't too harsh in my response. I do get tired of the "give me everything" questions.
December 5, 2008 at 11:54 am
Sometimes people have to be hit the 2 X 4 to understand. I know, it happens with me at times.
December 5, 2008 at 12:02 pm
Michael Earl (12/5/2008)
Anyone catch the question before it was edited?http://www.sqlservercentral.com/Forums/Topic614696-146-1.aspx
Go Steve for calling someone's question silly...
I actually think I did, but I decided not to reply because I couldn't have been as polite as Steve was.
Of course I still don't know what the OP wants the differences of. Apples and Oranges? Coke and Pepsi?
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
December 5, 2008 at 12:12 pm
...a good post and a bad one?...
December 9, 2008 at 12:56 pm
BWAAA-HAAAA-HAAA! OMG!!! ... If you think the posted questions are getting worse, you aint seen nothin' compared to real life... here's some code I just found in one of the DB's at my new job... all were done by people who were supposed experts at SQL Server... these are "unretouched photos" of the accidents as they actually happened... 😛
-- -----------------------------------------------------------------------------------
create function fn_mod(@n int, @d int)
returns int
AS
begin
return @n - @d * (@n/@d)
end
GO
-- -----------------------------------------------------------------------------------
create function fn_getUniqueId(@d datetime)
returns bigint
AS
begin
declare @n bigInt
set @n = convert(bigint, replace(replace(replace(replace(convert(varchar, @d, 121), '-', ''), ' ', ''), ':', ''), '.', ''))
return @n
end
GO
-- -----------------------------------------------------------------------------------
create function fn_getLastDayOfMonth(@d datetime)
returns datetime
AS
begin
return dateAdd(dd, -1, dateAdd(mm, 1, dbo.fn_getFirstDayOfMonth(@d)))
end
GO
create function fn_getMinInt(@a int, @b-2 int)
returns int
begin
declare @returnValue int
if @a is null
set @returnValue = @b-2
else if @b-2 is null
set @returnValue = @a
else if(@a < @b-2)
set @returnValue = @a
else
set @returnValue = @b-2
return @returnValue
end
GO
CREATE function fn_cSTR
(@int int)
returns varchar(20)
AS
BEGIN
declare @STR varchar(20)
select @STR =convert(varchar(20), @int)
return (@str)
END
[font="Arial Black"]... and the winner for the "Computational Darwin Award" is...[/font]
create function fn_getPhoneNumber(@phone varchar(25), @ext varchar(25))
returns varchar(255)
AS
BEGIN
declare @phoneNumber varchar(255)
select @phoneNumber =
case when @ext is null then @phone + 'x' + @ext
else @phone
end
return @phoneNumber
END
Good thing these folks no longer work for the company or I'd have to invest in a water cooled pork chop launcher! :hehe:
--Jeff Moden
Change is inevitable... Change for the better is not.
December 9, 2008 at 1:03 pm
That last query... the uh... you know it... well... uh...
Never mind. That actually makes my current local favorite look intelligent:
DECLARE @i int
SET @i =1
IF @i = 0
BEGIN...
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
December 9, 2008 at 1:31 pm
Looks like someone to some persons fell in love with UDF's.
Developer1 - "Hey why write it over and over again, we can encapsulate it in a UDF and now we have re-usable code"
Developer2 - "Wow, you are genius! Why didn't I think of that?"
Developer3 - "This will cut our development time by 20%, more time on the internet!'
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
December 9, 2008 at 1:46 pm
Grant Fritchey (12/9/2008)
That last query... the uh... you know it... well... uh...Never mind. That actually makes my current local favorite look intelligent:
DECLARE @i int
SET @i =1
IF @i = 0
BEGIN...
If THAT's the worse you got...sheesh.
How's this one (I just finished ripping this one out of production):
Declare @i int
set @i=0;
while (@i<50000)
BEGIN
SELECT *
Into #tempTable
from MyHumongousTable --1,750,000 rows
update MyNewTable
set aBunchOfFields= #TempTable.aBunchOfFields
From MyNewTable
Inner Join #TempTable on MyNewTable.id=TempTable.id
Where #TempTable.id=@i
Drop table #temptable
Set @i=@i+1;
END
----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
December 9, 2008 at 1:47 pm
While you are at it, here are two of my favorites from my previous employer (yes, I stll remember the code well, and it is also COBOL).
IF X = 1 THEN STOP RUN.
IF Y = 1 THEN STOP RUN.
IF Z = 1 THEN STOP RUN.
STOP RUN.
IF TAX_CODE = 1 THEN TAX_CODE = 0
ELSE IF TAX_CODE = 0 THEN TAX_CODE = 1.
December 9, 2008 at 1:48 pm
Lynn Pettis (12/9/2008)
While you are at it, here are two of my favorites from my previous employer (yes, I stll remember the code well, and it is also COBOL).
IF X = 1 THEN STOP RUN.
IF Y = 1 THEN STOP RUN.
IF Z = 1 THEN STOP RUN.
STOP RUN.
IF TAX_CODE = 1 THEN TAX_CODE = 0
ELSE IF TAX_CODE = 0 THEN TAX_CODE = 1.
Agreed. I always preferred the "WALK" statement instead of the STOP RUN...:)
----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
December 9, 2008 at 2:01 pm
I still think my favourite has to be this piece of code that I found when one of the devs complained that the dev server was very slow. The same code was on production, but fortunately, the data on prod was such that the code never entered the while loop.
WHILE LEN(@DataSegment < 7000)
SET @DataSegment = @DataSegment + ' '
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
December 9, 2008 at 2:12 pm
I have discovered quite a few stored procedures on our SIS system that use nested cursors and the queries are written using the old style join syntax (I hate that as I learned the ANSI style join syntax when I started working with SQL Server 6.5 12 years ago or so).
Luckily, I am confident that they are benign in that each of the queries used to build the cursors only return a few rows (no more than 10 or so). I still intend to rewrite those when I finish working on other things that are ACTUALLY more pressing than just eliminating cursors from code, even though I know it needs to be done.
Viewing 15 posts - 181 through 195 (of 66,712 total)
You must be logged in to reply to this topic. Login to reply