<?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>Marcus Nyberg &#187; SQL-server</title>
	<atom:link href="http://www.marcusnyberg.com/category/sql-server/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.marcusnyberg.com</link>
	<description>Digital and dangerous</description>
	<lastBuildDate>Fri, 03 Feb 2012 08:41:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Running and debugging a SQL Server 2000 DTS Package in Visual Basic 6.0</title>
		<link>http://www.marcusnyberg.com/2010/08/12/running-and-debugging-a-sql-server-2000-dts-package-in-visual-basic-6-0/</link>
		<comments>http://www.marcusnyberg.com/2010/08/12/running-and-debugging-a-sql-server-2000-dts-package-in-visual-basic-6-0/#comments</comments>
		<pubDate>Thu, 12 Aug 2010 12:28:55 +0000</pubDate>
		<dc:creator>marcus</dc:creator>
				<category><![CDATA[Programmering]]></category>
		<category><![CDATA[SQL-server]]></category>

		<guid isPermaLink="false">http://www.marcusnyberg.com/?p=696</guid>
		<description><![CDATA[If you have a fairly complex DTS-package (Data Transformation Services) in SQL-Server 2000 and don&#8217;t have a clue of what it does and have a limited understanding of dts read this. You can &#8221;export&#8221; the package to VB6 and by doing so you can read the code and run and debug the script from the [...]]]></description>
			<content:encoded><![CDATA[<p>If you have a fairly complex DTS-package (<a href="http://en.wikipedia.org/wiki/Data_Transformation_Services">Data Transformation Services</a>) in SQL-Server 2000 and don&#8217;t have a clue of what it does and have a limited understanding of dts read this. You can &#8221;export&#8221; the package to VB6 and by doing so you can read the code and run and debug the script from the VB6-IDE. You can even run it in <a href="http://www.sqldts.com/264.aspx">VB.NET</a>. This is quite old school but sometimes necessary to do in legacy systems if you want to edit a complex dts-script.</p>
<p><strong>Step 1 &#8211; Export the dts-package to visual basic</strong></p>
<p>Open your DTS-package in SQL-server 2000.<br />
<a href="http://www.marcusnyberg.com/wp-content/uploads/2010/08/dts-package.jpg"><img src="http://www.marcusnyberg.com/wp-content/uploads/2010/08/dts-package-253x300.jpg" alt="" title="dts-package" width="253" height="300" class="alignnone size-medium wp-image-697" /></a></p>
<p>Choose &#8221;Package -> Save as&#8221; in the menu and then change &#8221;Location&#8221; to &#8221;Visual Basic file&#8221; in the dialog. Press OK and then a bas-file (VB-module) is saved to disk.</p>
<p><a href="http://www.marcusnyberg.com/wp-content/uploads/2010/08/dts-visual-basic.jpg"><img src="http://www.marcusnyberg.com/wp-content/uploads/2010/08/dts-visual-basic-300x258.jpg" alt="" title="dts-visual-basic" width="300" height="258" class="alignnone size-medium wp-image-698" /></a></p>
<p><strong>Step 2 &#8211; Create a visual basic project</strong></p>
<p>Open Microsoft Visual Basic IDE. Choose to create a new &#8221;Standard EXE&#8221; project then click &#8221;Open&#8221;.  Remove the default Forms1 from the project. Then you add the dts bas-file to the project with &#8221;Project -> Add module&#8221;. The result should should look like below.</p>
<p><a href="http://www.marcusnyberg.com/wp-content/uploads/2010/08/dts-vb6-3.jpg"><img src="http://www.marcusnyberg.com/wp-content/uploads/2010/08/dts-vb6-3-300x216.jpg" alt="" title="dts-vb6-3" width="300" height="216" class="alignnone size-medium wp-image-706" /></a></p>
<p><strong>Step 2 &#8211; Executing and debugging the dts-package</strong></p>
<p>Go to &#8221;Project -> References&#8221; and add references to &#8221;Microsoft DTSPackage Object Library&#8221; and &#8221;Microsoft DTS Custom Task Object Library&#8221;. Now you are ready to edit your package.</p>
<p><a href="http://www.marcusnyberg.com/wp-content/uploads/2010/08/dts-vb6-references.jpg"><img src="http://www.marcusnyberg.com/wp-content/uploads/2010/08/dts-vb6-references-300x237.jpg" alt="" title="dts-vb6-references" width="300" height="237" class="alignnone size-medium wp-image-708" /></a></p>
<p>To debug the package you simply set a breakpoint and hit F5.</p>
<p><a href="http://www.marcusnyberg.com/wp-content/uploads/2010/08/dts-debugging.jpg"><img src="http://www.marcusnyberg.com/wp-content/uploads/2010/08/dts-debugging-300x173.jpg" alt="" title="dts-debugging" width="300" height="173" class="alignnone size-medium wp-image-710" /></a></p>
<p>Now feel free to fool around with the package/module and make the changes that you need. It is not easy at first but after a while you get the hang of it.</p>
<p><strong>Step 3 -Saving the dts-package to SQL-server</strong></p>
<p>When your package is ready for deployment you can deploy it through VB. Instead of executing the package you can easily save it to your SQL-server.</p>
<p>Search for the &#8221;Save or execute package&#8221; section in the module. Comment the Execute statement and uncomment the SaveToSQLServer row.</p>
<p><a href="http://www.marcusnyberg.com/wp-content/uploads/2010/08/dts-save-package.jpg"><img src="http://www.marcusnyberg.com/wp-content/uploads/2010/08/dts-save-package-300x92.jpg" alt="" title="dts-save-package" width="300" height="92" class="alignnone size-medium wp-image-712" /></a></p>
<p>Hit F5 to run the module. If everything works fine your new dts-package shows up in SQL-server.</p>
<p>More help with DTS can be found and at <a href="http://www.sqldts.com/">sqldts.com/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.marcusnyberg.com/2010/08/12/running-and-debugging-a-sql-server-2000-dts-package-in-visual-basic-6-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Query designer in management studio sql server 2005</title>
		<link>http://www.marcusnyberg.com/2008/04/17/query-designer-in-management-studio-sql-server-2005/</link>
		<comments>http://www.marcusnyberg.com/2008/04/17/query-designer-in-management-studio-sql-server-2005/#comments</comments>
		<pubDate>Thu, 17 Apr 2008 08:58:44 +0000</pubDate>
		<dc:creator>marcus</dc:creator>
				<category><![CDATA[SQL-server]]></category>

		<guid isPermaLink="false">http://www.marcusnyberg.com/2008/04/17/query-designer-in-management-studio-sql-server-2005/</guid>
		<description><![CDATA[I have been using Management Studio for SQL-server 2005 for a while now. However, I have never really liked it because of the really strange user interface. Compared to the simple Enterprise manager I first thought that Management studio was a nightmare. But I guess it takes some time to get used to&#8230; I have [...]]]></description>
			<content:encoded><![CDATA[<p>I have been using Management Studio for SQL-server 2005 for a while now. However, I have never really liked it because of the  really strange user interface. Compared to the simple Enterprise manager I first thought that Management studio was a nightmare. But I guess it takes some time to get used to&#8230;</p>
<p>I have searched for a simple and quick way to start the query designer. I only want to do a couple of querys and exit. In enterprise manager you only had to browse for a table, right click it and choose open table -> query. The same procedure in management studio takes a lot more clicks and is not worth the effort.</p>
<p>Today I found <a href="http://www.mssqltips.com/tip.asp?tip=1086">this post</a> which describes how to access the query designer in SQL-server 2005 Management studio in a quick way. I also found out that it had a lot more features than the earlier version. That&#8217;s really good. </p>
<p>How to access the query designer the fastest way:</p>
<p>1. Start Management studio and connect to server.<br />
2. Browse for the database and select it.<br />
3. Press Ctrl+N for a new query window.<br />
4. Press Ctrl+Shift+Q to get the query designer.<br />
5. Rock on.</p>
<p>This is a great feature that is added to what previously was named &#8221;Query analyzer&#8221;. The results of these queries are however not editable like they were in Enterprise managers query designer. I guess I have to through the &#8221;open table&#8221; (and get all rows) procedure for that functionality. That is really strange, why couldn&#8217;t thay have left the &#8221;open table -> query&#8221; option?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.marcusnyberg.com/2008/04/17/query-designer-in-management-studio-sql-server-2005/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Shrinking ALL Truncate Log Files</title>
		<link>http://www.marcusnyberg.com/2007/12/13/shrinking-all-truncate-log-files/</link>
		<comments>http://www.marcusnyberg.com/2007/12/13/shrinking-all-truncate-log-files/#comments</comments>
		<pubDate>Thu, 13 Dec 2007 14:48:49 +0000</pubDate>
		<dc:creator>marcus</dc:creator>
				<category><![CDATA[SQL-server]]></category>

		<guid isPermaLink="false">http://www.marcusnyberg.com/2007/12/13/shrinking-all-truncate-log-files/</guid>
		<description><![CDATA[The transaction logs on your SQL-server can fill up a lot of disk space. In my case, I monthly needed to truncate all the log files from the databases that I get from our production environment. These log files are really huge. I need to truncate them because I do not need the logs on [...]]]></description>
			<content:encoded><![CDATA[<p>The transaction logs on your SQL-server can fill up a lot of disk space. In my case, I monthly needed to truncate all the log files from the databases that I get from our production environment. These log files are really huge. I need to truncate them because I do not need the logs on my development machine. I made this little T-SQL script to make my (and your) life easier.</p>
<pre>declare @db varchar(300)
declare @logname as varchar(300)
declare @sql nvarchar(1000)

declare cDB cursor for
SELECT name from master..sysdatabases sdb
WHERE sdb.name NOT IN('master','model','pubs','msdb')
ORDER BY name

open cDB
fetch cDB into @db

while (@@fetch_status = 0)
begin

--print @db
SET @sql='SELECT @logname=name FROM '+@db+'.dbo.Sysfiles WHERE fileid=2'
--print @sql
EXEC sp_executesql @sql,N'@logname varchar(300) out,@db varchar(300)',@logname out,@db
--print @logname

SET @sql='Use '+@db+';'
SET @sql=@sql+'Backup Log '+@db+' with truncate_only;'
SET @sql=@sql+'DBCC shrinkfile ('+@logname+', 2);'
--print @sql
EXEC sp_executesql @sql,N'@logname varchar(300)',@logname

fetch cDB into @db
end
close cDB
deallocate cDB
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.marcusnyberg.com/2007/12/13/shrinking-all-truncate-log-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

