November 9, 2014 at 12:01 pm
Comments posted to this topic are about the item Using Comments to Quickly Test CTEs
November 10, 2014 at 1:11 am
Neat trick!
.
November 10, 2014 at 2:06 am
Nice, thanks for sharing. Although I must point out a flaw with your program's logic... 50 isn't old!
Ben
^ Thats me!
----------------------------------------
01010111011010000110000101110100 01100001 0110001101101111011011010111000001101100011001010111010001100101 01110100011010010110110101100101 011101110110000101110011011101000110010101110010
----------------------------------------
November 10, 2014 at 5:07 am
Nice tip, but as a person over 50 I can only give one star.
November 10, 2014 at 6:50 am
It would be nice if MS could add pre-compile directives similar to C++ or C# -
#define, #if, #undefine, etc...
Dan Beggs
November 10, 2014 at 8:53 am
i like this a lot 🙂
Thanks for sharing.
November 10, 2014 at 12:09 pm
Guess I'm a dinosaur at 57! Funny, I don't consider myself "old"! 😀
November 10, 2014 at 12:37 pm
Hey! I'm 61 and nowhere close to done.
This is nice thing to do when you are trying to understand some other persons code. Especially if it already has block comment as most of mine do.
My technique is to test the first level of a CTE before adding the next level
ATBCharles Kincaid
November 10, 2014 at 12:38 pm
We may be old, but as long as we can learn new tricks, we're not too old. 🙂
November 10, 2014 at 12:59 pm
This makes my decision to retire at 56 much easier 🙂
Final.Answer!
November 10, 2014 at 3:39 pm
Retire? Me? Never! They will find me dead at the keyboard!!
First of September I just got out of six months in a medical facility. It did not cost me an arm and a leg. Just the leg :w00t:
Beside software I write a bit of poetry.
Yesterday Nothing
Today Nothing
Tomarrow Nothing
Retirement?
Or is this something else
By a different name?
ATBCharles Kincaid
November 11, 2014 at 12:13 am
I concure regarding the age bit 🙂
November 11, 2014 at 3:53 am
Charles Kincaid (11/10/2014)
My technique is to test the first level of a CTE before adding the next level
Ah now that's an approach that doesn't really work for me, if I stop to test a CTE I will forget what to write next by the time I'm done. If I'm writing something at all complex that requires multiple levels of CTEs I sit and stare at the screen for several minutes whilst I juggle data in my head. I eventually get this notion that my current thought process is 'right' and then have to quickly type the whole lot down before my thought process changes or I will have to start again. I can't afford to think about what I'm doing, I just have to dump whats in my head to the screen.
Tricks like this for testing after it has been written as oposed to testing during the writing suit me well! Generally speaking I come up with my final solution first time but often need to tweak details like sort orders or including additional columns etc.
Ben
^ Thats me!
----------------------------------------
01010111011010000110000101110100 01100001 0110001101101111011011010111000001101100011001010111010001100101 01110100011010010110110101100101 011101110110000101110011011101000110010101110010
----------------------------------------
November 11, 2014 at 6:25 am
Ben. Whatever works for you. 😎
ATBCharles Kincaid
November 12, 2014 at 7:39 pm
My technique is to put all of those queries at the end. Then I can enable the test queries or the final result query as a block of text and only be concerned with having patched out the queries not to use. For instance to test the content of "OldPeople":
WITH
People AS (
SELECT 1 ID, 'Joe' FirstName, 'Smith' LastName, 21 Age, 'Male' Gender UNION ALL
SELECT 2 ID, 'John' FirstName, 'Smit' LastName, 32 Age, 'Male' Gender UNION ALL
SELECT 3 ID, 'Jo' FirstName, 'Schmit' LastName, 43 Age, 'Female' Gender UNION ALL
SELECT 4 ID, 'Joanne' FirstName, 'Smith' LastName, 54 Age, 'Female' Gender UNION ALL
SELECT 5 ID, 'Juan' FirstName, 'Smithe' LastName, 65 Age, 'Male' Gender
)
,
OldPeople AS (
SELECT * FROM People WHERE Age > 50
)
,
Men AS (
SELECT * FROM People WHERE Gender = 'Male'
)
--select * from People
select * from OldPeople
--select * from Men
--SELECT
-- o.*
--FROM
-- Men AS m
-- INNER JOIN OldPeople AS o
-- ON m.ID = o.ID
Viewing 15 posts - 1 through 14 (of 14 total)
You must be logged in to reply to this topic. Login to reply