SQL Error : Column already has a DEFAULT bound to it

The Problem

Today I was testing an application that using SQL server 2008 DB. I got an error in my application says that a table is missing in the DB. I decided to generate CREATE SQL script from other DB that has the missing table and execute in this target DB.

While executing the CREATE SQL script I got these errors:

There is already an object named 'SANotify' in the database.

Msg xxx, Level xx, State x, Procedure sp_addextendedproperty, Line xx
Property cannot be added. Property ... already exists for ...

Msg xxx, Level xx, State x, Line x
 Column already has a DEFAULT bound to it.

Msg xxx, Level xx, State x, Line x
 Could not create constraint. See previous errors.

Troubleshoot and Solution

To trouble shoot this error, I decided first to list all constrains in this table, for that I found this helpful post. In my table, all constrains names starts with DF_SANotify so to get all these constrains I executed the following SQL:

SELECT name,OBJECT_NAME(parent_object_id) AS TableName, OBJECT_NAME(object_id) AS ConstraintName
FROM sys.objects
WHERE type_desc LIKE '%CONSTRAINT' and name like 'DF_SANotify_%' order by name

and I got this result:

As you can see .. I found that the constrains are really exist because the table SANotify I am trying to create is already exist but renamed to XXSANotify.

So I deleted the XX table, ran the SQL script and it is executed successful. Instead of deleting the XXSANotify I could just rename it back to SANotify.

Text Direction Button Disappeared From Gmail Message Editor

In last two days I found that the text directions buttons disappeared from gmail message editor. Today a fried told me that there is an option for that in Gmail settings.

For now me editor is like this:

Gmail Editor without Text Direction Buttons


So To add the text Direction button to the tools box of message editor simply do this:

Open Gmail options menu and select settings:

Gmail Options Menu

in the settings page, see the marked two options of text direction:

Gmail Settings - Text Directon

Select the second option to enable the Direction Buttons .. then save the settings.


Now the text direction buttons will appear and message editor will look like:

Gmail Message Editor


Thats it

Clear Saved Login

Sometime I want to access a network shared folder from normal user PC and when I call the computer using \\computer-name it ask me to type the credentials to access the destination computer shared folder, by mistake I type the administrator account Username and Password and even I select “Remember my credentials”

Then I needed to clear this connection session to log-in back with the correct user account not the administrator. So I found that I can use this command:

rundll32.exe keymgr.dll, KRShowKeyMgr

it will show you all active session to the computer then you can manage them (Add/Edit/Delete)

also you can use this command:

control keymgr.dll

it will open this page:

I tried both commands in windows 7 it works, I didn’t try on windows XP, but I guess at least first one will work.





“Licensing for this product has expired” Adobe CS4 Applications

Licensing for this product has expired

If you are getting this error message when you start your Adobe CS4 application like Dreamweaver. And you want to tray another serial but not able to because application is not starting but only showing this message “Licensing for this product has expired”

Then.. Go to C:\Program Files\Common Files\Adobe\Adobe PCD\cache
and rename or delete the file “cache.DB”

Try to start the application again .. it should start .. then you will get a chance to enter your correct serial number.

check this link for more details.


BTW .. I am talking about Windows OS .. MAC people said another solution work for them, that is to do the following:

  1. Change your DATE to a previous (those working days)
  2. Re-open Program (It will, now)
  3. On the menus-> HELP->DEACTIVATE and close program
  4. Change DATE to present
  5. Open program again, it will ask for a new KEY, enter a new key



CF Function to Clean MS Word HTML Mess

I was have a trouble with our clients using our CMS system, that is, they used to copy their text from MS Word and paste into the CMS editor directly. If you already know, that will make trouble and create a lot of unwanted HTML and XML tags  (as I see on internet people call it MS Word Mess). I Used to paste the MS Word stuff into the design area of Dreamweaver because it gives me a control and options to clean unwanted things while pasting. you can find that options by :

Click in Design area in Dreamweaver > open Edit meun and select “Paste Special…

Then select the cleaning option you want.  Still after that you may need to do some RegExp replacements.

But as you know you can’t ask your clients to use Dreamweaver to clean MS Word mess.

Clean MSWord Mess Function

I decided to create a ColdFusion Function to replace all unwanted HTML and XML Tags from MS Word pasted text. Here is the function:

<cffunction name="cleanWordMess" output="no" returntype="string">
 <cfargument name="inString" default="">
 <!--- if nothing passed , return empty string --->
 <cfif Not Len(Trim(arguments.inString))><cfreturn "" /></cfif>
 <!--- create a tmporary variable to cold the passed text --->
 <cfset local.text = arguments.inString />
 <!--- remove the HTML comments --->
 <cfset local.text = REReplace(local.text, "<!--.*-->", "", "ALL") />
 <!--- remove most of the unwanted HTML attributes with their values --->
 <cfset local.text = REReplace(local.text, "[ ]+(style|align|valign|dir|class|id|lang|width|height|nowrap)=""[^""]*""", "", "ALL") />
 <!--- clean extra spaces & tabs --->
 <cfset local.text = REReplace(local.text, "\s{2,}", " ", "ALL") />
 <!--- remove exra spaces between tags --->
 <cfset local.text = REReplace(local.text, ">\s{1,}<", "><", "ALL") />
 <!--- remove any &nbsp; spaces between tags --->
 <cfset local.text = REReplace(local.text, ">&nbsp;<", "><", "ALL") />
 <!--- remove empty <b> empty tags --->
 <cfset local.text = REReplace(local.text, "<b></b>", "", "ALL") />
 <!--- remove empty <p> empty tags --->
 <cfset local.text = REReplace(local.text, "<p></p>", "", "ALL") />
 <!--- Remove all unwanted tags opening and closing --->
 <cfset local.text = REReplace(local.text, "</?(span|div|o:p|p)>", "", "ALL") />
 <!--- remove and repetation of &nbsp; and make it one only --->
 <cfset local.text = REReplace(local.text, "(&nbsp;){2,}", "&nbsp;", "ALL") />
 <cfreturn local.text />

Of course the sequence of replacement code is very important. I think you know how to call this function .. or do I need to explain!  🙂

Feel free to use the function personally, commercially .. whatever.

Clean Truncated HTML Tags

While showing list of articles in a website usually you will see a short description with each article. As a programmer, sometimes I have to gather some number of words or characters from the article body text and show it as a short description.

When I get this number of letters from the body say by using CAST in SQL, as example:

SELECT TOP 10 ID, Title, CAST (Body AS NVARCHAR(100)) AS shortDescription FROM Articles

Assume I in one of the records I has this original value in the body field:

While comparing two entities, we tend to see both of them as competitors and <a href=http://www.somesite.com&#8221; target=“blank”>consequently comparing</a> them to find a winner.

After running the SQL I will get:

While comparing two entities, we tend to see both of them as competitors and <a href=http://www.so

As you can see the result has invalid/corrupted HTML which definitely will effect the page display if I output it as it is. Say I decided to strip out the HTML tags from the description before outputing it with this code:

<cfset text = REReplace(text, "<[^>]*>", "", "ALL")>

It will not do any thing because there is no correct tags in this string, so it will not replace any thing. For that you need to replace any unclosed tags, it could be ‘<blockquote class=”somting”‘ of even ‘<blockquo’. Hence, I use this line of code to clean any truncated HTML tags:

<cfset text = REReplace(text, "<[^>]*$", "", "ALL")>

Mostly I use the both replacement above.


Show & Hide Loading/Processing Indicator in iPhone App

To show the loading or processing indicator in your iPhone Application just add this line:

[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;

and to hide the loading indicator use the same with changing  YES to NO, like this:

[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;

You will need to use this feature normally when you are processing something in background using thread(I will try to write about thread later Inshallah) and you want user to know that something is going on in background.

thats it;