03.14.07

The art of scripting replications.

Posted in DBA, Microsoft Sql server, TSQL at 9:00 pm by

Open the Microsoft sql server management studio.
In the object explorer pane you connect to the base server.
You open the replication node then local publications and Rightclick on the desired replication.
Select generate script from the pop up menu.
Make sure “Create or enable the components.” is selected.
Script to file…
Then open this file replace the name of original server in the whole file with the name of the serevr you want to deploy to.

In my case it only was written once in the :exec sp_addpublication

Then look for @job_password = null if the @job_login isn’t null either you have to provide the password for that account.

Also look for
exec sp_grant_publication_access @publication = N’My publication’, @login = N’oldserverSQLServer2005SQLAgentUser$oldserver$MSSQLSERVER’

Change the oldserver to newserver name. (better check for the correct account first!

First enable distribution on your new server.
Then run the file you crafted.

03.13.07

Creating a distributor with the sql server management studio and losing connection with the server

Posted in DBA, Microsoft Sql server, TSQL at 11:35 pm by

Scenario: Using the sql server management studio you are setting up a server to act as distributor. Then while you have clicked finished the connection is lost between your workstation and the server. Now the server thinks he’s a distributor but then again he’s not sure! You try to redo the previous action but that won’t work. What you need to do is tell the server to give up being a distributor.


use master

exec sp_dropdistributor @no_checks = 1, @ignore_distributor = 1

GO

Now just restart the distribution creation wizard.

03.12.07

Generating insert statements from data(manual way)

Posted in DBA, Microsoft Sql server, TSQL at 9:12 pm by

Sample :

DECLARE @replunit as char(2);
DECLARE @kantoor_nr as varchar(4);
DECLARE @kas_nr as varchar(4);
DECLARE @bediende_nr as varchar(4);

SET @replunit = ‘BE’;
SET @kantoor_nr = ‘141′;
SET @kas_nr = ‘1′;
SET @bediende_nr = ‘996′;

SELECT
INSERT INTO KasBeginSaldo
(
KBS_ReplUnit,
KBS_KantoorNr,
KBS_KasNr,
KBS_ItemCode,
KBS_SubCode,
KBS_TijdStip,
KBS_BediendeNr,
KBS_Aantal,
KBS_Waarde,
KBS_VerschilWaarde,
KBS_BediendeNrTeller,
KBS_TijdstipTelling
) VALUES
( @replunit,
@kantoor_nr,
@kas_nr, ‘ +
”” + CAST(KBS_ItemCode AS varchar(8000)) + ”’, ‘ +
”” + CAST(KBS_SubCode AS varchar(8000)) + ”’, ‘ +
”” + CAST(getdate() AS varchar(8000)) + ”’, ‘ +
‘@bediende_nr, ‘ +
CAST(KBS_Aantal AS varchar(8000)) + ‘, ‘ +
CAST(KBS_Waarde AS varchar(8000)) + ‘, ‘ +
CAST(KBS_VerschilWaarde AS varchar(8000)) + ‘, ‘ +
CAST(KBS_BediendeNrTeller AS varchar(8000)) + ‘, ‘ +
”” + CAST(KBS_TijdstipTelling AS varchar(8000)) + ”” +
‘);’ as statement
FROM
KasBeginSaldo
WHERE
KBS_KantoorNr = @kantoor_nr AND
KBS_KasNr = @kas_nr AND
KBS_ReplUnit = @replunit;

03.11.07

Changing a property for all articles on a publication.

Posted in DBA, Microsoft Sql server, TSQL at 1:30 pm by

This week I had to change the pre_creation_cmd from ‘delete’ to ‘drop’ on all articles of a publication. I could do this manually or I could find all articles by using sp_helparticle. Lazy as I’m I opt for the latest option.

DECLARE @articles table
(
[article id] int,
[article name] varchar(255),
[base object] varchar(255),
[destination object] varchar(255),
[synchronization object] varchar(255),
[type] int,
status varchar(255),
filter varchar(255),
description varchar(255),
insert_command varchar(255),
update_command varchar(255),
delete_command varchar(255),
[creation script path] varchar(255),
[vertical partition] varchar(255),
pre_creation_cmd varchar(255),
filter_clause varchar(255),
schema_option varchar(255),
dest_owner varchar(255),
source_owner varchar(255),
unqua_source_object varchar(255),
sync_object_owner varchar(255),
unqualified_sync_object varchar(255),
filter_owner varchar(255),
unqua_filter varchar(255),
auto_identity_range varchar(255),
publisher_identity_range varchar(255),
identity_range varchar(255),
threshold varchar(255),
identityrangemanagementoption varchar(255),
fire_triggers_on_snapshot varchar(255)

);
DECLARE @article_name varchar(255);

INSERT INTO @articles
exec sp_helparticle  'Your replication publication name';

DECLARE article_cursor CURSOR FOR
SELECT [article name] as base_object FROM @articles;

OPEN article_cursor;

FETCH NEXT FROM article_cursor
INTO @article_name;

WHILE @@FETCH_STATUS = 0
BEGIN

EXEC sp_changearticle
@publication = 'Your replication publication name',
@article = @article_name,
@property = N'pre_creation_cmd',
@value = 'drop',
@force_invalidate_snapshot = 1,
@force_reinit_subscription= 1;

FETCH NEXT FROM article_cursor
INTO @article_name;

END

CLOSE article_cursor;
DEALLOCATE article_cursor;
GO

After this you need to reinit all the subscriptions.

12.03.06

Having Problems With the ‘nvidia’ X.Org Driver and a Dell Inspiron 8000/8100?

Posted in Linux at 7:52 pm by

Because I needed to hook my laptop up to a beamer, I recently found myself installing the proprietary ‘nvidia’ driver again. Unfortunately, when I restarted X, I was greeted with the following error:

(II) Setting vga for screen 0.
(**) NVIDIA(0): Depth 24, (–) framebuffer bpp 32
(==) NVIDIA(0): RGB weight 888
(==) NVIDIA(0): Default visual is TrueColor
(==) NVIDIA(0): Using gamma correction (1.0, 1.0, 1.0)
(**) NVIDIA(0): Enabling RENDER acceleration
(II) NVIDIA(0): Support for GLX with the Damage and Composite X extensions is
(II) NVIDIA(0): enabled.
(EE) NVIDIA(0): Failure reading maximum pixel clock value for display device
(EE) NVIDIA(0): CRT-0.
(WW) NVIDIA(0): Unable to read EDID for display device CRT-0
(EE) NVIDIA(0): Failure reading maximum pixel clock value for display device
(EE) NVIDIA(0): TV-0.
(EE) NVIDIA(0): Failure to determine the TV encoder.
(II) NVIDIA(0): NVIDIA GPU GeForce2 Go at PCI:1:0:0
(–) NVIDIA(0): VideoRAM: 16384 kBytes
(–) NVIDIA(0): VideoBIOS: 03.11.01.13.12
(II) NVIDIA(0): Detected AGP rate: 4X
(–) NVIDIA(0): Interlaced video modes are not supported on this GPU
(–) NVIDIA(0): Connected display device(s) on GeForce2 Go at PCI:1:0:0:
(–) NVIDIA(0): CRT-0
(–) NVIDIA(0): (null) TV Encoder (TV-0)
(–) NVIDIA(0): NVIDIA NVIDIA_SXGA (DFP-0)
(–) NVIDIA(0): CRT-0: 100.0 MHz maximum pixel clock
(–) NVIDIA(0): (null) TV Encoder (TV-0): 100.0 MHz maximum pixel clock
(–) NVIDIA(0): TV encoder: (null)
(II) NVIDIA(0): Assigned Display Device: CRT-0
(WW) NVIDIA(0): No valid modes for “1400×1050″; removing.
(WW) NVIDIA(0):
(WW) NVIDIA(0): Unable to validate any modes; falling back to the default mode
(WW) NVIDIA(0): “nvidia-auto-select”.
(WW) NVIDIA(0):
(II) NVIDIA(0): Validated modes:
(II) NVIDIA(0): “nvidia-auto-select”
(II) NVIDIA(0): Virtual screen size determined to be 1024 x 768
(WW) NVIDIA(0): Unable to get display device CRT-0’s EDID; cannot compute DPI
(WW) NVIDIA(0): from EDID.
(==) NVIDIA(0): DPI set to (75, 75); computed from built-in default

It’s a very uninformative error as I had neither a CRT monitor nor a TV hooked up to my laptop. The problem, it turns out, is an incompatibility between recent ‘nvidia’ drivers and the Dell Inspiron 8000/8100 BIOS. The solution is to simply upgrade your BIOS. You can download Dell BIOS upgrades here. Use Dell’s BIOSdisk if you’re otherwise unable to boot into DOS.

10.14.06

Vi: Search and Replace

Posted in Linux, Miscellaneous at 9:58 pm by

Search (Wraped around at end of file):

Search STRING forward :   / STRING.
Search STRING backward:   ? STRING.

Repeat search:   n
Repeat search in opposite direction:  N  (SHIFT-n)

Replace: Same as with sed, Replace OLD with NEW:

First occurrence on current line:      :s/OLD/NEW

Globally (all) on current line:        :s/OLD/NEW/g

Between two lines #,#:                 :#,#s/OLD/NEW/g

Every occurrence in file:              :%s/OLD/NEW/g

10.10.06

Posted in Linux, Miscellaneous at 11:14 pm by

Getting awstats running with geoip

GeoIp C API

To start you‘ll need to install GeoIP C API. Download it :

wget http://www.maxmind.com/download/geoip/api/c/GeoIP.tar.gz 
 
Next thing is unzipping it and placing the directory where you want it.
I use midnight commander for this so just fire it up and copy it.
 
Starting midnight commander:
 
Mc
 
Go into the directory you just created by unzipping.
 
Do the following commands:
 
./configure
make
make check
make install
 
The GeoIP C API has been installed. Next we install the IP Perl Module.
 
When this fails and you are on a linux distro(debian taste) you might want to run:
apt-get update
apt-get upgrade
apt-get install gcc
apt-get install make
apt-get install texinfo
apt-get install libc6
apt-get install zlib1g-dev
 
 

GeoIP Perl API

Download Geo::IP Perl Module, use the command below but recplace THE_LAST_VERSION with the right tar.gz file

wget http://www.maxmind.com/download/geoip/api/perl/THE_LAST_VERSION

Next thing is unzipping it and placing the directory where you want it.
Go into the directory you just created by unzipping.

Now do the following commands. (if you have a problem with the make test see for instruction after the commands)

perl Makefile.PL
make
make test
make install
 

Only if you had problems

 
If you get a “libGeoIP.so.1: cannot open shared object No such file or
directory” error, add /usr/local/lib to /etc/ld.so.conf then run
/sbin/ldconfig /etc/ld.so.conf     
 
 
 

Awstats

Now you need to go to the config file of your website and alter the Plugin: GeoIP part.

Change /pathto/GeoIP.dat to where this database acctually is. You can quicly find it by

Doing a locate. Well quickly you’ll have to do a locate –u first of course which will take some time.

locate –u

locate GeoIP.dat

On my system it returns:

/usr/local/share/GeoIP/GeoIP.dat

Now I replace # LoadPlugin=”geoip GEOIP_STANDARD /pathto/GeoIP.dat”

By

LoadPlugin=”geoip GEOIP_STANDARD /usr/local/share/GeoIP/GeoIP.dat”

This is the section where to do it

 
# Plugin: GeoIP

# Perl modules required: Geo::IP or Geo::IP::PurePerl (from Maxmind)

# Country chart is built from an Internet IP-Country database.

# This plugin is useless for intranet only log files.

# Note: You must choose between using this plugin (need Perl Geo::IP module

# from Maxmind, database more up to date) or the GeoIPfree plugin (need

# Perl Geo::IPfree module, database less up to date).

# This plugin reduces AWStats speed of 8% !

#

#LoadPlugin=”geoip GEOIP_STANDARD /pathto/GeoIP.dat”
 
Also make sure that DNSLookup look up is turned off.
 
DNSLookup=0
 

Congratulations you have now a awstats with a working geoip module.

09.23.06

VB errorchecking on lostfocus event

Posted in Visual Basic 6 at 2:14 am by

Today an error was reported by an end user of my program. They could get a crazy unstopable msgbox hell. After some investigation I found this happens when the user moves the focus from one faulty text field into another one which is also faulty. Both of these textfields have a lostfocus event. In the lostfocus event some checks are done and when they checks are positive a msgbox is shown and the focus is reset to the own textbox. Internally VB triggers a lost focus event when the user leaves the textbox. Then this lostfocus event does a setfocus on it’s own textbox. This triggers the lostfocus event of the other textbox, because by clicking on it the other textbox had the focus. The solution is simpel first do a setfocus and then show a msgbox with the error.

If Not ValidDate(Somefield.Text) Then
Somefield.SetFocus
msgBox "Some message"
End if

08.27.06

How to Connect GTalk to MSN/ICQ/AIM/Yahoo

Posted in Miscellaneous at 8:02 pm by

GTalk, Google’s instant messaging client, uses the Jabber network protocol (also known as XMPP). Now although GTalk doesn’t expose it in its user interface, Jabber has a concept of transports that let you communicate with users on non-Jabber instant messaging networks. Using the small trick detailed below, it is possible to get these transports working in GTalk.

Adding Transports to your GTalk Account

First you need to set up GTalk to acknowledge other, non-Jabber/XMPP instant messaging networks. As this is not possible using the official GTalk client, you will need to install a more featureful Jabber client program. Pick any client that will work on your platform. For a list of Jabber clients and instructions on how to log into GTalk, see this page. (A comprehensive list of Jabber clients can be found here, but doesn’t come with instructions specific to GTalk.) Once installed you will need to start the program and log in to your GTalk account. After having logged in, only two more steps for registering a transport remain:

  1. Find a public Jabber/XMPP transport for the network you want to connect to. Try googling for it or use the popular jabber.anywise.com;
  2. Add this transport to your GTalk account.

Once you have decided on a transport to use, you’ll need to bring up your Jabber client’s Service Discovery dialog. If you don’t know where it is, look around in the menus a bit. In the Service Discovery dialog enter the name of the Jabber server that has the transport you need.

Jabber/XMPP Service Discovery in Gajim

Next register the transport you need. You should be prompted for your username and password. You will need to enter a username and password for the instant messaging network you want to connect to. I.e., if you wish to install an MSN transport, you will need to enter the username and password you normally use to connect to MSN. If you don’t have an account yet, create one now using the standard procedure for the instant messaging network you want to connect to (if you need an account for MSN, check passport.net).

Register Transport in Gajim

Once you have registered your transport, subscription requests may pop up for the people on your MSN/ICQ/AIM/Yahoo contact list. Approve these.

Subscription Request in Gajim

Adding MSN/ICQ/AIM/Yahoo Buddies to your GTalk Contact List

Once you have registered a relevant transport, you can add users from other instant messaging networks to your contact list. One way to go about that is to add them via the Jabber client that you installed. This client should allow you to select the transport or protocol through which the user can be reached.

Add Contact in Gaim

Alternatively you can add a friend to your contact list from GTalk (even using the web based GTalk in GMail). To do this add “username@transport” to your contact list, where username is the name of the user on whatever network he is using, and where transport is the name of the transport to contact him through. For instance, if you’re using the jabber.anywise.com MSN transport, you’ll want to enter “msn.jabber.anywise.com” for transport. To find out the name of a transport, look at other users on your contact list that use the same instant messaging network. The part of after the “@” in their GTalk username, is the name of the transport. If you don’t have any such people on your contact list, you might also look for the transport name in your contact list, although it might be burried beneath a Show All link (this is the case in the web based GTalk as of August 2006). Sometimes it will also be necessary to mangle usernames a bit when adding them. Thus it may happen that to add MSN user “jdv@foobar.be”, you have to tell GTalk to add “jdv%foobar.be@msn.jabber.anywise.com”. Take a peak at the other users’ GTalk usernames for finding your way around such obstacles.

08.26.06

Totem Slow in Ubuntu Dapper Drake

Posted in Ubuntu at 4:17 pm by

If Totem, the GNOME movie player, has been unusually slow for you lately, you might want to try configuring GStreamer (the GNOME multimedia framework) to use ALSA for audio output instead of esd. The following steps should fix your problem:

  1. Press Alt+F2. This will pop up the run dialog;
  2. Type “gstreamer-properties” and press enter;
  3. In the first dropdown list on your screen (Audio → Default Output Plugin → Output) choose ALSA;
  4. Close and restart Totem.

There’s one caveat though: depending on your sound card you may no longer be able to run multiple audio using applications side by side. E.g., it may no longer be possible to play a song in Muine while you have a movie playing in Totem – even if said movie is paused.

Hopefully GNOME and Ubuntu will switch to the esd-compatible audio server PulseAudio (formerly known as polypaudio) in the near future, and we’ll have no more of this nonsense.

« Previous entries · Next entries »