Detecting the default Data Path for SQLServer
June 22, 2007 on 9:59 am | In Technology | No CommentsNormally, when you create a DB, you perform it manually through Enterprise Manager (if you use SQLServer2000) or Management Studio (if SQLServer 2005).
Sometimes, during the setup of an Application, it’s needed to create a DB from scratch; In the CREATE DATABASE command, you need to specify the FULL path for the physical file of the DB.
As, at runtime, you don’t know what’s the default Data directory for the choosen DB Server, you need to retrieve it.
The following SQL Snippet allow you to retrieve the Default Data Directory for the current DB you’re connected to:
USE master DECLARE @defaultDataPath As nvarchar(255) SET @defaultDataPath = (SELECT REPLACE(filename, 'model.mdf', '')
FROM SysDatabases WHERE name = 'model' )
Try to post from ImIfied
June 6, 2007 on 4:28 pm | In Uncategorized | No CommentsHere’s a small post from my Instant Messenger client.
Will this kind of blogging work for me ? Who’s using this kind of blogging ?
What kind of programmer am I ?
June 6, 2007 on 2:25 pm | In General | No CommentsFrom an online Programmers Personality Test, here’s my own personality…in programming
.
Your programmer personality type is:
DLSC
You’re a Doer.
You are very quick at getting tasks done. You believe the outcome is the most important part of a task and the faster you can reach that outcome the better. After all, time is money.You like coding at a Low level.
You’re from the old school of programming and believe that you should have an intimate relationship with the computer. You don’t mind juggling registers around and spending hours getting a 5% performance increase in an algorithm.You work best in a Solo situation.
The best way to program is by yourself. There’s no communication problems, you know every part of the code allowing you to write the best programs possible.You are a Conservative programmer.
The less code you write, the less chance there is of it containing a bug. You write short and to the point code that gets the job done efficiently.
Am I really this ? Mmm…YES! But the second point (”Low level programming”) is not stuck with me…anymore!
I remember of me optimizing code (x86 assembly code) with the Pentium pipelines…but NOW I’m too lazy to write code thinking of CPU-cycles…
My first post from WLW Beta2
May 31, 2007 on 10:08 am | In Technology, Blog | No CommentsThanks to Simone, I can try the second Beta of Windows Live Writer.
Something is changed … I have to re-align my eyes to the new layout…but at the end it’s very “Vista-like”.
Will this tool increase my blogging ? ![]()
Live Search Box
May 30, 2007 on 1:40 pm | In Technology, Blog | No CommentsThanks to Andrea’s post, I’ve just introduced the “Live Search Box” also on this blog.
Actually the blog hasn’t so much content to be indexed by MS Live Search BUT … it doesn’t find anything related to my blog…yet
.
Anyhow I modified the Pool Theme for WordPress (from inside the administration web console) so :
- I totally removed the search div from the Header.php file
- I inserted the script Live Search box site generated into the Sidebar.php just above the default ones (Categories &C.)
Finally, I modified (Was I allowed to do it ?
) the generated script so the table is just 160px instead of the 322px default size.
I hope to find MY contents more easily from now on…what do you think ?
Converting WEP Passphrase into Hex numbers
May 11, 2007 on 4:24 pm | In Technology | No CommentsPeople like me, usually, go from strong development to system administration and network management (yes, there’s a dark side into me
).
As I also need, sometimes, to manage Cisco (and other kind of) wireless routers, I created (with the help of MS .NET Framework) a small utility to
convert WEP Passphrase (some routers accept as Encryption Key) to Hex Digits.
It’s a simple task but, sometimes, you need to do it immediately or by a software…so I wrote this software for you all.
Here’s the source code (just a copy and paste) of the Console Application; moreover, you can download the compiled app here.
using System;
using System.Text;
namespace Bitbreaker.Utilities.WiFiKeyConverter
{
class WiFiKeyConverter
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
Console.WriteLine("WiFi Key Converter - Igor Antonacci ");
Console.Write("Please insert the passphrase to convert: ");
string passphrase = Console.ReadLine();
byte[] wifiKeyArray = System.Text.Encoding.ASCII.GetBytes(passphrase);
StringBuilder sb = new StringBuilder();
for(int i=0;i<wifiKeyArray.Length;i++)
{
sb.AppendFormat("{0:X}",wifiKeyArray[i]);
}
Console.WriteLine("The Hex Key is {0}",sb.ToString());
Console.Write("Press return to continue...");
Console.ReadLine();
}
}
}
I hope this will shorten your code rush
.
Captcha Plugin - Patched
February 12, 2007 on 9:00 pm | In Technology | No CommentsSince I decided to start blogging again on this blog, I saw my WordPress Captcha plugin from Boriel didn’t work anymore.
First step: check for new Versions…and I was with a veeeery old version (1.9 vs. 2.5d).
I simply followed Readme file inside the package (of the latest version I downloaded) and I upgraded the plugin.
Unfortunately, the setup ended with a list of errors INSTEAD of the image “to keep Human and Computer apart”.
Three errors (similar each other) appeared :
WordPress database error: [Unknown column ‘public_key’ in ‘field list’]
INSERT INTO `wp_captcha_keys` (`public_key`, `tries`) VALUES(’67c12′, 1)
Solution:
First, I created a backup of the DB my blog is based on.
From those scripts, I checked all fields in the wp_captcha_keys table and I saw that the field public_key didn’t exist BUT a private_key was there.
I replaced the non-existent field name with the real one in the whole file, I uploaded the captcha.php again … and BINGO!, a picture was there to insert a comment.
Errors in Maintenance Plan executions’ Jobs
February 12, 2007 on 1:03 pm | In Technology | No CommentsWhen you schedule a Maintenance Plan in SQLServer 2000 that performs also an Integrity Check, it can fail under some conditions.
The error, that appears in the log of the Job the Maintenance Plans Wizard creates, is the following:
“Executed as user: NT AUTHORITY\SYSTEM. sqlmaint.exe failed. [SQLSTATE 42000] (Error 22029). The step failed.”
It means that, the Job has been executed under the NT AUTHORITY\SYSTEM account:
more explictly, the service SQLServerAgent runs with Local Service Account (along with the MSSQLServer service) .
Solution: Change the account BOTH the SQLServer Agent AND MSSQLServer service run on.
Normally, it’s a special created account but, in some conditions, the local Administrator account is needed.
Moreover, AND IT IS VERY IMPORTANT, enable the local Administrator account to Log on as batch.
It’s a policy you can change with the local policy editor ( Run -> Start -> gpedit.msc ).
Enabling AWE option on SQLServer 2000 Ent. Ed.
February 9, 2007 on 6:09 pm | In Technology | 1 CommentToday we experienced the AWE option of SQLServer 2000 and here there are errors and workaround you can use to fully-enable it.
Let’s begin from the explanation of that option: If you have a 32bit version of Windows Server (2000 or 2003) with more than 4Gb (so, Advanced Server version of Windows 2000 or Enterprise Ed. of Windows 2003), along with SQLServer 2000 Enterprise Ed., you need to tell both
- Microsoft Windows Server to address more than the 4Gb Limit (/PAE option) AND to let every process to address more than the 3GB limit (/3GB)
- Microsoft SQLServer to address up to 64GB (instead of the base 2GB limit); this feature is called AWE.
The first step (1) could be easily done thru the editing of the boot.ini file in the boot drive (e.g. C:\boot.ini ); be aware it’s a read-only file: uncheck the Read-Only checkbox before editing AND put it back again when you finish. Remember: IT IS a SYSTEM FILE. BACKUP IT before changing.
Go ahead with step 2.
Here’s a simple script you can run (based on both your server’s memory configuration and the kind of client applications).
sp_configure 'show advanced options',1 RECONFIGURE GO sp_configure 'awe enabled',1 RECONFIGURE GO -- sp_configure 'min server memory',5120 sp_configure 'min server memory',<SQL Server minimum reserved memory (in MB)> RECONFIGURE GO -- sp_configure 'max server memory',5120 sp_configure 'max server memory',<SQL Server maximum reserved memory (in MB)> RECONFIGURE GO
Restricting Policy
Unfortunately, things can’t go on as simple as they are.
At the time I’m writing, I found 2 Windows Server 2003 Ent. Ed. that has a “limiting” policy about the Pages a user can allocate (lock).
I suppose it’s a default setting or a new setting Servers got from Windows Update.
As soon as you change the boot.ini and run the script above (and a reboot), SQLServer continues to reserve the “original” amount of memory (the amount before these changes).
Looking into the SQLServer Log File, you can find this message : “Cannot use Address Windowing Extensions because lock memory privilege was not granted“.
The reason why of this, is in the MS KB article KB811891 .
You can follow the KB instructions for Windows 2000 BUT for Windows 2003, you have to follow these instructions:
- Open the Local Policy editor (Start -> Run -> gpedit.msc )
- Browse through the following nodes:
Local Computer Policy -> Computer Configuration -> Windows Settings -> Security Settings -> Local Policies -> User Rights Assignment - Choose the Lock memory pages policy and Add the Local Administrators group (or the user you used to run MSSQLServer Service).
- Reboot the server (I know it’s not needed BUT it’s better for a complete policy refresh)
Final considerations
The (min and max) amount of reserved memory you should reserve may vary upon Your server configuration (e.g.: with a dedicated DB server with
physical amount of memory of 8Gb, you can reserve 6Gb).
Finally, you can choose to have a FIXED amount of memory reserved (min and max amount are the same) OR a dynamic allocation (min amount is lower than max).
It depends on your applications: if the amount of queries is not requiring too much memory and you’d like to leave more memory for other services running on the same server, it’s better to have a dynamic amount of memory reservation.
On the other hand, if the server is a Dedicated-DB Server, it’s better to have a FIXED amount of memory reserved.
New blog’s Life ?
February 3, 2007 on 11:58 am | In General, Blog | No CommentsHere again to post about the long long abandoned Blog “Developing Mind”.
The domain has been re-newed for the second time since I bought it, and I can start AGAIN to blog on this.
I hope to improve my english by writing on this blog … and I hope to have more visitors…too!
Enjoy
Powered by WordPress with design by Borja Fernandez.
Entries and comments feeds.
Valid XHTML and CSS. ^Top^