Moving a table to another filegroup

by Syska 9. June 2010 16:10

So, how does one move a table to another filegroup.

Say I have the following table:

CREATE TABLE [dbo].[Tests](
    [TestID] [int] NOT NULL,
    [TestInt] [int] NOT NULL,
    [TestBigInt] [bigint] NOT NULL,
 CONSTRAINT [PK_Tests] PRIMARY KEY CLUSTERED 
(
    [TestID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

Since tables are always stored with the clustered index. Moving the clustered index, also moves the table. So if we want to move the table, we can recreate the CLUSTERED index on another storage group. Here we are moving from “PRIMARY” to “PRIMARY2”.

CREATE UNIQUE CLUSTERED INDEX PK_Tests
   ON dbo.Tests(TestID)
   WITH DROP_EXISTING
ON [PRIMARY2]

This can also be done when the table is online and is also moving the indexes. There are some performance diff if you are moving the table while its still online, so consider if its worth the extra overhead.

You can extend the relation index options with the create index command like this, to move it while its still online.

CREATE UNIQUE CLUSTERED INDEX PK_Tests
   ON dbo.Tests(TestID)
   WITH (DROP_EXISTING = ON, ONLINE = ON)
ON [PRIMARY2]

Tags: ,

MSSQL

Working with .NET Micro Framework and Fonts

by Syska 26. May 2010 18:39

So, for a smaller school project I’m going to make a remote controlled twitter client showing off the latest tweets from you the ones you are following or just from a search. So I wanted to make my own font and what a hell that was. Crappy command line tool … the font size if given as a parameter called “height”.

To save memory and space on target, Microsoft is using a new font format, instead of TTF, called tinyfont.

TFConvert overview
TFConvert reference

So I was reading Apress Expert .NET Micro Framework and they linked to this excellent Tiny Font Tool GUI, which makes it a lot easier to make fonts for your application. Instead of using the default fonts.

Now you got all the tools you need to create your own fonts. Hope this saves you some time.

happy I’m just so happy now, this saved my day

Tags:

Windows Mobile 6.5 – HTC HD2

by Syska 20. May 2010 01:16

htc-hd2I just got a HTC HD2. Nice piece of hardware when one is used to this wonder of a phone Nokia 1208:

nokia-1208-00  

But I ran into some problems or lets just call them limitations.

1. The wireless

I needed it to logon to a wireless network using WPA-Enterprise, TKIP & PEAP. It kept saying that my certificate was not valid … and it was right, but there were no ways of turning this off. Then I searched google and found this.

You need to edit this registry key and then it works:

\HKLM\Comm\EAP\Extension\25\ValidateServerCert=dword:00000000

ScreenShot12. The start page

The start page is limited to 3 icons per line and that's awful, what the hell were they thinking when making this. But after installing a little program I get 5 icons per line.

There are links to the cab files for 3, 4, 5 and 6 icons per line. The files names should be self explaining.

 

 

ScreenShot2

3. Home page

The Home tab is ARGHH and crappy, this little cab file will do wonders with it and you can edit it, dran’n’drop icons … you will love it. I know i do.

ScreenShot3Download HomeTab 1.7.1 - Home

Download CHTEditor - Home

Video of Co0kie's Home Tab Mod 1.7 for HTC Sense 2.5

Its required to signup to download but its worth the time.

 

 

 

 

 

 

 

 

ShakeAndSave4. Shake And Save

It's a print screen program for windows mobile. Used to make this blog post.

Download ShakeAndSave

Tips

1. keyboard

Just like the iPhone, if you double tap the space bar on the keyboard after a letter, you will enter a period (full stop) AND a space automatically.

2. Regdb Editor and other utilities

Resco explorer and lots of other great stuff. Try it out, its real nice.

Tags:

IsNullOrWhiteSpace

by Syska 22. April 2010 00:39

Instead of doing

   1: if(s == null || s.Length == 0)
   2:     return;

I normally do

   1: if(string.IsNullOrEmpty(s))
   2:     return;

So, as I would normally do, I started typing: string.Is and intellisense showed me an nice addition to the normal string class in .NET 4.0 … NICE :-).

   1: if (string.IsNullOrWhiteSpace(s))
   2:     return;

Its the little things in life that counts, this saved my evening after messing around trying to move all my projects from SVN to TFS 2010.

Tags:

Starting Cassini ASP.NET App on selected folder

by Syska 16. April 2010 01:57

I get some Web apps in compressed zip files. While its easy to unzip and map it to my local IIS server, its still a very doll job to do over and over again. So I was searching the web and came across ASP.NET 4 Web Server Here Shell Extension by Phil Haack.

A very simple shell extension starting the Cassini webserver on the selected folder:

image

And then just point you favorite browser at: http://localhost:8081/ or what ever port you used in the reg file.

I have attached both reg files for 32 & 64 bit.

32bit

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\VS2010 WebServer]
@="ASP.NET 4 Web Server Here"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\VS2010 WebServer\command]
@="C:\\Program Files\\Common Files\\microsoft shared\\DevServer\\10.0\\Webdev.WebServer40.exe /port:8081 /path:\"%1\""

64bit

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\VS2010 WebServer]
@="ASP.NET 4 Web Server Here"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\VS2010 WebServer\command]
@="C:\\Program Files (x86)\\Common Files\\microsoft shared\\DevServer\\10.0\\Webdev.WebServer40.exe /port:8081 /path:\"%1\""

Yes, the Formating is very bad, so to avoid any copy/paste errors, download the attached zip file.

Regs.zip (758.00 bytes)

Tags: , , , ,

Vind med Windows Azure

by Syska 15. April 2010 13:18

Kunne du tænke dig og prøve at deploy en Windows Azure og samtidig have muligheden for at vinde fede premiere. Så er dette noget for dig.

 

Besøg følgende link http://azure.danielfrost.dk/ og læs guiden for at komme igang.

Der er rift om de 400 tokens som er til rådighed.

Tags:

ASP.NET MVC 2 bug, misleading exception message

by Syska 29. March 2010 00:11

Today I was making some refactoring to my site made in ASP.NET MVC 2. Created a complex class on my  model, which should be passed to a RenderPartial like this:

<% Html.RenderPartial(“name”, Model.ComplexClass) %>

Corrected the type in the partial view I was expecting but got an odd error I think …

The model item passed into the dictionary is of type 'Model.MyModel', but this dictionary requires a model item of type 'Model.ComplexClass'.

So I started to look around, but got even more confused … recompiled, open and closed Visual Studio 2008, until I found the error. The reference to the ComplexClass was null. I’m not sure why it thinks it got a type of the model instead of the my ComplexClass.

This got to be a bug or something to do with the Reflection methods used to determine the type of the class passed to the PartialRender when trying to cast it and that failed. So when throwing the Exception, the information could be wrong … only guesses.

Update:
Searched the internet, and one person suggested parsing the values to the "ViewDateDictionary" ... but still not a good workaround here.

Tags: , ,

Find duplicate rows in MS SQL

by Syska 17. March 2010 17:51

So, the other day I was reading T-SQL: Why “It Depends” and in the comments section a guys suggested using the “PARTITION BY” in the OVER clause.

I thought was the heck does that do … so i searched the web for an answer … and wow … what a great way to find duplicate post … and possible also a lot of other things it can be used for that I haven’t thought about.

To the code …

WITH Data AS
(
	SELECT 
	ROW_NUMBER() OVER ( PARTITION BY CID ORDER BY Added DESC) AS DupeNumber
	,CID, Added
FROM Servers
)
SELECT * FROM Data Where DupeNumber >= 2

This will check for dupes on the CID column … and then select all the rows where DupeNumber is over or equal to 2. You could then instead of select it … you could delete it.

Fancy way … I like it.

Tags: , , ,

windows 7

Tcpdump – The ultimate tool for traffic analysis

by Syska 9. March 2010 14:50

Hello, so the other day I say that out external IP address was black listed on some black list … I used:
http://www.dnsbl.info/dnsbl-database-check.php
http://rbls.org/
http://whatismyipaddress.com/staticpages/index.php/is-my-ip-address-blacklisted

They are all similar, but maybe they show different result, if there database are outdated or the site could be down. Always a good idea to control the IP address against more sites.

So … we were black listed … but why. Back to the console on the firewall.

eth0 is my internal interface on the 172.17.4.0 network.

tcpdump -i eth1 net 172.17.4
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth1, link-type EN10MB (Ethernet), capture size 96 bytes
08:23:01.219395 IP x.x.x.x.dynamic.altibox.net.63486 > 172.17.4.251.distinct32: . ack 142967821 win 256
08:23:01.335626 IP 172.17.4.113.53814 > 93.152.158.87.47834: . 272803351:272804803(1452) ack 3427659943 win 16139 08:23:01.871096 IP pool-x-x-x-x.chi01.dsl-w.verizon.net.50129 > 172.17.4.251.distinct32: . ack 3979841491 win 62356 <nop,nop,timestamp 14764517 2569468>

This showed way to much information … back to reading the “man” pages for tcpdump. Then I saw that I could use logical operators and bit masking … now its getting fun. Also possible to look in the ip, tcp or udp package.

The DHCP server here only serves address from 100 and up … and as there are SMTP servers below that, we need to filter them out … looking at Figure 1, the source address is the 12byte and the next 4. We got the net address already …not we need to filter on the 4 octet.

tcpdump -i eth1 net 172.17.4 and \(ip[15] \>= 100\)

We can filter the port in 3 ways … either look at the tcp package or use “port 25” or “port smtp” in the name are located in the /etc/services file.

Doing the first … and looking at figure 2, we can see that we need read 2 bytes and have an offset of 2. Like “tpc[offset:bytes] = 25” and append it to the command we end up with the following.

tcpdump -i eth1 net 172.17.4 and \(ip[15] \>= 100\) and tcp[2:2] = 25
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth1, link-type EN10MB (Ethernet), capture size 96 bytes

This gives endless options … you can detect anything. Look in the data package … I’m amazed, this was not the first time using it, but probably the first time I understand all the options and possibilities it gives you.

Happy tcpdump’ing … :-)

Figure 1. IPv4 header

MJB-IP-Header-800x576

Figure 2. TCP header

MJB-TCP-Header-800x564

Tags: , , ,

Unix/Linux

Windows 7 Tips – Shortcuts

by Syska 5. December 2009 18:12

In windows 7 there are several great shortcuts that can make you day in front of the computer better, and here are some of them than I use often … and some of them I just know of.

Windows + Arrow

You can move the active window around on the screen.

capper-16 capper-18
Windows + Left Arrow
Will dock the window to the left
Windows + Right Arrow
Will dock the window to the right
capper-19 capper-17
Windows + Arrow up
Will maximize the window to the current screen.
Windows + Arrow Down
(do it again and it will minimize)

Windows + Shift + Arrow up

Like the shortcuts above, hitting these keys will stretch the active window vertically. Pressing Windows + Down will restore it to the previously size.

Alt + P

Alt_P

When you are in a explorer and want to preview things. Pressing Alt + P will bring up a preview window in the left part of the Explorer window. It can be used on all types of documents … but there is a startup time for them and depending on the time of document the first preview can take some time show.

Windows + + ( plus key ) and Windows + – ( minus key )

capper-21

Brings up the magnifier, so if you are showing something on a projector on a daily basis this is great. Consider you are showing how a program works, instead of lowering the resolution to something like 800x600 … you can just quickly zoom in on it.

You can of cause zoom out again using the other shortcut – Windows + – ( minus key )

capper-20 

Windows + P

capper-8

Will manage multiple monitor setup more easily or if you just connected a projector. Pressing the key P again while holding down the Windows key will loop over the available options.

Windows + [number]

capper-23

Here in my Taskbar i have:

  1. visionapp Remote Desktop 2010
  2. Visual Studio 2008
  3. Firefox ( of cause )
  4. Messenger
  5. Total Commander
  6. Windows Explorer
  7. Photo Viewer

Pressing Windows + 7 and this will bring up the Photo Viewer if there were only one instance. Here i got 2 so it lets to toggle between them. If there are no instance running of the program it will start one for you.

Ctrl + Click

capper-15

Holding down Ctrl while clicking a program icon in the taskbar will toggle between the instances. For example like in the above, that would toggle between the 2 instances of the Photo viewer. Here used with two instances of the Windows Explorer started.

Ctrl + Shift + Click

This will start the program clicked on with full administrative rights on the system. While not very useful I, it can be used as pinned programs to the Taskbar, would require more clicks, so it saves a little time :-)

Conclusion

These are some of the best shortcuts I have found to date, but there are still more I guess … so in the future I will update this blog post if I find any.

You you got any that you think is missing, please to post them as comments or contact me, and I will add them.

Tags: , , ,

About the brain

Mikael SyskaMikael Syska

Student at the Engineering College of Aarhus.

Microsoft Student Partner ( MSP )

On this blog I will primarily write about .NET, MSSQL & projects I'm working on ... and of course there will some off topic posts :-)