A blog about SQL Server, Books, Movies and life in general
Sunday, September 06, 2015
My 3 favorite sessions at PASS Summit 2014
These were my 3 favorite sessions at the PASS Summit 2014. I attended 13 sessions and most of them, were good, some of them had a demo fail and one of them had several demos fail. So here are the 3 I liked the most, they are in order that I attended them
[AD-400] Query Tuning Mastery: Manhandling Parallelism, 2014 Edition
Speaker: Adam Machanic
This was an excellent session, the content was superb and the delivery was top-notch. I was a little sad when the session ended, I wish it would continue.
You can find the demos here: http://sqlblog.com/blogs/adam_machanic/archive/2014/11/06/pass-summit-2014-manhandling-parallelism-demos.aspx
[DBA-500-HD] Inside SQL Server I/O
Speaker(s): Bob Ward
What do I have to see that anyone who attended any of Bob Ward's previous sessions at the PASS Summit, doesn't already know. you HAVE to attend his sessions, don't worry if the content might be to advanced for you. Fast paced, a lot of cool stuff shown and excellent delivery
You can find the demos here: http://www.sqlpass.org/summit/2014/Sessions/Details.aspx?sid=7057
[DBA-305] Working with Very Large Tables Like a Pro in SQL Server 2014
Speaker: Guy Glantser
First session I ever attended by Guy Glantser. The delivery was perfect, the content was to the point and explained in simple steps.
You can find the demos here: http://www.sqlpass.org/summit/2014/Sessions/Details.aspx?sid=6519
I also want to mention the following session, this is a pre-conference session so you won't be able to find the recording
Troubleshoot Customer Performance Problems Like a Microsoft Engineer
Speaker(s): Tim Chapman Denzil Ribeiro
Excellent session with a lot of good stuff, cool demos and tools were shown
Of course you might have attended a better session, but since it is impossible to attend all sessions I onlyknow about those that I attended, but you can leave me a comment telling me which ones you liked the best
What is a valid variable name in T-SQL?
On twitter Adam Machanic posted a question if anyone has a document that details what a valid variable name is, what is allowed and what is not allowed.
Did you know that you can have a variable named @@ or @@@@?
Running that will print 25 25
There is a Books On Line page that gives some details but it is not very explicit, you can find that page here Identifiers
But what is valid? Let's write a quick SQL script, we are going to use the spt_values in the master database to quickly generate a SQL statement which we can execute
First step is to dump what we want into a temporary table
Don't be fooled by that the first 33 rows, those will be generated as @ and will appear valid, those are non printable characters
So let's continue with our SQL script after you created the temp table, run the following, if there is an error, the script will catch it and print the character number
Running that code will give you the following output
So those are all invalid, as well as the single and double quote and everything between characters 0 and 32 since those are not really printable but how would you even use those?
So there you have it a quick and dirty script to test what is valid....
Exercise for you...expand this to use unicode......
Did you know that you can have a variable named @@ or @@@@?
DECLARE @ int=5,@@ int SET @@=@ DECLARE @@@@ int=@*@@ DECLARE @$$ int=@@@@ SELECT @$$,@@@@
Running that will print 25 25
There is a Books On Line page that gives some details but it is not very explicit, you can find that page here Identifiers
But what is valid? Let's write a quick SQL script, we are going to use the spt_values in the master database to quickly generate a SQL statement which we can execute
SELECT number,'declare @' + CHAR(CONVERT(VARCHAR(5),number)) +' int' AS stmt INTO #test FROM master..spt_values WHERE type='p' SELECT * from #test
Running that will give you something like this if you have the output in grid not text
Don't be fooled by that the first 33 rows, those will be generated as @ and will appear valid, those are non printable characters
DELETE #test WHERE stmt IS NULL DELETE #test WHERE number < 33 DELETE #test WHERE stmt like '%''%' OR stmt LIKE '"' DECLARE @stmt VARCHAR(100) DECLARE @start int = 0,@end int =(SELECT max(number) from #test) WHILE @start <= @end BEGIN SELECT @stmt = stmt from #test where number = @start BEGIN TRY EXEC(@stmt) END TRY BEGIN CATCH PRINT 'error ' + right('000' + CONVERT(VARCHAR(3),@start),3) + ' ' + @stmt END CATCH SET @start+=1 END
Running that code will give you the following output
error 033 declare @! int error 034 declare @" int error 037 declare @% int error 038 declare @& int error 039 declare @' int error 040 declare @( int error 041 declare @) int error 042 declare @* int error 043 declare @+ int error 044 declare @, int error 045 declare @- int error 046 declare @. int error 047 declare @/ int error 058 declare @: int error 059 declare @; int error 060 declare @< int error 061 declare @= int error 062 declare @> int error 063 declare @? int error 091 declare @[ int error 092 declare @\ int error 093 declare @] int error 094 declare @^ int error 096 declare @` int error 123 declare @{ int error 124 declare @| int error 125 declare @} int error 126 declare @~ int error 127 declare @ int error 128 declare @€ int error 129 declare @ int error 130 declare @‚ int error 132 declare @„ int error 133 declare @… int error 134 declare @† int error 135 declare @‡ int error 136 declare @ˆ int error 137 declare @‰ int error 139 declare @‹ int error 141 declare @ int error 143 declare @ int error 144 declare @ int error 145 declare @‘ int error 146 declare @’ int error 147 declare @“ int error 148 declare @” int error 149 declare @• int error 150 declare @– int error 151 declare @— int error 152 declare @˜ int error 153 declare @™ int error 155 declare @› int error 157 declare @ int error 161 declare @¡ int error 162 declare @¢ int error 163 declare @£ int error 164 declare @¤ int error 165 declare @¥ int error 166 declare @¦ int error 167 declare @§ int error 168 declare @¨ int error 169 declare @© int error 171 declare @« int error 172 declare @¬ int error 173 declare @ int error 174 declare @® int error 175 declare @¯ int error 176 declare @° int error 177 declare @± int error 178 declare @² int error 179 declare @³ int error 180 declare @´ int error 182 declare @¶ int error 183 declare @· int error 184 declare @¸ int error 185 declare @¹ int error 187 declare @» int error 188 declare @¼ int error 189 declare @½ int error 190 declare @¾ int error 191 declare @¿ int error 215 declare @× int error 247 declare @÷ int
So those are all invalid, as well as the single and double quote and everything between characters 0 and 32 since those are not really printable but how would you even use those?
So there you have it a quick and dirty script to test what is valid....
Exercise for you...expand this to use unicode......
Thursday, September 03, 2015
Did you know you can pass false and true to SQL Server bit parameters?
I noticed a stored procedure with a bit parameter and the default was false, I have never seen this before in SQL Server. You can do this in a language like c# but not in SQL Server right?
Let's take a look
Create this proc
create procedure prTest @BitTrue bit = true, @BitFalse bit = False, @BitNotFalse bit = -2 as Select @BitTrue as BitTrue, @BitFalse as BitFalse, @BitNotFalse as BitNotFalse GO
Now execute the sored procedure
EXEC prTest
BitTrue BitFalse BitNotFalse
1 0 1
As you can see true gets converted to 1, false gets converted to 0 and any number that is not 0 will be converted to 1 as well
What happens when you pass in false for the parameter that had a default of true?
EXEC prTest @BitTrue = false
BitTrue BitFalse BitNotFalse
0 0 1
How about variables..can you use true and false with bit datatype variables?
Let's try it out
DECLARE @BitTrue bit SET @BitTrue = true
Msg 207, Level 16, State 1, Line 2
Invalid column name 'true'.
DECLARE @BitTrue bit SET @BitTrue = false
Msg 207, Level 16, State 1, Line 3
Invalid column name 'false'.
As you can see you can use true and false with parameters in a proc but not with variables.
Tuesday, September 03, 2013
My non SQL blog is up
In case you are interested in non SQL Server related stuff, I have started a blog about non SQL stuff. You can find it here http://denis-gobo.squarespace.com
See you there
See you there
Subscribe to:
Posts (Atom)