Viewing 15 posts - 16 through 30 (of 60 total)
Luis Cazares (9/18/2015)
Because T-SQL doesn't like to have flow control.
Why exactly ?
BTW: Thanks for that "THEN" but IMHO that should be optional.
September 18, 2015 at 3:45 pm
Awesome Kristen.....and thanks....
I'll remember this one for sure.
Very elegant. I was all bollexed up with how to specify the CASE statement.
Now I Just execute: SELECT * from dbo.FnReturnTablesForGroup(1)
And a list...
September 14, 2015 at 12:04 pm
Thanks Sean, but remember, my potential solution would effectively be 2 lines of code.
One to define the table via string, the other to call a function to convert it to...
September 14, 2015 at 11:52 am
Fair enough Sean, thanks for that idea.
However, I don't agree that using comma-delimited lists violates any rules of relation theory.
A list is a list....whether it's in table form or...
September 14, 2015 at 10:37 am
This compiled but won't execute:
Msg 557, Level 16, State 2, Line 1
Only functions and some extended stored procedures can be executed from within a function.
ALTER FUNCTION dbo.fnReturnTablesForGroup
(
@whichgroup int
)
RETURNS @RETTAB TABLE...
September 14, 2015 at 9:29 am
Thanks Sean, but whe I try to use a temp table, I get:
"Msg 2772 - Cannot access temporary tables from within a function."
What I am trying to do is develop...
September 14, 2015 at 9:15 am
My bad....the column was formatted as decimal (who did that ??!!**&&)
September 7, 2015 at 9:16 am
Thanks Luis for the explanation.....it's very slick.
I like to call these things "patterns" ...as they can be reused to solve similar problems.
September 4, 2015 at 12:27 pm
Sorry guys, my bad....definitely having a bad day.
And DateAdd is probably efficient....as whenever strings are involved, the conversion is usually costly.
Lowell's solution is very slick and efficient.
Sean's solution is way...
September 4, 2015 at 11:38 am
Thanks for that...forgot about FORMAT.
The final solution:
SELECT Convert(smalldatetime,FORMAT(GETDATE(), 'yyyy-MM-dd hh:00:00'))
In fact that works with datetime format as well.
My solution was too convoluted....however, since no string conversion was involved, it...
September 4, 2015 at 8:28 am
Sean Lange (9/4/2015)
mar.ko (9/4/2015)
I tried this:SELECT Convert(smalldatetime,Round(Convert(float,(dbo.fnDateOnly(getDate())))+16.0000000/24.0000000,6))
Result: 2015-09-04 16:00:00
It works (FnDateOnly strips the time).
Is there a more efficient way ?
What are you trying to do? And what is fnDateOnly?
RTFM: (FnDateOnly...
September 4, 2015 at 8:13 am
Thanks guys...that was not obvious to me.
September 4, 2015 at 7:42 am
Here is that function that I had mentioned in a previous post.....ughhh
CREATE FUNCTION dbo.IsBigInt (@a varchar(30))
returns bit
AS
BEGIN
-- Submitted to SqlServerCentral by William Talada
DECLARE
@s-2 varchar(30),
@i int,
@IsNeg bit,
@valid int
-- assume...
September 3, 2015 at 1:32 pm
Luis Cazares (9/3/2015)
Not really strange as it converts to an int within the IIF before being converted to a bigint.the problems caused by ISNUMERIC
No excuse on Microsoft's part....should have been...
September 3, 2015 at 1:02 pm
Viewing 15 posts - 16 through 30 (of 60 total)