28 nov 2010

Xencenter Export

I had to move a vm from a "old" XenPool to a brand new Xen 5.6 Pool.

but unfortunately it was not as simple as it looked. everytime when i did an export i received an error after about 8 minutes. Being desperate after a lot of exports and errors i removed the xencenter and started a reinstall of XenCenter 5.6 ..... 5.6 ????  hmmmm... using XenCenter 5.6 for an export from a 5.5 environment can be tricky.


So i reinstalled xencenter 5.5 and my problems with exports was over

23 nov 2010

update Foreign keys in all tables with constraints

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: Elcomeno
-- Create date: 23/11/2010
-- Description: Searches for all constraints to the Referenced Column
-- generates update statements to replaces old FK with new FK
-- =============================================


CREATE PROCEDURE [dbo].[Z_Replace_OldFK_By_NewFK]


-- Add the parameters for the stored procedure here


@ReferencedColumnName Nvarchar(100),
@ReferencedTableName NVArchar(100),
@NewValue NVARCHAR(10),
@OldValue NVARCHAR(10)


AS
BEGIN
DECLARE @col1 NVARCHAR(100),@col2 NVARCHAR(100), @getRow CURSOR
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
SET @getRow = CURSOR FOR
SELECT
-- rc.CONSTRAINT_NAME,
rcu.TABLE_NAME 'Ref_Table',
rcu.COLUMN_NAME 'Ref_Column'
-- rcu1.TABLE_NAME 'Referenced_Table',
-- rcu1.COLUMN_NAME 'Referenced_Column'
FROM
INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS rc
INNER JOIN
INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE rcu

ON rc.CONSTRAINT_CATALOG = rcu.CONSTRAINT_CATALOG

AND rc.CONSTRAINT_NAME = rcu.CONSTRAINT_NAME

INNER JOIN

INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE rcu1

ON rc.UNIQUE_CONSTRAINT_CATALOG = rcu1.CONSTRAINT_CATALOG

AND rc.UNIQUE_CONSTRAINT_NAME = rcu1.CONSTRAINT_NAME

WHERE rcu1.COLUMN_NAME=@ReferencedColumnName AND rcu1.TABLE_NAME=@ReferencedTableName

ORDER BY rcu1.TABLE_NAME

OPEN @getRow

FETCH NEXT
FROM @getRow INTO @col1,@col2
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT 'UPDATE SET ' + @col2 + '=' + @NewValue + ' FROM ' + @col1 + ' WHERE ' + @col2 + '=' + @OldValue
--PRINT 'SELECT * FROM ' + @col1 + ' WHERE ' + @col2 + '=' + @OldValue
FETCH NEXT
FROM @getRow INTO @col1,@col2
END
CLOSE @getRow
DEALLOCATE @getRow
END

select all tables from a database

user generated tables
Select * from sysobjects where xtype='u'


system generated tables

Select * from sysobjects where xtype='s'

17 jun 2010

Generate Sql queries on the fly

BEGIN
DECLARE @TableName as nvarchar(50),@test as nvarchar(max)
SET @TableName = 'orders'
Print @TableName
SET @test = 'SELECT * FROM ' + @TableName
EXEC(@test)
END

8 jun 2010

SQL send an email from database mail

use Test
execute msdb.dbo.sp_send_dbmail
@profile_name='TEST',
@recipients = 'anemailadres@domainname.com',
@body = 'body of the mail',
@query = 'select * from orders',
@execute_query_database='',
@subject = 'subject of the mail',
@attach_query_result_as_file = 1

7 jun 2010

SQL With TIES Example

SELECT *
FROM QryCustomersWithMostOrders

Customer   OrderCount
A               3
B               3
C               1

SELECT  TOP 1  *
FROM QryCustomersWithMostOrders 
ORDER BY  OrderCount DESC

Customer   OrderCount
A               3

SELECT  TOP 1 WITH TIES *
FROM QryCustomersWithMostOrders 
ORDER BY  OrderCount DESC

Customer   OrderCount
A               3
B               3 

16 feb 2010

find used colums or functions in sql database

you have wrote your own function in several views or stored procedures, but you don't know anymore where you have used it? it can be difficult to find them.

i did it my way :

  1. open Microsoft Sql Server Management studio
  2. select the target database
  3. right click => tasks=> Generate scripts
  4. Select the database and press next
  5. select where you want to search in for example views and tabels and pess next
  6. presss select all to select all tables and press next
  7. press selet all to select all viewss and pres next
  8. choose for example "script to new query window"
  9. press next and finish.
does anyone has another or better idea?

9 feb 2010

Problems & experiences with files

Files can be created by different applications. more and more they all try to follow the standards that are defined by the different institutions. On the other hand there is a wild growing forest of apps where they try to use these standards. Take pdf-files as an example. There are the original adobe apps but you find a lot of pdf programs on sourceforge. When you generate pdf files with the different tools you'll find, you'll see that you get different files. This causes problems.... strange problems....

A Time ago i had a corrupt Word file. i'm sure that the file was created with MS Office 2000. But my 2007 did nothing else then put some messageboxes on the screen. after a while i opened the file with My OpenOffice 3.0 and voilĂ  ... problem solved.

In another situation I had an MS Excel 2003 file opened with my Excel 2007.
Ms Excel 2007 was in compatibility-mode. after i changed the file extension to xlsx file i discovered that the filesize reduced with more than 40%.

here are some other standard Tricks wich you can use in these kind of situations :

  • Open and Save
  1. open file exported from other program
  2. Save file in current program
  • open the file and copy it to a new File
  1. open file
  2. Select all
  3. copy
  4. open new file
  5. paste all
  6. save new file
  • Open it in another application / Generate the file with an other application if possible
  • Install Different File viewers.
  • Some programs have cleaning options.
  1. autocad : purge commands
  2. office : repair options
  • find the autoRecover files from the application
  1. asd files for MS Word
  2. xar files for Ms Excel

7 feb 2010

Syslog Server for windows

many applications, appliances and services have an option for logging to a syslog server.
You can setup a vanilla linux server for this. an other option is to use the Aonaware Syslog Daemon.
it is a windows service that runs a syslog server. All the received messages will be parsed to a MS sql server. very handy if you have a windows-only environment.

31 jan 2010

Remind your visions of life with a digital photo frame

i've read books about different subjects like management and other theoretical books. All these books have one thing in common ... they all had a shema to remember and to use it as a tool. unfortunately i forget these schema's.

But my idea is to buy a digital photo frame and put the schema's as photo on this photo frame so i will see the shema's between the nice pictures of me.

27 jan 2010

scan wifi in the neighborhood

inSSider is a Netstumbler alternative.
Both of the applications use your Wireless Network adapter to scan all the Access Points in your neighborhood. When you experiencing latency on you wifi you use these tools to see what channels are used in the neighborhood. Try to find a channel that is not used or selectt one that is used by the access points far away(week signal)....

You can also use these applications to align antenna's.

Also Xirrus Wi-Fi Inspector  is such an application. (didnt test it)

Sending SMS with GSM modem


i lost the link to the original webpage where i found this.
but it works ....

i used an HUAWEI E160E modem


Imports System.IO.Ports


Public Class SMSSender



Dim WithEvents serialport As New IO.Ports.SerialPort
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Public Sub New()

End Sub

Public Sub SendMessage(ByVal SerialPortName As String, ByVal PhoneNumber As String, ByVal TextMessage As String)
If SerialPort.IsOpen Then
SerialPort.Close()
End If

Try
SerialPort.PortName = SerialPortName
SerialPort.BaudRate = 192000
SerialPort.Parity = Parity.None
SerialPort.DataBits = 8
SerialPort.StopBits = StopBits.One
SerialPort.Handshake = Handshake.RequestToSend
SerialPort.DtrEnable = True
SerialPort.RtsEnable = True
SerialPort.NewLine = vbCrLf
SerialPort.Open()

SerialPort.WriteLine("AT+CMGF=1" & vbCr)
System.Threading.Thread.Sleep(200)
SerialPort.WriteLine("AT+CMGS=" & Chr(34) & PhoneNumber & Chr(34) & vbCr)
System.Threading.Thread.Sleep(200)
SerialPort.WriteLine(TextMessage & vbCrLf & Chr(26))
System.Threading.Thread.Sleep(200)
Catch ex As Exception

Finally

SerialPort.Close()
End Try

End Sub

Public Sub GetModes(ByVal SerialPortName As String)
If SerialPort.IsOpen Then
SerialPort.Close()
End If
Dim myline As Object
Try
SerialPort.PortName = SerialPortName
SerialPort.BaudRate = 96000
SerialPort.Parity = Parity.None
SerialPort.DataBits = 8
SerialPort.StopBits = StopBits.One
SerialPort.Handshake = Handshake.RequestToSend
SerialPort.DtrEnable = True
SerialPort.RtsEnable = True
SerialPort.NewLine = vbCrLf
SerialPort.Open()

SerialPort.WriteLine("AT+CMGF=1" & vbCr)
System.Threading.Thread.Sleep(200)
serialport.WriteLine("AT+CMGL=" + Chr(34) + "ALL" + Chr(34) & vbCr)
serialport.WriteLine("AT+CMGL=" + Chr(34) + "REC UNREAD" + Chr(34) & vbCr)
myline = SerialPort.ReadExisting()

Catch ex As Exception

Finally

serialport.Close()
serialport.Dispose()
End Try

End Sub

End Class


If you want to deploy sms for all your users use an smtp2sms gateway
there are plenty on the internet

i did a setup with
Network SMS Gateway and took about 5 minutes

enjoy

16 jan 2010

polarization of wireless antenna's

When you install a wireless bridge you have to recognize the importance of the antenna polarization

See this and read about it on wikipedia

when you understand this, you have also a good idea on how to align wifi antenna's.