<?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>remidian.com &#187; T-SQL</title>
	<atom:link href="http://remidian.com/category/mssql/t-sql/feed" rel="self" type="application/rss+xml" />
	<link>http://remidian.com</link>
	<description>Braindumps of Remi Visser, freelance Oracle DBA.</description>
	<lastBuildDate>Mon, 10 May 2010 12:33:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Restore SQL Server database with TSQL</title>
		<link>http://remidian.com/mssql/restore-sql-server-database-with-tsql.html</link>
		<comments>http://remidian.com/mssql/restore-sql-server-database-with-tsql.html#comments</comments>
		<pubDate>Wed, 25 Mar 2009 11:31:56 +0000</pubDate>
		<dc:creator>remivisser</dc:creator>
				<category><![CDATA[T-SQL]]></category>
		<category><![CDATA[mssql]]></category>

		<guid isPermaLink="false">http://remidian.com/?p=98</guid>
		<description><![CDATA[Recently I had troubles restoring a database in my SQL Server 2005 instance (SP3). I used the &#8216;wizard&#8217; in the SQL Server Enterprise manager but after I got the message &#8216;restore completed successfully&#8217; the database hung in &#8216;Restoring&#8217; state, blocking connections. I decided the try to restore the database with T-SQL, with T-SQL the restore [...]]]></description>
			<content:encoded><![CDATA[<p>
Recently I had troubles restoring a database in my SQL Server 2005 instance (SP3). I used the &#8216;wizard&#8217; in the SQL Server Enterprise manager but after I got the message &#8216;restore completed successfully&#8217; the database hung in &#8216;Restoring&#8217; state, blocking connections.<span id="more-98"></span>
</p>
<p>
I decided the try to restore the database with T-SQL, with T-SQL the restore completed successfully! Another advantage of using T-SQL is that T-SQL gave more logging. This logging shows me that the BAK file (delivered from a third party) is not a SQL Server 2005 backup but presumably a SQL Server 2000 database backup &#8230;
</p>
<pre>
DECLARE
&nbsp;&nbsp;@BackupFile varchar(8000),
&nbsp;&nbsp;@sql varchar(8000)
&nbsp;&nbsp;SET @BackupFile = &#039;E:\DB2000.BAK&#039;
&nbsp;&nbsp;SET @sql = &#039;RESTORE DATABASE ADB01 FROM DISK = &#039;&#039;&#039; + @backupfile + &#039;&#039;&#039; WITH FILE = 1,&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;MOVE N&#039;&#039;DB2000_dat&#039;&#039; TO N&#039;&#039;E:\mssql\data\ADB01\ADB01_01.mdf&#039;&#039;,&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;MOVE N&#039;&#039;DB2000_log&#039;&#039; TO N&#039;&#039;F:\mssql\tlog\ADB01\ADB01_01.ldf&#039;&#039;,&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;NOUNLOAD,&nbsp;&nbsp;REPLACE,&nbsp;&nbsp;STATS = 10, RECOVERY&#039;
&nbsp;&nbsp;exec (@sql)
go
&nbsp;
10 percent processed.
20 percent processed.
30 percent processed.
40 percent processed.
50 percent processed.
60 percent processed.
70 percent processed.
80 percent processed.
90 percent processed.
100 percent processed.
Processed 2792 pages for database &#039;ADB01&#039;, file &#039;DB2000_dat&#039; on file 1.
Processed 1 pages for database &#039;ADB01&#039;, file &#039;DB2000_log&#039; on file 1.
Converting database &#039;ADB01&#039; from version 539 to the current version 611.
Database &#039;ADB01&#039; running the upgrade step from version 539 to version 551.
Database &#039;ADB01&#039; running the upgrade step from version 551 to version 552.
Database &#039;ADB01&#039; running the upgrade step from version 552 to version 553.
Database &#039;ADB01&#039; running the upgrade step from version 553 to version 554.
Database &#039;ADB01&#039; running the upgrade step from version 554 to version 589.
Database &#039;ADB01&#039; running the upgrade step from version 589 to version 590.
Database &#039;ADB01&#039; running the upgrade step from version 590 to version 593.
Database &#039;ADB01&#039; running the upgrade step from version 593 to version 597.
Database &#039;ADB01&#039; running the upgrade step from version 597 to version 604.
Database &#039;ADB01&#039; running the upgrade step from version 604 to version 605.
Database &#039;ADB01&#039; running the upgrade step from version 605 to version 606.
Database &#039;ADB01&#039; running the upgrade step from version 606 to version 607.
Database &#039;ADB01&#039; running the upgrade step from version 607 to version 608.
Database &#039;ADB01&#039; running the upgrade step from version 608 to version 609.
Database &#039;ADB01&#039; running the upgrade step from version 609 to version 610.
Database &#039;ADB01&#039; running the upgrade step from version 610 to version 611.
RESTORE DATABASE successfully processed 2793 pages in 1.513 seconds (15.118 MB/sec).
&nbsp;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://remidian.com/mssql/restore-sql-server-database-with-tsql.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Control Structures</title>
		<link>http://remidian.com/mssql/t-sql/control-structures.html</link>
		<comments>http://remidian.com/mssql/t-sql/control-structures.html#comments</comments>
		<pubDate>Wed, 15 Nov 2006 20:35:20 +0000</pubDate>
		<dc:creator>remivisser</dc:creator>
				<category><![CDATA[T-SQL]]></category>

		<guid isPermaLink="false">http://remidian.com/uncategorized/control-structures.html</guid>
		<description><![CDATA[Control structures syntax; IF THEN ELSE, CASE, WHILE . IF THEN ELSE The IF THEN ELSE syntax in TSQL is kinda weird if you ask me &#8230; I forget them &#8216;all the time&#8217;, created examples below for my reference. IF THEN if 1 = 1 begin &#160;&#160;print &#039;true&#039; end &#160; go &#160; IF THEN &#8211; [...]]]></description>
			<content:encoded><![CDATA[<p>Control structures syntax; <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_tsqlcon_6lyk.asp">IF THEN ELSE</a>, <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_tsqlcon_6lyk.asp">CASE</a>, <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_wa-wz_6oyt.asp">WHILE</a> .<span id="more-35"></span>
</p>
<h3>IF THEN ELSE</h3>
<p>
The IF THEN ELSE syntax in TSQL is kinda weird if you ask me &#8230; I forget them &#8216;all the time&#8217;, created examples below for my reference.
</p>
<h6>IF THEN</h6>
<pre>
if 1 = 1
begin 
&nbsp;&nbsp;print &#039;true&#039;
end
&nbsp;
go
&nbsp;
</pre>
<h6>IF THEN &#8211; short notation</h6>
<pre>
if 1 = 1
&nbsp;&nbsp;print &#039;true&#039;
&nbsp;
go
&nbsp;
</pre>
<h6>IF THEN ELSE</h6>
<pre>
if 1 = 1
begin
&nbsp;&nbsp;print &#039;true&#039;
end
&nbsp;
else&nbsp;&nbsp;

begin
&nbsp;&nbsp;print &#039;false&#039;
end
&nbsp;
go
&nbsp;
</pre>
<h6>IF THEN ELSE &#8211; short notation</h6>
<pre>
if 1 = 1
&nbsp;&nbsp;print &#039;true&#039;
else&nbsp;&nbsp;
&nbsp;&nbsp;print &#039;false&#039;

go
&nbsp;
</pre>
<h6>Multiple IF THEN ELSE blocks</h6>
<pre>
if 1 = 1
begin
&nbsp;&nbsp;print &#039;1 = 1&#039;
end
else&nbsp;&nbsp;
if 1 = 2
&nbsp;&nbsp;begin
&nbsp;&nbsp;&nbsp;&nbsp;print &#039;1 = 2&#039;
&nbsp;&nbsp;end
else
if 1 = 3
begin
&nbsp;&nbsp;print &#039;1 = 3&#039;
end
&nbsp;
go
&nbsp;
</pre>
<h3>CASE</h3>
<p>TSQL has the CASE control structure &#8230;</p>
<pre>
declare @i int, @r int
&nbsp;
set @i = 1
&nbsp;
set @r = 
&nbsp;&nbsp;case @i
&nbsp;&nbsp;&nbsp;&nbsp;when 1 then 1
&nbsp;&nbsp;&nbsp;&nbsp;when 2 then 2
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else 0
&nbsp;&nbsp;end
&nbsp;
print @r
&nbsp;
go
&nbsp;
</pre>
<h3>WHILE</h3>
<h6>Eternal loop</h6>
<pre>
while 1 = 1 
&nbsp;&nbsp;print &#039;true&#039;
&nbsp;
go
&nbsp;
</pre>
<h6>Simple WHILE loop</h6>
<pre>
declare @i int
set @i = 0
&nbsp;
while @i &lt; 10
begin
&nbsp;&nbsp;print @i
&nbsp;&nbsp;set @i = @i + 1
end
&nbsp;
go
&nbsp;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://remidian.com/mssql/t-sql/control-structures.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>cursors in tsql</title>
		<link>http://remidian.com/mssql/t-sql/cursors-in-tsql.html</link>
		<comments>http://remidian.com/mssql/t-sql/cursors-in-tsql.html#comments</comments>
		<pubDate>Fri, 03 Nov 2006 16:22:17 +0000</pubDate>
		<dc:creator>remivisser</dc:creator>
				<category><![CDATA[T-SQL]]></category>

		<guid isPermaLink="false">http://remidian.com/mssql/t-sql/cursors-in-tsql.html</guid>
		<description><![CDATA[Cursors in tsql, it can be done &#8230; Simple cursor loop Example below is the most straight forward example of walking through a CURSOR with a WHILE loop in tsql. The cursor is declared, opened and and a FETCH NEXT is done while @@fetch_status equals 0. The behaviour of a FETCH [ NEXT ] call [...]]]></description>
			<content:encoded><![CDATA[<p>
Cursors in tsql, it can be done &#8230; <span id="more-32"></span>
</p>
<h3>Simple cursor loop</h3>
<p>
Example below is the most straight forward example of walking through a <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_cr-cz_7hgy.asp">CURSOR</a> with a <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_wa-wz_6oyt.asp">WHILE</a> loop in tsql. The cursor is declared, opened and and a <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_fa-fz_90rs.asp">FETCH</a> NEXT is done while <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_globals_1c1f.asp">@@fetch_status</a> equals 0.
</p>
<p>
The behaviour of a FETCH [ NEXT ] call is that it returns the value(s) for the column(s) specified in the DECLARE CURSOR as a single-row result set.
</p>
<h6>Basic cursor example with FETCH returning row as single-row result set</h6>
<pre>
1&gt; declare c1 cursor
2&gt; for
3&gt; select left( name, 32)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;as name,
4&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cast( dbid as varchar(10)) as dbid
5&gt;&nbsp;&nbsp; from master.dbo.sysdatabases
6&gt;&nbsp;&nbsp;where dbid &lt; 5
7&gt;
8&gt; open c1
9&gt; fetch next from c1
10&gt;
11&gt; &#45;- while @@fetch_status != -1 and @@fetch_status != -2
12&gt; while @@fetch_status = 0
13&gt;&nbsp;&nbsp;&nbsp;&nbsp;fetch next from c1
14&gt;
15&gt; close c1
16&gt; deallocate c1
17&gt;
18&gt; go
 name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dbid
 &#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;-- &#45;&#45;-&#45;&#45;-&#45;&#45;&#45;-
 master&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1
&nbsp;
 name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dbid
 &#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;-- &#45;&#45;-&#45;&#45;-&#45;&#45;&#45;-
 tempdb&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2
&nbsp;
 name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dbid
 &#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;-- &#45;&#45;-&#45;&#45;-&#45;&#45;&#45;-
 model&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3
&nbsp;
 name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dbid
 &#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;-- &#45;&#45;-&#45;&#45;-&#45;&#45;&#45;-
 msdb&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4
&nbsp;
 name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dbid
 &#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;-- &#45;&#45;-&#45;&#45;-&#45;&#45;&#45;-
&nbsp;
1&gt;</pre>
<h3>@@fetch_status</h3>
<p>
@@fetch_status is a built in variable returning the exit code of the latest fetch call.
</p>
<table border="1">
<tr>
<th>Return Value</th>
<th>Description</th>
</tr>
<tr>
<td>0</td>
<td> FETCH statement was successful.                              </td>
</tr>
<tr>
<td>-1</td>
<td> FETCH statement failed or the row was beyond the result set.</td>
</tr>
<tr>
<td>-2</td>
<td> Row fetched is missing.</td>
</tr>
</table>
<h3>FETCH INTO</h3>
<p>
The &#8216;FETCH INTO&#8217; option is used to return values from a cursor (instead of getting it returned as a single-row result set) into pre-defined variables.
</p>
<h6 style="margin:0 1px 2px 0;padding:0;border-bottom:1px solid #bbb">Example below displays how to perform a FETCH INTO with a single column.</h6>
<pre>
1&gt; declare @s_name&nbsp;&nbsp;&nbsp;&nbsp;varchar(32)
2&gt; declare c1 cursor
3&gt; for
4&gt; select name
5&gt;&nbsp;&nbsp; from master.dbo.sysdatabases
6&gt;&nbsp;&nbsp;where dbid &lt; 5
7&gt;
8&gt; open c1
9&gt; fetch next from c1 into @s_name
10&gt;
11&gt; while @@fetch_status = 0
12&gt; begin
13&gt;&nbsp;&nbsp; print &#039;name = &#039; + @s_name
14&gt;&nbsp;&nbsp; fetch next from c1 into @s_name
15&gt; end
16&gt;
17&gt; close c1
18&gt; deallocate c1
19&gt;
20&gt; go
name = master
name = tempdb
name = model
name = msdb
1&gt;</pre>
<h6>Example below displays how to perform a FETCH INTO with multiple columns.</h6>
<pre>
1&gt; declare @s_name&nbsp;&nbsp;&nbsp;&nbsp;varchar(32),
2&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @i_dbid&nbsp;&nbsp;&nbsp;&nbsp;smallint
3&gt; declare c1 cursor
4&gt; for
5&gt; select name,
6&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dbid
7&gt;&nbsp;&nbsp; from master.dbo.sysdatabases
8&gt;&nbsp;&nbsp;where dbid &lt; 5
9&gt;
10&gt; open c1
11&gt; fetch next from c1 into @s_name, @i_dbid
12&gt;
13&gt; while @@fetch_status = 0
14&gt; begin
15&gt;&nbsp;&nbsp; print &#039;DB = &#039; + cast( @i_dbid as varchar(8)) + &#039;:&#039; + @s_name
16&gt;&nbsp;&nbsp; fetch next from c1 into @s_name, @i_dbid
17&gt; end
18&gt;
19&gt; close c1
20&gt; deallocate c1
21&gt;
22&gt; go
DB = 1:master
DB = 2:tempdb
DB = 3:model
DB = 4:msdb
1&gt;</pre>
<h3>Scrollable cursors</h3>
<p>
All examples above are so-called &#8216;forward only cursors&#8217; (the default cursor type). When you want to be able to scroll through your cursor the cursor most be declared through the SCROLL CURSOR declaration.
</p>
<p>Whenever a cursor is declared as a SCROLL CURSOR the following FETCH options become available:
</p>
<h6>Fetch Options</h6>
<ul>
<li>PRIOR                  </li>
<li>FIRST                  </li>
<li>LAST                   </li>
<li>ABSOLUTE { n | @nvar } </li>
<li>RELATIVE { n | @nvar } </li>
</ul>
<p>
All examples below are done with &#8216;demo&#8217; table listed below.
</p>
<h6>demo table</h6>
<pre>
1&gt; select * from demo order by k
2&gt; go
 k
 &#45;&#45;-&#45;&#45;-&#45;&#45;&#45;--
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 6
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 7
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 9
&nbsp;
(10 rows affected)
1&gt;
</pre>
<h6>FETCH NEXT and FETCH PRIOR</h6>
<pre>
1&gt; declare @i as int
2&gt; declare c1 scroll cursor
3&gt; for
4&gt; select k
5&gt;&nbsp;&nbsp; from demo
6&gt; order by k
7&gt;
8&gt;
9&gt;
10&gt; open c1
11&gt;
12&gt;
13&gt; print &#039;FETCH NEXT &#039; + char(10)
14&gt; print &#039;==================================&#039;
15&gt;
16&gt; fetch next from c1 into @i
17&gt; while @@fetch_status = 0
18&gt; begin
19&gt;&nbsp;&nbsp; print cast(@i as char(1)) + &#039; @@fetch_status &#039; + cast(@@fetch_status as char)
20&gt;&nbsp;&nbsp; fetch next from c1 into @i
21&gt; end
22&gt;
23&gt; fetch next from c1 into @i
24&gt; print cast(@i as char(1)) + &#039; @@fetch_status &#039; + cast(@@fetch_status as char)
25&gt;
26&gt;
27&gt; print char(10) + &#039;FETCH PRIOR &#039; + char(10)
28&gt; print &#039;==================================&#039;
29&gt;
30&gt; fetch prior from c1 into @i
31&gt; while @@fetch_status = 0
32&gt; begin
33&gt;&nbsp;&nbsp; print cast(@i as char(1)) + &#039; @@fetch_status &#039; + cast(@@fetch_status as char)
34&gt;&nbsp;&nbsp; fetch prior from c1 into @i
35&gt; end
36&gt;
37&gt; fetch prior from c1 into @i
38&gt; print cast(@i as char(1)) + &#039; @@fetch_status &#039; + cast(@@fetch_status as char)
39&gt;
40&gt;
41&gt; close c1
42&gt; deallocate c1
43&gt;
44&gt;
45&gt;
46&gt; go
FETCH NEXT
==================================
0 @@fetch_status 0
1 @@fetch_status 0
2 @@fetch_status 0
3 @@fetch_status 0
4 @@fetch_status 0
5 @@fetch_status 0
6 @@fetch_status 0
7 @@fetch_status 0
8 @@fetch_status 0
9 @@fetch_status 0
9 @@fetch_status -1
&nbsp;
FETCH PRIOR
==================================
9 @@fetch_status 0
8 @@fetch_status 0
7 @@fetch_status 0
6 @@fetch_status 0
5 @@fetch_status 0
4 @@fetch_status 0
3 @@fetch_status 0
2 @@fetch_status 0
1 @@fetch_status 0
0 @@fetch_status 0
0 @@fetch_status -1
1&gt;
</pre>
<h6>FETCH LAST / FETCH PRIOR</h6>
<pre>
1&gt; declare @i as int
2&gt; declare c1 scroll cursor
3&gt; for
4&gt; select k
5&gt;&nbsp;&nbsp; from demo
6&gt; order by k
7&gt;
8&gt;
9&gt;
10&gt; open c1
11&gt;
12&gt;
13&gt; print char(10) + &#039;FIRST LAST PRIOR &#039; + char(10)
14&gt; print &#039;==================================&#039;
15&gt; fetch last from c1 into @i
16&gt; print &#039;FETCH LAST&nbsp;&nbsp;= &#039; + cast(@i as char(1)) +
17&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#039; @@fetch_status = &#039; + cast(@@fetch_status as char)
18&gt; fetch prior from c1 into @i
19&gt; print &#039;FETCH PRIOR = &#039; + cast(@i as char(1)) +
20&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#039; @@fetch_status = &#039; + cast(@@fetch_status as char)
21&gt; fetch first from c1 into @i
22&gt; print &#039;FETCH FIRST = &#039; + cast(@i as char(1)) +
23&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#039; @@fetch_status = &#039; + cast(@@fetch_status as char)
24&gt; fetch prior from c1 into @i
25&gt; print &#039;FETCH PRIOR = &#039; + cast(@i as char(1)) +
26&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#039; @@fetch_status = &#039; + cast(@@fetch_status as char)
27&gt; fetch next from c1 into @i
28&gt; print &#039;FETCH NEXT&nbsp;&nbsp;= &#039; + cast(@i as char(1)) +
29&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#039; @@fetch_status = &#039; + cast(@@fetch_status as char)
30&gt; fetch next from c1 into @i
31&gt; print &#039;FETCH NEXT&nbsp;&nbsp;= &#039; + cast(@i as char(1)) +
32&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#039; @@fetch_status = &#039; + cast(@@fetch_status as char)
33&gt;
34&gt;
35&gt; close c1
36&gt; deallocate c1
37&gt;
38&gt;
39&gt;
40&gt; go
&nbsp;
FIRST LAST PRIOR
==================================
FETCH LAST&nbsp;&nbsp;= 9 @@fetch_status = 0
FETCH PRIOR = 8 @@fetch_status = 0
FETCH FIRST = 0 @@fetch_status = 0
FETCH PRIOR = 0 @@fetch_status = -1
FETCH NEXT&nbsp;&nbsp;= 0 @@fetch_status = 0
FETCH NEXT&nbsp;&nbsp;= 1 @@fetch_status = 0
1&gt;
</pre>
<h6>FETCH ABSOLUTE</h6>
<pre>
1&gt; declare @i as int
2&gt; declare c1 scroll cursor
3&gt; for
4&gt; select k
5&gt;&nbsp;&nbsp; from demo
6&gt; order by k
7&gt;
8&gt; open c1
9&gt;
10&gt; print char(10) + &#039;FETCH ABSOLUTE &#039; + char(10)
11&gt; print &#039;======================================&#039;
12&gt; fetch absolute 2 from c1 into @i
13&gt; print &#039;FETCH ABSOLUTE 2 = &#039; + cast(@i as char(1)) +
14&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#039; @@fetch_status = &#039; + cast(@@fetch_status as char)
15&gt; fetch absolute 8 from c1 into @i
16&gt; print &#039;FETCH ABSOLUTE 8 = &#039; + cast(@i as char(1)) +
17&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#039; @@fetch_status = &#039; + cast(@@fetch_status as char)
18&gt;
19&gt; close c1
20&gt; deallocate c1
21&gt;
22&gt; go
&nbsp;
FETCH ABSOLUTE
======================================
FETCH ABSOLUTE 2 = 1 @@fetch_status = 0
FETCH ABSOLUTE 8 = 7 @@fetch_status = 0
1&gt;</pre>
<h6>FETCH RELATIVE</h6>
<pre>
1&gt; declare @i as int
2&gt; declare c1 scroll cursor
3&gt; for
4&gt; select k
5&gt;&nbsp;&nbsp; from demo
6&gt; order by k
7&gt;
8&gt;
9&gt;
10&gt; open c1
11&gt;
12&gt;
13&gt; print char(10) + &#039;FETCH RELATIVE&#039; + char(10)
14&gt; print &#039;=======================================&#039;
15&gt; fetch relative 1 from c1 into @i
16&gt; print &#039;FETCH RELATIVE 1&nbsp;&nbsp; = &#039; + cast( @i as varchar(1)) +
17&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#039; @@fetch_status = &#039; + cast(@@fetch_status as char)
18&gt;
19&gt; fetch relative -1 from c1 into @i
20&gt; print &#039;FETCH RELATIVE -1&nbsp;&nbsp;= &#039; + cast( @i as varchar(1)) +
21&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#039; @@fetch_status = &#039; + cast(@@fetch_status as char)
22&gt;
23&gt; fetch relative -2 from c1 into @i
24&gt; print &#039;FETCH RELATIVE -2&nbsp;&nbsp;= &#039; + cast( @i as varchar(1)) +
25&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#039; @@fetch_status = &#039; + cast(@@fetch_status as char)
26&gt;
27&gt; fetch relative 3 from c1 into @i
28&gt; print &#039;FETCH RELATIVE 3&nbsp;&nbsp; = &#039; + cast( @i as varchar(1)) +
29&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#039; @@fetch_status = &#039; + cast(@@fetch_status as char)
30&gt;
31&gt; fetch relative 100 from c1 into @i
32&gt; print &#039;FETCH RELATIVE 100 = &#039; + cast( @i as varchar(1)) +
33&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#039; @@fetch_status = &#039; + cast(@@fetch_status as char)
34&gt;
35&gt; fetch relative -1 from c1 into @i
36&gt; print &#039;FETCH RELATIVE -1&nbsp;&nbsp;= &#039; + cast( @i as varchar(1)) +
37&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#039; @@fetch_status = &#039; + cast(@@fetch_status as char)
38&gt;
39&gt;
40&gt; close c1
41&gt; deallocate c1
42&gt;
43&gt;
44&gt;
45&gt; go
&nbsp;
FETCH RELATIVE
=======================================
FETCH RELATIVE 1&nbsp;&nbsp; = 0 @@fetch_status = 0
FETCH RELATIVE -1&nbsp;&nbsp;= 0 @@fetch_status = -1
FETCH RELATIVE -2&nbsp;&nbsp;= 0 @@fetch_status = -1
FETCH RELATIVE 3&nbsp;&nbsp; = 2 @@fetch_status = 0
FETCH RELATIVE 100 = 2 @@fetch_status = -1
FETCH RELATIVE -1&nbsp;&nbsp;= 9 @@fetch_status = 0
1&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://remidian.com/mssql/t-sql/cursors-in-tsql.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>return variables from dynamic sql &#8211; sp_executesql</title>
		<link>http://remidian.com/mssql/t-sql/return-variables-from-dynamic-sql-sp_executesql.html</link>
		<comments>http://remidian.com/mssql/t-sql/return-variables-from-dynamic-sql-sp_executesql.html#comments</comments>
		<pubDate>Wed, 01 Nov 2006 20:31:11 +0000</pubDate>
		<dc:creator>remivisser</dc:creator>
				<category><![CDATA[T-SQL]]></category>

		<guid isPermaLink="false">http://remidian.com/mssql/return-values-from-dynamic-sql.html</guid>
		<description><![CDATA[Returing values into tsql variables from a dynamic sql statement using sp_executesql stored procedure. Scenario The example below displays the number of objects per database. The following steps are involved. open a cursor for the select * from master.dbo.sysdatabases statement (cursor is a while loop), inside the cursor a dynamic sql statement is defined , [...]]]></description>
			<content:encoded><![CDATA[<p>
        Returing values into tsql variables from a dynamic sql statement using <a href="http://msdn2.microsoft.com/en-us/library/ms188001.aspx">sp_executesql</a> stored procedure. <span id="more-30"></span>
</p>
<h3>Scenario</h3>
<p>
The example below displays the number of objects per database. The following steps are involved.
</p>
<ul>
<li>open a cursor for the <code>select * from master.dbo.sysdatabases</code> statement (cursor is a while loop), </li>
<li>inside the cursor a dynamic sql statement is defined ,</li>
<li>at last the stored procedure sp_executesql is used to retrieve the output of this defined sql statement into tsql variables .</li>
</ul>
<h6>sp_execute example to return values into variables </h6>
<pre>
1&gt; declare @s_dtb&nbsp;&nbsp;sysname
2&gt; declare @s_sql&nbsp;&nbsp;nvarchar(2000)
3&gt; declare @i_obj&nbsp;&nbsp;int
4&gt; declare c1&nbsp;&nbsp;&nbsp;&nbsp; cursor
5&gt; for
6&gt; select name
7&gt;&nbsp;&nbsp; from master.dbo.sysdatabases
8&gt;
9&gt;
10&gt; open c1
11&gt; fetch c1 into @s_dtb
12&gt;
13&gt; while @@fetch_status &gt;= 0
14&gt; begin
15&gt;
16&gt;&nbsp;&nbsp; &#45;- construct sql statement
17&gt;&nbsp;&nbsp; set @s_sql = &#039;select @count = count(*)
18&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from &#039; + QuoteName(@s_dtb) + &#039;.dbo.sysobjects&#039;
19&gt;
20&gt;&nbsp;&nbsp; &#45;- execute dynamic sql and map output variable @count to variable @i_obj
21&gt;&nbsp;&nbsp; exec sp_executesql
22&gt;&nbsp;&nbsp;&nbsp;&nbsp; @s_sql,
23&gt;&nbsp;&nbsp;&nbsp;&nbsp; N&#039;@count int output&#039;,
24&gt;&nbsp;&nbsp;&nbsp;&nbsp; @count = @i_obj output
25&gt;
26&gt;&nbsp;&nbsp; print @s_dtb + &#039; db has &#039; + cast( @i_obj as varchar) + &#039; objects&#039;
27&gt;
28&gt;&nbsp;&nbsp; fetch c1 into @s_dtb
29&gt;
30&gt; end
31&gt;
32&gt; close c1
33&gt; deallocate c1
34&gt;
35&gt;
36&gt; go
master db has 1324 objects
model db has 54 objects
msdb db has 454 objects
Northwind db has 146 objects
tempdb db has 54 objects
1&gt;
</pre>
<p>
        Extremely handy I would say. &#8211; Whenever you want to perform an operation (execute tsql) on all your databases.</p>
]]></content:encoded>
			<wfw:commentRss>http://remidian.com/mssql/t-sql/return-variables-from-dynamic-sql-sp_executesql.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>environment</title>
		<link>http://remidian.com/mssql/t-sql/environment.html</link>
		<comments>http://remidian.com/mssql/t-sql/environment.html#comments</comments>
		<pubDate>Mon, 18 Sep 2006 19:22:48 +0000</pubDate>
		<dc:creator>remivisser</dc:creator>
				<category><![CDATA[T-SQL]]></category>

		<guid isPermaLink="false">http://remidian.com/uncategorized/mssql-environment.html</guid>
		<description><![CDATA[Getting around in the mssql environment Whoami In MSSQL (2000) there&#8217;s not an easy way to see in which database you are. Script below creates a view &#8216;whoami&#8217; that gives you the information; create view dbo.whoami as select @@spid as &#039;@@spid&#039;, &#160;&#160;&#160;&#160;&#160;&#160; cast( user as varchar(12)) as &#039;user&#039;, &#160;&#160;&#160;&#160;&#160;&#160; cast( p.dbid as varchar(6)) + &#039;:&#039; [...]]]></description>
			<content:encoded><![CDATA[<p>Getting around in the mssql environment<span id="more-25"></span></p>
<h3>Whoami</h3>
<p>
In MSSQL (2000) there&#8217;s not an easy way to see in which database you are. Script below creates a view &#8216;whoami&#8217; that gives you the information;
</p>
<pre>
create view dbo.whoami
as
select @@spid as &#039;@@spid&#039;,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cast( user as varchar(12)) as &#039;user&#039;,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cast( p.dbid as varchar(6)) + &#039;:&#039; + cast( d.name as varchar(14)) as &#039;database&#039;,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cast( p.loginame as varchar(16)) loginame,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cast( p.hostname as varchar(16)) as &#039;hostname&#039;,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cast( p.nt_username as varchar(16)) nt_username
&nbsp;&nbsp; from master.dbo.sysprocesses p left join master.dbo.sysdatabases d
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;on d.dbid = p.dbid
&nbsp;&nbsp; where spid = @@spid
&nbsp;
go
&nbsp;
grant select on dbo.whoami to public
go
&nbsp;
</pre>
<pre>
1&gt; select * from whoami
2&gt; go
 @@spid user&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; database&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;loginame&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hostname&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; nt_username
 &#45;&#45;-&#45;&#45;- &#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;- &#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;- &#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;- &#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;- &#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;-
&nbsp;&nbsp;&nbsp;&nbsp; 51 dbo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1:master&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NYC01\\remivisser NYC01&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;remivisser
&nbsp;
(1 row affected)
1&gt;
&nbsp;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://remidian.com/mssql/t-sql/environment.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Date Time functions</title>
		<link>http://remidian.com/mssql/date-time-functions.html</link>
		<comments>http://remidian.com/mssql/date-time-functions.html#comments</comments>
		<pubDate>Sun, 17 Sep 2006 18:20:19 +0000</pubDate>
		<dc:creator>remivisser</dc:creator>
				<category><![CDATA[T-SQL]]></category>
		<category><![CDATA[mssql]]></category>

		<guid isPermaLink="false">http://remidian.com/mssql/date-functions-in-t-sql.html</guid>
		<description><![CDATA[Date time functions (frustrations) in T-SQL. Current date Functions getdate and getutcdate display the current date. Both functions accept zero arguments. 1&#62; print getdate() 2&#62; print getutcdate() 3&#62; go Sep 18 2006&#160;&#160;8:25PM Sep 18 2006&#160;&#160;6:25PM Formatting To format the display of your date you need to convert it to a varchar (like the to_char function [...]]]></description>
			<content:encoded><![CDATA[<p>Date time functions (frustrations) in T-SQL.<span id="more-24"></span></p>
<h3>Current date</h3>
<p>Functions <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_ga-gz_4z51.asp"><code>getdate</code></a> and <a href="http://msdn.microsoft.com/library/en-us/tsqlref/ts_ga-gz_4kkp.asp">getutcdate</a> display the current date. Both functions accept zero arguments.</p>
<pre>
1&gt; print getdate()
2&gt; print getutcdate()
3&gt; go
Sep 18 2006&nbsp;&nbsp;8:25PM
Sep 18 2006&nbsp;&nbsp;6:25PM</pre>
<h3>Formatting</h3>
<p>To format the display of your date you need to <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_ca-co_2f3o.asp"><code>convert</code></a> it to a varchar (like the <code>to_char</code> function in oracle).</p>
<p>So to display 18 september as 25-09-2006 I must convert it the Italian?? way, as shown below.</p>
<pre>
1&gt; print convert( varchar(32), getdate(), 105)
2&gt; go
18-09-2006
1&gt; print convert( varchar(32), getdate(), 5)
2&gt; go
18-09-06</pre>
<h3>Advanced(?) formatting</h3>
<p>
My requirement is simple: get the date displayed as &#8216;yyyymmdd_hhmiss&#8217;. And yes I want leading zeros for the first nine monts/minutes. So &#8217;09&#8242; for &#8216;September&#8217; and not &#8217;9&#8242;. How hard can that be &#8230; Well, I am missing something bigtime OR this basic functionality is simply missing from sqlserver T-SQL (version 2000).
</p>
<p>
I wrote the T-SQL code below to get me the datetime in the format &#8216;yyyymmdd_hhmiss&#8217;;
</p>
<pre>
1&gt; set nocount on
2&gt;
3&gt; declare @yy varchar(4)
4&gt; ,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @mm varchar(2)
5&gt; ,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @dd varchar(2)
6&gt; ,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @hh varchar(2)
7&gt; ,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @mi varchar(2)
8&gt; ,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @ss varchar(2)
9&gt; ,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @ts varchar(15)
10&gt;
11&gt; set @yy = datepart( yy, getdate())
12&gt; set @mm = datepart( mm, getdate())
13&gt; set @dd = datepart( dd, getdate())
14&gt; set @hh = datepart( hh, getdate())
15&gt; set @mi = datepart( mi, getdate())
16&gt; set @ss = datepart( ss, getdate())
17&gt;
18&gt;
19&gt; if ( cast( @mm as int) &lt; 10) set @mm = &#039;0&#039; + @mm
20&gt; if ( cast( @dd as int) &lt; 10) set @dd = &#039;0&#039; + @dd
21&gt; if ( cast( @hh as int) &lt; 10) set @hh = &#039;0&#039; + @hh
22&gt; if ( cast( @mi as int) &lt; 10) set @mi = &#039;0&#039; + @mi
23&gt; if ( cast( @ss as int) &lt; 10) set @ss = &#039;0&#039; + @ss
24&gt;
25&gt;
26&gt; set @ts = @yy + @mm + @dd + &#039;_&#039; + @hh + @mi + @ss
27&gt; print @ts
28&gt;
29&gt; go
20060918_183339
</pre>
<p>
I can not believe this is not standard functionality &#8230; Please correct me if I am wrong (As I&#8217;m an Oracle DBA very new to MSSQL &#8230;)</p>
]]></content:encoded>
			<wfw:commentRss>http://remidian.com/mssql/date-time-functions.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
