mei 01

Select top 100 most cpu intensive sql queries (with full query)

select top 100
        qs.plan_handle
      , avg_worker_time = (sum(qs.total_worker_time)/sum(qs.execution_count))
      , avg_worker_time_ms = (sum(qs.total_worker_time)/sum(qs.execution_count)/1000)
      , sum(qs.total_worker_time) as total_worker_time
      , sum(qs.execution_count) as total_execution_count
      , count(*) as  number_of_statements
      , st.text
from sys.dm_exec_query_stats qs
cross apply sys.dm_exec_sql_text(sql_handle) st
group by plan_handle, st.text
order by sum(qs.total_worker_time) desc, avg_worker_time desc

Select most cpu intensive sql queries (without full query, only statics)

select  qs.plan_handle
      , qs.sql_handle
      , avg_worker_time = (sum(qs.total_worker_time)/sum(qs.execution_count))
      , avg_worker_time_ms = (sum(qs.total_worker_time)/sum(qs.execution_count)/1000)
      , sum(qs.total_worker_time) as total_worker_time
      , sum(qs.execution_count) as total_execution_count
      , count(*) as  number_of_statements
from sys.dm_exec_query_stats qs
where qs.execution_count > 0
group by plan_handle, qs.sql_handle
order by avg_worker_time desc
Tags:
mei 01
DECLARE @tempDbCreationDate DATETIME, @totalminutes int, @days int, @hours int, @minutes int
SELECT @tempDbCreationDate=create_date FROM master.sys.databases WHERE NAME='tempdb'
SELECT @totalminutes = (DATEDIFF(mi, @tempDbCreationDate, GETDATE()))
SELECT @days = @totalminutes / 60 / 24
SELECT @hours = @totalminutes / 60 - @days * 24
SELECT @minutes = @totalminutes - @hours * 60 - @days * 24 * 60
PRINT 'SQL Server ' + CONVERT(VARCHAR(20),SERVERPROPERTY('SERVERNAME'))+' is online for the past ' + CAST(@days AS NVARCHAR(50)) + ' days, ' + CAST(@hours AS NVARCHAR(50)) + ' hours, ' + CAST(@minutes AS NVARCHAR(50)) + ' minutes'

-- Check for sql agent
IF NOT EXISTS (SELECT 1 FROM master.dbo.sysprocesses WHERE program_name = N'SQLAgent - Generic Refresher')
BEGIN
  PRINT 'SQL Server Agent not running'
END
ELSE BEGIN
  PRINT 'SQL Server Agent is running'
END

Inspiration source: http://social.msdn.microsoft.com/Forums/en/transactsql/thread/3d7aa13d-61a7-48d2-ada6-2398b31feb39

Tags:
apr 24

How to builda Ubuntu based Chrome Web Kiosk. Follow the steps...

sudo gedit /usr/share/xsessions/kiosk.desktop

[Desktop Entry]
Encoding=UTF-8
Name=Kiosk Mode
Comment=Chromium Kiosk Mode
Exec=/usr/share/xsessions/chromeKiosk.sh
Type=Application

sudo gedit /usr/share/xsessions/chromeKiosk.sh

#!/bin/bash
#get mac address and set as a viarble to be used in url.
MAC=$(ifconfig eth0 | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}')

#get current resolution from xrandr and save the screen size into the chrome Preferences. If not done chome starts in fullscreen with the size of the last window.
cat ~/.config/google-chrome/Default/Preferences | perl -pe "s/\"bottom.*/\"bottom\": $(xrandr | grep \* | cut -d' ' -f4 | cut -d'x' -f2),/" > ~/.config/google-chrome/Default/Preferences
cat ~/.config/google-chrome/Default/Preferences | perl -pe "s/\"right.*/\"right\": $(xrandr | grep \* | cut -d' ' -f4 | cut -d'x' -f1),/" > ~/.config/google-chrome/Default/Preferences

#Turn off screensaver
xset s off

#turn off power management
xset -dpms

#check if chrome is running and if not start it. This is to prevent loops.
if !(ps -A | grep -w chrome > /dev/null)
then

#sleep for 10 seconds because the web page will not load due to network not fully started at first boot.
sleep 10s
google-chrome --kiosk http://lakerveld.eu/?mac=$MAC&

#hide the cursor
unclutter -grab
fi

Make chromeKiosk.sh executable
sudo chmod 755 /usr/share/xsessions/chromeKiosk.sh

Make kiosk desktop the default
sudo gedit /etc/lightdm/lightdm.conf
Update the autologin... variables

Last step: test and play

Sources:
- http://ubuntuforums.org/showthread.php?t=1687545
- http://www.instructables.com/id/Setting-Up-Ubuntu-as-a-Kiosk-Web-Appliance/?ALLSTEPS
- http://askubuntu.com/questions/62833/how-do-i-change-the-default-session-for-when-using-auto-logins

Tags:
apr 16

1. Server manager, go to features, select "add features", select "smtp server"

2. Internet Information Services (IIS) 6.0 Manager, make sure that SMTP virtual server/default smtp server is running

3. Download and install the metabase explorer tool (part of the Internet Information Services (IIS) 6.0 Resource Kit Tools)

4. Metabase Explorer, give / check read permissions to IIS_IUSRS group on the LM/SMTPSvc/1, LM/SMTPSvc and LM

5. Give IIS_IUSRS group write permissions to pickup folder (C:\inetpub\mailroot\Pickup)

6. Use the following asp.net configuration settings:

<?xml version="1.0" encoding="UTF-8"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
    <system.net>
        <mailSettings>
            <smtp deliveryMethod="PickupDirectoryFromIis" from="website@contoso.com" />
        </mailSettings>
    </system.net>
</configuration>

7. Test aspx page

<%@ page language="C#" autoeventwireup="false" inherits="System.Web.UI.Page" title="Test Email" %>
<%@ import namespace="System.Net" %>
<%@ import namespace="System.Net.Mail" %>
<script runat="server">
protected void bTestMail_Click(object sender, EventArgs e)
{
  string time = DateTime.Now.ToString();
  MailMessage mm = new MailMessage();
  mm.From = new MailAddress(tbFrom.Text);
  mm.To.Add(tbTo.Text);
  mm.Subject = "Test email (" + time + ")";
  mm.Body = "Test SmtpDeliveryMethod.PickupDirectoryFromIis";
  try
  {
    SmtpClient smtp = new SmtpClient();
    smtp.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
    smtp.Send(mm);
    Response.Write("Message send (" + time + ")");
  }
  catch (SmtpException ex)
  {
    Response.Write(ex.Message);
  }
}
</script>
<html>
<head>
  <title>Test SmtpDeliveryMethod.PickupDirectoryFromIis</title>
</head>
<body>
  <form runat="server">
    From:<asp:textbox id="tbFrom" runat="server"></asp:textbox><br/>
    To:<asp:textbox id="tbTo" runat="server"></asp:textbox><br/>
    <asp:button runat="server" text="Send" onclick="bTestMail_Click" />
  </div>
  </form>
</body>
</html>

 

Sources:
http://forums.iis.net/p/1157046/1901343.aspx
http://stackoverflow.com/questions/1615088/problem-with-smtp-in-iis7

Tags:
apr 13

Found today a nice app for the iPad. Connect your iPad to a Windows 8 Consumer Preview edition.

http://www.splashtop.com/win8

 

After first reboot had an issue with the nVidia Geforce driver, resulting in a black screen with only a cursor on the iPad. Found a fix:

http://support-remote.splashtop.com/entries/20192176-black-screen-only-with-streamer-1-4-5-3?page=1#post_20251698

[HKEY_CURRENT_USER\Software\Splashtop Inc.\Splashtop Remote Server]
"EnableNvFBC"=dword:00000000

http://support-remote.splashtop.com/attachments/token/o6xlqzeccu3htjk/?name=EnableNvFBC.reg_

Tags:
apr 11

If you build a Windows Server 2008 R2 (or Windows 7) with MDT 2010 it creates an BDEDrive partition with the boot files on it, which you can't delete as it is the "Active" partion.

If you want to delete the partition them you need to copy boot files to the C drive by running "bcdboot c:\windows /s c:" from a command prompt (NOTE: Make sure the command prompt is opened as administrator or bcdboot will fail with a "Failure when attempting to copy boot files"). Once this is done then you can mark the C drive as active in Disk Management and reboot.

To stop the BDEDrive partition being created in future then add DoNotCreateExtraPartition=YES to your customsettings.ini.

Tags:
apr 11

Get-GlobalAddressList | update-GlobalAddressList

Get-AddressList | update-AddressList
Get-OfflineAddressBook | Update-OfflineAddressBook

Tags:
apr 05

use master

declare @vcdbname varchar(50)
--hier de naam van de database invullen waarvoor je de connections wil killen
set @vcdbname = 'Match_Online'

set nocount on

declare @spid int, @str varchar(255)

declare Users cursor for
select spid
from master..sysprocesses
where db_name(dbid) = @vcdbname
open users

fetch next from users into @spid
while @@fetch_status <> -1
begin
   if @@fetch_status = 0
   begin
      set @str = 'kill ' + convert(varchar, @spid)
      exec (@str)
   end
   fetch next from users into @spid
end

deallocate users

Tags:
mrt 27

Use the following section in the configuration:

<configuration> 
  <system.net> 
    <defaultProxy enabled="true"> 
      <proxy usesystemdefault="True"/> 
    </defaultProxy> 
  </system.net> 
</configuration>
Tags:
mrt 19

Exchange 2007

The command to use is

set-mailboxcalendarsettings "MailboxAlias" -BookingWindowInDays <# of days>

Example:

set-mailboxcalendarsettings "Meeting Room 1" -BookingWindowInDays 365

You can use Get-MailboxCalendarSettings to get a long list of other values supported by the calendar.

Get-MailboxCalendarSettings mailbox alias |fl

You will see a long list of the properties and their values that are associated with the resource mailbox.

 

Source: http://www.slipstick.com/outlook/calendar/booking-meetings-more-than-180-days-out/

Tags: