<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>nenadkostic.com</title>
	<atom:link href="http://nenadkostic.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://nenadkostic.com</link>
	<description>nenadkostic&#039;s blog</description>
	<lastBuildDate>Thu, 29 Nov 2012 01:47:07 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Backup MSSQL instances</title>
		<link>http://nenadkostic.com/2012/11/backup-mssql-instances/</link>
		<comments>http://nenadkostic.com/2012/11/backup-mssql-instances/#comments</comments>
		<pubDate>Thu, 29 Nov 2012 01:29:13 +0000</pubDate>
		<dc:creator>Nenad</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://nenadkostic.com/?p=385</guid>
		<description><![CDATA[While working actively on development of complex systems in small development team, my team often had a need for a simple instance backup, especially where there were more than one database in that instance. Even with one database this will save you a lot of time while backing up databases. I love this piece of [...]]]></description>
				<content:encoded><![CDATA[<p>While working actively on development of complex systems in small development team, my team often had a need for a simple instance backup, especially where there were more than one database in that instance. Even with one database this will save you a lot of time while backing up databases. I love this piece of code and i would like to share this with you.</p>
<p>First part is sql script.</p>
<script src="https://gist.github.com/4165829.js"></script><noscript><pre><code class="language-sql sql">-- =============================================
-- Author:		Nenad Kostic
-- Create date: 11/29/2012
-- Description:	Backup Instance
-- Big Thanks : Dragan Zdravkovic
-- =============================================

USE MASTER

DECLARE 
	@filepath nvarchar(500)
	,@servername nvarchar(100)
	,@currentdatabasename varchar(100)
	,@databasename as nvarchar (100)
	,@filenamepath as nvarchar (500)
	,@backupname nvarchar (100)

SELECT	@servername =  CAST(SERVERPROPERTY('InstanceName') as nvarchar(128))
SET	@filepath =  'D:MyDBBackups\' + @servername + '\'

DECLARE 
    DATABASENAMES CURSOR
FOR
    SELECT 
        NAME 
    FROM sysdatabases
    WHERE name not in('master', 'tempdb', 'msdb','model')

OPEN DATABASENAMES

FETCH NEXT FROM DATABASENAMES
INTO @currentdatabasename

WHILE (@@FETCH_STATUS &lt;&gt; -1)
BEGIN

	SET @databasename = CAST(Year(getdate()) as nvarchar)
						+ RIGHT('00'+ CAST(MONTH(getdate()) as nvarchar), 2) 
						+ RIGHT('00'+ CAST(DAY(getdate()) as nvarchar),2)
						
	SET @backupname = @currentdatabasename + '-Full Database Backup'
	SET @filenamepath = @filepath + @currentdatabasename   + @databasename + '.bak'
	
	BACKUP DATABASE @currentdatabasename TO  DISK = @filenamepath  WITH FORMAT,
	INIT,  NAME = @backupname, SKIP, NOREWIND, NOUNLOAD,  STATS = 10

    FETCH NEXT FROM DATABASENAMES
    INTO @currentdatabasename

END

CLOSE DATABASENAMES
DEALLOCATE DATABASENAMES
</code></pre></noscript>
<p>Set The <strong>@filepath</strong> to shoot on your desired location, and make sure that you have that folder. You need as well to have folder with your instance name in this folder.</p>
<p><em>Hence: Instance name = <strong>SQLEXPRESS</strong><br />
Make sure that you have <strong>D:MyDBBackups\SQLEXPRESS</strong> folder</em></p>
<p>Second part is bat file which will invoke desired instance backup.<br />
<script src="https://gist.github.com/4165839.js"></script><noscript><pre><code class="language-batchfile batchfile">ECHO OFF
CLS
:MENU
ECHO.
ECHO ...............................................
ECHO SELECT SERVER or 0 to EXIT.
ECHO ...............................................
ECHO.
ECHO 1 - BACKUP INSTANCE SERVERNAME\INSTANCENAME
ECHO 0 - EXIT
ECHO.
SET /P M=Type 1 or 0, then press ENTER:
IF %M%==1 GOTO INSTANCENAME
IF %M%==0 GOTO EOF
ECHO Wrong value
GOTO MENU
:INSTANCENAME
osql -E -S SERVERNAME\INSTANCENAME -i mssql_db_backup.sql
GOTO MENU
ECHO Presed 0</code></pre></noscript></p>
<p>Change <strong>SERVERNAME</strong> and <strong>INSTANCENAME</strong> to match your own.</p>
<p>Filename of the database backup will have this format: <strong>databasenameYYYYMMDD.bak</strong></p>
<p>As You guessed, regarding to title of this post, You can add more instances to this bat file, same way this one is added.</p>
<p><a href="http://nenadkostic.com/wp-content/uploads/2012/11/mssql_db_backup_result.jpg"><img class="aligncenter size-full wp-image-408" src="http://nenadkostic.com/wp-content/uploads/2012/11/mssql_db_backup_result.jpg" alt="instance database preview" width="541" height="363" /></a></p>
<p>Big thanks to  Dragan Zdravkovic for shoving me how.</p>
]]></content:encoded>
			<wfw:commentRss>http://nenadkostic.com/2012/11/backup-mssql-instances/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Copy GIT commit to another branch</title>
		<link>http://nenadkostic.com/2012/08/copy-git-commit-to-another-branch/</link>
		<comments>http://nenadkostic.com/2012/08/copy-git-commit-to-another-branch/#comments</comments>
		<pubDate>Thu, 30 Aug 2012 22:16:21 +0000</pubDate>
		<dc:creator>Nenad</dc:creator>
				<category><![CDATA[Git]]></category>

		<guid isPermaLink="false">http://nenadkostic.com/?p=359</guid>
		<description><![CDATA[Here is the thought that can be shared to all you git newbies like myself. You have branch X and branch Y. You committed something on the branch X and now you want this commit on the branch Y. This is basically like you want to copy files, from one branch to another, but you don&#8217;t [...]]]></description>
				<content:encoded><![CDATA[<p>Here is the thought that can be shared to all you git newbies like myself. You have branch X and branch Y. You committed something on the branch X and now you want this commit on the branch Y. This is basically like you want to copy files, from one branch to another, but you don&#8217;t want actually to create new commits. You just want to take existing one from branch X.</p>
<p><strong>git checkout Y<br />
git cherry-pick SHA</strong></p>
<p>You need SHA, from desired commit off course.</p>
]]></content:encoded>
			<wfw:commentRss>http://nenadkostic.com/2012/08/copy-git-commit-to-another-branch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CFEclipse Theme Night Lights</title>
		<link>http://nenadkostic.com/2012/04/cfeclipse-theme-night-lights/</link>
		<comments>http://nenadkostic.com/2012/04/cfeclipse-theme-night-lights/#comments</comments>
		<pubDate>Sat, 07 Apr 2012 20:26:54 +0000</pubDate>
		<dc:creator>Nenad</dc:creator>
				<category><![CDATA[CFEclipse]]></category>

		<guid isPermaLink="false">http://nenadkostic.com/?p=315</guid>
		<description><![CDATA[CFEclipse Syntax color theme Night Lights Installation: Download file org.cfeclipse.cfml.nightlights.prefs Remove nightlights from file name. You need to get org.cfeclipse.cfml.prefs file Just in case, backup org.cfeclipse.cfml.prefs file that is located in [workspace]/.metadata/.plugins/org.eclipse.core.runtime/.settings Overwrite this file with the one you downloaded and renamed. Restart Eclipse Here is the nice post related to this subject. Cheers!]]></description>
				<content:encoded><![CDATA[<p>CFEclipse Syntax color theme Night Lights</p>
<p><img src="http://nenadkostic.com/wp-content/uploads/2012/04/nightlights-e1333827398363.png" alt="Night Lights" width="600px" /></p>
<p>Installation:</p>
<ul>
<li>Download file <a href="http://nenadkostic.com/wp-content/downloads/nightlights.zip">org.cfeclipse.cfml.nightlights.prefs</a></li>
<li>Remove <span style="color: #3399cc;">nightlights</span> from file name. You need to get <span style="color: #3399cc;">org.cfeclipse.cfml.prefs</span> file</li>
<li>Just in case, backup org.cfeclipse.cfml.prefs file that is located in <span style="color: #3399cc;">[workspace]/.metadata/.plugins/org.eclipse.core.runtime/.settings</span></li>
<li>Overwrite this file with the one you downloaded and renamed.</li>
<li>Restart Eclipse</li>
</ul>
<p><a title="craigkaminsky.me" href="http://craigkaminsky.me/cfeclipse-themerations">Here</a> is the nice post related to this subject.<br />
Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://nenadkostic.com/2012/04/cfeclipse-theme-night-lights/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Delete all tables in MSSQL database</title>
		<link>http://nenadkostic.com/2012/04/delete-all-tables-in-mssql-database/</link>
		<comments>http://nenadkostic.com/2012/04/delete-all-tables-in-mssql-database/#comments</comments>
		<pubDate>Sat, 07 Apr 2012 12:57:46 +0000</pubDate>
		<dc:creator>Nenad</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://nenadkostic.com/?p=295</guid>
		<description><![CDATA[Very useful piece of code, that we run from time to time, especially when your target database is lower version from the one you are working on.]]></description>
				<content:encoded><![CDATA[<p>Very useful piece of code, that we run from time to time, especially when your target database is lower version from the one you are working on.</p>
<script src="https://gist.github.com/2319648.js"></script><noscript><pre><code class="language-sql sql">use database_name
declare @i int
set @i = 0
while (@i&lt;99)
begin
   declare @table_name varchar(100)
   declare table_list cursor for
      select name from sysobjects o2 where xtype='U' and
         not exists (
            select * from sysforeignkeys k
               join syscolumns c1 on (k.fkeyid = c1.id and c1.colid=k.fkey)
               join syscolumns c2 on (k.rkeyid = c2.id and c2.colid=k.rkey)
            where c2.id = o2.id and c1.id &lt;&gt; o2.id
         )
   open table_list
   fetch next from table_list into @table_name   
   while @@fetch_status = 0
   begin
      print 'dropping table '+@table_name
      exec ('drop table '+@table_name)   
      fetch next from table_list into @table_name
   end   
   close table_list
   deallocate table_list
   set @i = @i+1
end </code></pre></noscript>
]]></content:encoded>
			<wfw:commentRss>http://nenadkostic.com/2012/04/delete-all-tables-in-mssql-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Resolution Code 2012</title>
		<link>http://nenadkostic.com/2012/01/resolution-2012/</link>
		<comments>http://nenadkostic.com/2012/01/resolution-2012/#comments</comments>
		<pubDate>Mon, 02 Jan 2012 00:19:45 +0000</pubDate>
		<dc:creator>Nenad</dc:creator>
				<category><![CDATA[Thoughts]]></category>

		<guid isPermaLink="false">http://nenadkostic.com/?p=270</guid>
		<description><![CDATA[Decision we make, define us in the future. Start of the year is usually the best time for clearing thoughts and defining new goals  in the year that already started. Here are some things that I will try to accomplish in 2012: I really want to be helicopter pilot and buy one Yacht. Just kidding, [...]]]></description>
				<content:encoded><![CDATA[<p>Decision we make, define us in the future. Start of the year is usually the best time for clearing thoughts and defining new goals  in the year that already started. Here are some things that I will try to accomplish in 2012:</p>
<ul>
<li>I really want to be helicopter pilot and buy one Yacht.</li>
<li>Just kidding, I would like to find some time to dive into Ruby and Phyton.</li>
<li>No SQL is something that I found really interesting, but still didn&#8217;t get chance to try. I will try Coach DB or something similar as soon as I get chance for that.</li>
<li>Improve my coding skills and contribute to software development community.</li>
<li>Organize office activities in order to be more productive. Less work &#8211; More Job done.</li>
<li>Improve my serve.</li>
<li>Loose more weight.</li>
<li><strong> Get Married finally</strong></li>
</ul>
<p>That is not all, god forbid.<br />
Wish you all the best in 2012.</p>
<p><strong>Let the force be with you!</strong></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://nenadkostic.com/2012/01/resolution-2012/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
