r/SQLServer • u/[deleted] • Jul 06 '18
SQL Query for DBAs working today...
SELECT
UPPER(SUBSTRING(a.b,a.c,1)) +
LOWER(SUBSTRING(a.b,a.c+1,a.d-1) +
SUBSTRING(a.b,a.e,a.f)) as Message
FROM (
select 2 as id, 9 as c, 2 as d, 12 as e, 1 as f, 'All the goodness in the world' as b UNION ALL
select 1 as id, 20 as c, 4 as d, 1 as e, 1 as f, 'Kindness is better than openness' as b UNION ALL
select 4 as id, 25 as c, 3 as d, 3 as e, 3 as f, 'Today we will eat frenchfries and cheese' as b UNION ALL
select 3 as id, 37 as c, 2 as d, 18 as e, 2 as f, 'Poetry is a human''s endeavour to merit' as b
) a
order by idHave a great weekend!
34
Upvotes
3
u/alinroc 4 Jul 06 '18
Slow day at the office, eh?
1
Jul 06 '18
Very nod. This is pretty much half our city today:
https://np.reddit.com/r/Calgary/comments/8wkwq9/coming_into_work_on_stampede_parade_day/
2
2
u/TNMattH Jul 09 '18
Today's follow-up:
SELECT
UPPER(SUBSTRING(a.b,a.c,1)) +
LOWER(SUBSTRING(a.b,a.c+1,a.d-1) +
SUBSTRING(a.b,a.e,a.f) +
SUBSTRING(a.b,a.g,a.h)) as Message
FROM (
select 2 as id, 14 as c, 4 as d, 5 as e, 1 as f, 9 as g, 1 as h, 'Each day has it''s own problems.' as b UNION ALL
select 1 as id, 18 as c, 2 as d, 20 as e, 2 as f, 35 as g, 2 as h, 'Don''t drown your sorrows in whiskey,' as b UNION ALL
select 3 as id, 11 as c, 2 as d, 27 as e, 1 as f, 34 as g, 3 as h, 'Because tomorrow will be another day.' as b
) a
order by idNow, get back to work. /s
2
1
10
u/hello_josh Jul 06 '18 edited Jul 06 '18
Back at ya
(Check the spatial results tab)