Dysfunctional programming?
-
SQL Server at its best. Guess the output:
CREATE FUNCTION dbo.WTE ( @ID UNIQUEIDENTIFIER )
RETURNS TABLE AS RETURN
(
SELECT @ID [ID]
UNION ALL
SELECT @ID
UNION ALL
SELECT @ID
)
GODECLARE @ID UNIQUEIDENTIFIER = NEWID()
SELECT [ID] FROM dbo.WTE ( @ID )SELECT [ID] FROM dbo.WTE ( NEWID() )
DROP FUNCTION dbo.WTE
This wasted a few hours today.
-
SQL Server at its best. Guess the output:
CREATE FUNCTION dbo.WTE ( @ID UNIQUEIDENTIFIER )
RETURNS TABLE AS RETURN
(
SELECT @ID [ID]
UNION ALL
SELECT @ID
UNION ALL
SELECT @ID
)
GODECLARE @ID UNIQUEIDENTIFIER = NEWID()
SELECT [ID] FROM dbo.WTE ( @ID )SELECT [ID] FROM dbo.WTE ( NEWID() )
DROP FUNCTION dbo.WTE
This wasted a few hours today.
Knowing absolutely nothing about SQL, I have no idea, although I guess the output was not what was expected (and possibly wasn't even logical, having heard various stories about SQL Server).
What do you get when you cross a joke with a rhetorical question? The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism. Do questions with multiple question marks annoy you???
-
SQL Server at its best. Guess the output:
CREATE FUNCTION dbo.WTE ( @ID UNIQUEIDENTIFIER )
RETURNS TABLE AS RETURN
(
SELECT @ID [ID]
UNION ALL
SELECT @ID
UNION ALL
SELECT @ID
)
GODECLARE @ID UNIQUEIDENTIFIER = NEWID()
SELECT [ID] FROM dbo.WTE ( @ID )SELECT [ID] FROM dbo.WTE ( NEWID() )
DROP FUNCTION dbo.WTE
This wasted a few hours today.
Wow! Never seen this before. I tested with RAND() and FLOAT and it's the same behavior. Did you find any explanation?
-
SQL Server at its best. Guess the output:
CREATE FUNCTION dbo.WTE ( @ID UNIQUEIDENTIFIER )
RETURNS TABLE AS RETURN
(
SELECT @ID [ID]
UNION ALL
SELECT @ID
UNION ALL
SELECT @ID
)
GODECLARE @ID UNIQUEIDENTIFIER = NEWID()
SELECT [ID] FROM dbo.WTE ( @ID )SELECT [ID] FROM dbo.WTE ( NEWID() )
DROP FUNCTION dbo.WTE
This wasted a few hours today.
Interesting. I wouldn't have guessed that! I'd suggest that's worth a quick tip (and possibly a list of what it does in various versions?) For the record, I tried it in SQL Server 2012:
Microsoft SQL Server 2012 - 11.0.5343.0 (X64)
May 4 2015 19:11:32
Copyright (c) Microsoft Corporation
Express Edition (64-bit) on Windows NT 6.3 <X64> (Build 10586: )And
Microsoft SQL Server 2012 (SP1) - 11.0.3156.0 (X64)
May 4 2015 18:48:09
Copyright (c) Microsoft Corporation
Web Edition (64-bit) on Windows NT 6.2 (Build 9200: ) (Hypervisor)And got the same results
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
-
SQL Server at its best. Guess the output:
CREATE FUNCTION dbo.WTE ( @ID UNIQUEIDENTIFIER )
RETURNS TABLE AS RETURN
(
SELECT @ID [ID]
UNION ALL
SELECT @ID
UNION ALL
SELECT @ID
)
GODECLARE @ID UNIQUEIDENTIFIER = NEWID()
SELECT [ID] FROM dbo.WTE ( @ID )SELECT [ID] FROM dbo.WTE ( NEWID() )
DROP FUNCTION dbo.WTE
This wasted a few hours today.
Now, that is weird and wonderful! :-o I wonder what else I can do with that... :laugh: :rolleyes:
All in one Menu-Ribbon Bar DirectX for WinRT/C# since 2013! Taking over the world since 1371!
-
SQL Server at its best. Guess the output:
CREATE FUNCTION dbo.WTE ( @ID UNIQUEIDENTIFIER )
RETURNS TABLE AS RETURN
(
SELECT @ID [ID]
UNION ALL
SELECT @ID
UNION ALL
SELECT @ID
)
GODECLARE @ID UNIQUEIDENTIFIER = NEWID()
SELECT [ID] FROM dbo.WTE ( @ID )SELECT [ID] FROM dbo.WTE ( NEWID() )
DROP FUNCTION dbo.WTE
This wasted a few hours today.
Function pointers FTW
"There are three kinds of lies: lies, damned lies and statistics." - Benjamin Disraeli
-
SQL Server at its best. Guess the output:
CREATE FUNCTION dbo.WTE ( @ID UNIQUEIDENTIFIER )
RETURNS TABLE AS RETURN
(
SELECT @ID [ID]
UNION ALL
SELECT @ID
UNION ALL
SELECT @ID
)
GODECLARE @ID UNIQUEIDENTIFIER = NEWID()
SELECT [ID] FROM dbo.WTE ( @ID )SELECT [ID] FROM dbo.WTE ( NEWID() )
DROP FUNCTION dbo.WTE
This wasted a few hours today.
Wow, that is truly horrible. I'd describe that as a bug, pure and simple.
"If you don't fail at least 90 percent of the time, you're not aiming high enough." Alan Kay.
-
SQL Server at its best. Guess the output:
CREATE FUNCTION dbo.WTE ( @ID UNIQUEIDENTIFIER )
RETURNS TABLE AS RETURN
(
SELECT @ID [ID]
UNION ALL
SELECT @ID
UNION ALL
SELECT @ID
)
GODECLARE @ID UNIQUEIDENTIFIER = NEWID()
SELECT [ID] FROM dbo.WTE ( @ID )SELECT [ID] FROM dbo.WTE ( NEWID() )
DROP FUNCTION dbo.WTE
This wasted a few hours today.
This is crazy - how is this possible! It's as if the NEWID() call is passed as a paremeter into the function and called three times?????
-
SQL Server at its best. Guess the output:
CREATE FUNCTION dbo.WTE ( @ID UNIQUEIDENTIFIER )
RETURNS TABLE AS RETURN
(
SELECT @ID [ID]
UNION ALL
SELECT @ID
UNION ALL
SELECT @ID
)
GODECLARE @ID UNIQUEIDENTIFIER = NEWID()
SELECT [ID] FROM dbo.WTE ( @ID )SELECT [ID] FROM dbo.WTE ( NEWID() )
DROP FUNCTION dbo.WTE
This wasted a few hours today.
-
Not on CP.
-
SQL Server at its best. Guess the output:
CREATE FUNCTION dbo.WTE ( @ID UNIQUEIDENTIFIER )
RETURNS TABLE AS RETURN
(
SELECT @ID [ID]
UNION ALL
SELECT @ID
UNION ALL
SELECT @ID
)
GODECLARE @ID UNIQUEIDENTIFIER = NEWID()
SELECT [ID] FROM dbo.WTE ( @ID )SELECT [ID] FROM dbo.WTE ( NEWID() )
DROP FUNCTION dbo.WTE
This wasted a few hours today.