viernes, 25 de junio de 2010

jueves, 24 de junio de 2010

About SQL Update and Insert: Updating data in a Table in another Database

I was confronted with a common problem when working with several staging environments, how to sync the data in the different databases.
I came up with a quite sleak solution, well at least is what I want to believe:


/****** INSERT NOT EXISTING ROWS ******/

INSERT INTO dbo.myFirstTable
SELECT KeyColumn1, KeyColumn2, KeyColumn3,Column1
FROM (

SELECT KeyColumn1, KeyColumn2, KeyColumn3,Column1

FROM mySecondDataBase.dbo.myFirstTable

WHERE (KeyColumn1 = 1)
AND (KeyColumn2 IN (1, 3, 35, 36, 29, 12, 38))
AND (KeyColumn3 = 'A')
) as myTempSubQuery

WHERE (

SELECT COUNT(*)
FROM dbo.myFirstTable
WHERE (KeyColumn1 = myTempSubQuery.KeyColumn1)
AND (KeyColumn2 = myTempSubQuery.KeyColumn2)
AND (KeyColumn3 = myTempSubQuery.KeyColumn3)

) = 0


/****** UPDATE EXISTING ROWS ******/

UPDATE dbo.myFirstTable
SET Column1 = myTempSubQuery.Column1
FROM (
SELECT KeyColumn1, KeyColumn2, KeyColumn3,Column1
FROM mySecondDataBase.dbo.myFirstTable
WHERE (KeyColumn1 = 1)
AND (KeyColumn2 IN (1, 3, 35, 36, 29, 12, 38))
AND (KeyColumn3 = 'A')
) as myTempSubQuery, dbo.myFirstTable targetTableInFirstDataBase
WHERE (targetTableInFirstDataBase.KeyColumn1 = myTempSubQuery.KeyColumn1)
AND (targetTableInFirstDataBase.KeyColumn2 = myTempSubQuery.KeyColumn2)
AND (targetTableInFirstDataBase.KeyColumn3 = myTempSubQuery.KeyColumn3)


Some inspiration coming from:

http://www.sqlrecipes.com/sql_questions_answers/insert_update_record_if_already_exists-6/

Code Markup from:

http://lukabloga.blogspot.com/2008/10/to-test-new-highlighting.html

lunes, 17 de mayo de 2010

Task Scheduler for .NET

I was looking for this a while ago, seems to be a perfect solution.
Now I'm going to test it more on this in some weeks!

http://quartznet.sourceforge.net/index.html

viernes, 24 de julio de 2009

Cambiar el Navegador por Defecto en Windows XP

Go to the following >> start >> control panel >>> add and remove
programs >>> select "set program access and defaults" have the dot on custom
and click on it which should bring a drop down menu , place a dot on
internet explorer , click ok

Como cambiar el Navegador por Defecto en Visual Studio / How to change the default Browser in VS 2005/2008

http://www.cambiaresearch.com/c4/83b1ee3e-e1b9-40ef-9505-7276007635d4/Change-the-Default-Browser-in-Visual-Studio-2005-and-Visual-Web-Developer.aspx