Tuesday, March 6, 2012

Aggrivation

The following will be a personal rant aimed at web developers and have nothing to do with DBA/SQL stuff (but coding in a round about sort of way)

To all you website developers out there who are insanely paranoid about your "content": 
If you take to time and effort to go unnecessarily out of your way to disable my ability to do things such as right clicking or selecting text, something which I should have every right to do in MY BROWSER, I can and WILL take just as much time and effort to deconstruct your website (in my local DOM) and figure out how undo this travesty. And when I'm through, I will post online how to do it, so others who share my same views don't have to waste time, all because you want to give yourself some undeserved, over inflated sense of personal satisfaction.

But I do give you credit for one thing: It is people like you, and those who share your ignorant views, that give me the motivation to continuously evolve my skills and knowledge. Flexing my artistic and creative abilities if you will. Go ahead and put a wall in front of me, because by god, I will spend every ounce of my very being doing whatever I can to tear the whole god-damned thing down to the ground. Information and knowledge is free and should be shared with any and all willing to seek it. And I will fight 'till my dying breath to keep these values.

 /endrant

Life

Just when you think you have everything starting to go in the same direction, life has a funny away of swinging a 2x4 upside your head.

Without going into personal details, my life was thrown into a disarray of "WTF" mixed with a big helping of "Why the hell?!?" Thankfully, time is the cure of most things, but as with anything, something had to give. I think it may have been my sanity, or maybe my work ethic, or maybe a mix of the 2. All I know is that I realized I wasn't spending anywhere enough time devoted to what meant most to me in life. But now with her being in school full time, and work life calmed down, I find myself with a little extra time to do some of the funner things in my professional life. So with that in mind, I will strive to do my best to post more cool code stuff here.

Friday, July 8, 2011

Easy Registered Servers

After having to re-image my work machine, I found myself forgetting to have saved the registered servers from my management studio. Since we manage well over 200 instances, I took the time to write a script that will add back in my registered servers.  I could have done this in powershell, but decided to do this in pure SQL just for kicks.

Since I use both SSMS 2005 and SSMS 2008, I made the importable registered servers file fit the format for 2005, then I could just use the "Import previous registered servers" function to import them into SSMS 2008.

In order for this script to work correctly, I have a table that holds a list of all our instances with their environments and versions. This will make a category for each environment and for each version. So an instance will appear in both categories.

set nocount on

declare @fulllist varchar(MAX)
declare @serverheader varchar(8000)
declare @serverfooter varchar(8000)
declare @serverentry varchar(max)

declare @environments table
(
environment varchar(20)
, rowid int
)
declare @versions table
(
version varchar(15)
, rowid int
)
declare @instances table
(
instancename varchar(100)
, environment varchar(20)
, version varchar(15)
, rowid int
)
declare @x int
declare @y int

insert into @environments
select case
when Environment like 'Dev%' then 'Development'
else Environment
end as 'Environment'
,ROW_NUMBER() OVER(order by Environment) as 'Rowid'
from Instances
group by Environment

insert into @versions
select case
when Version = '8.0' then 'SQL 2000'
when Version = '9.0' then 'SQL 2005'
when Version = '10.0' then 'SQL 2008'
when Version = '10.50' then 'SQL 2008 R2'
end as 'Version'
,ROW_NUMBER() OVER(order by Version) as 'Rowid'
from Instances
group by Version

insert into @instances
select SQLInstance
,case
when Environment like 'Dev%' then 'Development'
else Environment
end as 'Environment'
,case
when Version = '8.0' then 'SQL 2000'
when Version = '9.0' then 'SQL 2005'
when Version = '10.0' then 'SQL 2008'
when Version = '10.50' then 'SQL 2008 R2'
end as 'Version'
,ROW_NUMBER() OVER(order by sqlinstance) as 'Rowid'
from instances

set @fulllist =
'<?xml version="1.0" encoding="utf-8"?>
<Export serverType="8c91a03d-f9b4-46c0-a305-b5dcc79ff907">
<ServerType id="8c91a03d-f9b4-46c0-a305-b5dcc79ff907" name="Database Engine">
'

set @serverheader =
' <ConnectionInformation>
<ServerType>8c91a03d-f9b4-46c0-a305-b5dcc79ff907</ServerType>
<ServerName>'

set @serverfooter =
'</ServerName>
<AuthenticationType>0</AuthenticationType>
<UserName />
<Password />
<AdvancedOptions>
<PACKET_SIZE>4096</PACKET_SIZE>
<CONNECTION_TIMEOUT>15</CONNECTION_TIMEOUT>
<EXEC_TIMEOUT>0</EXEC_TIMEOUT>
<ENCRYPT_CONNECTION>False</ENCRYPT_CONNECTION>
</AdvancedOptions>
</ConnectionInformation>
</Server>
'

set @x = (select MIN(rowid) from @environments)

while(@x <= (select MAX(rowid) from @environments))
begin
select @fulllist +=
' <Group name="'+environment+'" description="">
'
from @environments
where rowid = @x

set @y = (select MIN(rowid) from @instances)

while(@y <= (select MAX(rowid) from @instances))
begin
if((select environment from @instances where rowid = @y) <> (select environment from @environments where rowid = @x))
begin
set @y = @y +1
continue
end

select @serverentry = ' <Server name="'+instancename+'" description="">'+@serverheader+instancename+@serverfooter
from @instances
where rowid = @y

select @fulllist += @serverentry

set @y = @y + 1
end

select @fulllist +=
' </Group>
'
set @x = @x + 1
end

set @x = (select MIN(rowid) from @versions)

while(@x <= (select MAX(rowid) from @versions))
begin
select @fulllist +=
' <Group name="'+version+'" description="">
'
from @versions
where rowid = @x

set @y = (select MIN(rowid) from @instances)

while(@y <= (select MAX(rowid) from @instances))
begin
if((select version from @instances where rowid = @y) <> (select version from @versions where rowid = @x))
begin
set @y = @y +1
continue
end

select @serverentry = ' <Server name="'+instancename+'" description="">'+@serverheader+instancename+@serverfooter
from @instances
where rowid = @y

select @fulllist += @serverentry

set @y = @y + 1
end

select @fulllist +=
' </Group>
'
set @x = @x + 1
end
select @fulllist +=
' </ServerType>
</Export>'

select convert(xml,@fulllist)

Monday, August 30, 2010

First day back

Today was my first day back at work after a 3 week break and was immediately thrust into a half-day meeting/training.  Kalen Delaney and query plan caching.  Fun stuff.

New beginnings

So I'm gonna try my hand at this whole blogging thing for work and post tips, tricks, and problems I run into.