<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6786711781036653113</id><updated>2024-10-24T12:52:48.280+01:00</updated><category term="SQL"/><category term="C#"/><category term="Performance"/><category term="Html"/><category term="SSIS"/><category term="Social"/><category term="VOIP"/><title type='text'>Nazer Mohamed</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://nazermohamed.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://nazermohamed.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06113952100169459610</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>36</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6786711781036653113.post-5493738958648193516</id><published>2016-01-01T22:34:00.004+00:00</published><updated>2016-01-01T22:34:31.063+00:00</updated><title type='text'>ssh failed logins</title><content type='html'>To get the list the of failed ssh logins&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;grep sshd.\*Failed /var/log/auth.log&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To extract only the ip address and get a unique list of ips&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;grep sshd.\*Failed /var/log/auth.log | grep -o &#39;[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}&#39; | sort | uniq&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
To block the ip&#39;s that have failed the ssh logins using iptables&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;grep sshd.\*Failed /var/log/auth.log | grep -o &#39;[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}&#39; | sort | uniq | while read ip ; do sudo iptables -A INPUT -s $ip -j DROP; done&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
running this command twice will create duplicates. Working on it to create it as a cron job,&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://nazermohamed.blogspot.com/feeds/5493738958648193516/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://nazermohamed.blogspot.com/2016/01/ssh-failed-logins.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/5493738958648193516'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/5493738958648193516'/><link rel='alternate' type='text/html' href='http://nazermohamed.blogspot.com/2016/01/ssh-failed-logins.html' title='ssh failed logins'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06113952100169459610</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6786711781036653113.post-8855990960663976646</id><published>2015-12-17T12:19:00.002+00:00</published><updated>2015-12-17T12:19:39.963+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Performance"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><title type='text'>Pending IO</title><content type='html'>&lt;pre style=&quot;background-color: white; border: 0px; color: #333333; font-family: inherit; font-size: 14px; line-height: 18px; outline: 0px; padding: 0px; white-space: pre-wrap;&quot;&gt;&lt;code class=&quot;visual basic&quot; style=&quot;border: 0px; font-family: inherit; font-style: inherit; font-weight: inherit; margin: 0px; outline: 0px; padding: 0px;&quot;&gt;-- Look at pending I/O requests by file
SELECT DB_NAME(mf.database_id) AS [Database] , mf.physical_name ,r.io_pending , r.io_pending_ms_ticks , r.io_type , fs.num_of_reads , fs.num_of_writesFROM sys.dm_io_pending_io_requests AS r INNER JOIN sys.dm_io_virtual_file_stats(NULL, NULL) AS fs ON r.io_handle = fs.file_handle INNER JOIN sys.master_files AS mf ON fs.database_id = mf.database_id
AND fs.file_id = mf.file_idORDER BY r.io_pending , r.io_pending_ms_ticks DESC ;&lt;/code&gt;&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://nazermohamed.blogspot.com/feeds/8855990960663976646/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://nazermohamed.blogspot.com/2015/12/pending-io.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/8855990960663976646'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/8855990960663976646'/><link rel='alternate' type='text/html' href='http://nazermohamed.blogspot.com/2015/12/pending-io.html' title='Pending IO'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06113952100169459610</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6786711781036653113.post-584497033759489932</id><published>2015-12-17T12:18:00.000+00:00</published><updated>2015-12-17T12:19:08.332+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Performance"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><title type='text'>IO stalls</title><content type='html'>&lt;br /&gt;
-- Good &amp;lt; 5 msec&lt;br /&gt;
-- ideal value &amp;lt; 20 msec&lt;br /&gt;
&lt;br /&gt;
SELECT files.physical_name, files.name,&lt;br /&gt;
stats.num_of_writes, (1.0 * stats.io_stall_write_ms / stats.num_of_writes) AS avg_write_stall_ms,&lt;br /&gt;
stats.num_of_reads, (1.0 * stats.io_stall_read_ms / stats.num_of_reads) AS avg_read_stall_ms&lt;br /&gt;
FROM sys.dm_io_virtual_file_stats(null, NULL) as stats&lt;br /&gt;
INNER JOIN master.sys.master_files AS files&lt;br /&gt;
ON stats.database_id = files.database_id&lt;br /&gt;
&amp;nbsp;AND stats.file_id = files.file_id&lt;br /&gt;
&amp;nbsp;WHERE files.type_desc = &#39;ROWS&#39;</content><link rel='replies' type='application/atom+xml' href='http://nazermohamed.blogspot.com/feeds/584497033759489932/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://nazermohamed.blogspot.com/2015/12/io-stalls.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/584497033759489932'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/584497033759489932'/><link rel='alternate' type='text/html' href='http://nazermohamed.blogspot.com/2015/12/io-stalls.html' title='IO stalls'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06113952100169459610</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6786711781036653113.post-6949994373970249730</id><published>2014-07-10T12:22:00.002+01:00</published><updated>2014-07-10T12:22:55.948+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><title type='text'>Get all table sizes</title><content type='html'>&lt;br /&gt;
SELECT&lt;br /&gt;
&amp;nbsp; &amp;nbsp; s.Name AS SchemaName,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; t.NAME AS TableName, &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; p.rows AS RowCounts,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; SUM(a.total_pages)/ 128.00 AS TotalSpaceMB,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; SUM(a.used_pages) / 128.00 AS UsedSpaceMB,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; (SUM(a.total_pages) - SUM(a.used_pages)) / 128.00 AS UnusedSpaceMB&lt;br /&gt;
FROM&lt;br /&gt;
&amp;nbsp; &amp;nbsp; sys.tables t&lt;br /&gt;
INNER JOIN &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; sys.indexes i ON t.OBJECT_ID = i.object_id&lt;br /&gt;
INNER JOIN&lt;br /&gt;
&amp;nbsp; &amp;nbsp; sys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id&lt;br /&gt;
INNER JOIN&lt;br /&gt;
&amp;nbsp; &amp;nbsp; sys.allocation_units a ON p.partition_id = a.container_id&lt;br /&gt;
LEFT OUTER JOIN&lt;br /&gt;
&amp;nbsp; &amp;nbsp; sys.schemas s ON t.schema_id = s.schema_id&lt;br /&gt;
WHERE&lt;br /&gt;
&amp;nbsp; &amp;nbsp; t.NAME NOT LIKE &#39;dt%&#39;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; AND t.is_ms_shipped = 0&lt;br /&gt;
&amp;nbsp; &amp;nbsp; AND i.OBJECT_ID &amp;gt; 255&lt;br /&gt;
GROUP BY&lt;br /&gt;
&amp;nbsp; &amp;nbsp; t.Name, s.Name, p.Rows&lt;br /&gt;
ORDER BY&lt;br /&gt;
&amp;nbsp; &amp;nbsp; SUM(a.total_pages) desc</content><link rel='replies' type='application/atom+xml' href='http://nazermohamed.blogspot.com/feeds/6949994373970249730/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://nazermohamed.blogspot.com/2014/07/get-all-table-sizes.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/6949994373970249730'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/6949994373970249730'/><link rel='alternate' type='text/html' href='http://nazermohamed.blogspot.com/2014/07/get-all-table-sizes.html' title='Get all table sizes'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06113952100169459610</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6786711781036653113.post-1072658301013539381</id><published>2014-03-06T16:59:00.003+00:00</published><updated>2014-03-06T16:59:42.038+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><title type='text'>List emails from SSRS Subscription </title><content type='html'>Get Email Subscriptions from SSRS&lt;br /&gt;
&lt;br /&gt;
with Cte as&lt;br /&gt;
(select CONVERT(XML, ExtensionSettings) x&lt;br /&gt;
FROM&lt;br /&gt;
ReportServer.dbo.Subscriptions a&lt;br /&gt;
inner join&lt;br /&gt;
Catalog c on a.Report_OID = c.ItemID&lt;br /&gt;
where c.Name = &#39;&lt;report name=&quot;&quot;&gt;&#39;&lt;/report&gt;&lt;br /&gt;
)&lt;br /&gt;
select&lt;br /&gt;
cast(x.query(&#39;/ParameterValues/ParameterValue[1]/Value/text()&#39;) as varchar(max)) ToEmails,&lt;br /&gt;
cast(x.query(&#39;/ParameterValues/ParameterValue[4]/Value/text()&#39;) as varchar(max)) Subject&lt;br /&gt;
from cte&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://nazermohamed.blogspot.com/feeds/1072658301013539381/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://nazermohamed.blogspot.com/2014/03/list-emails-from-ssrs-subscription.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/1072658301013539381'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/1072658301013539381'/><link rel='alternate' type='text/html' href='http://nazermohamed.blogspot.com/2014/03/list-emails-from-ssrs-subscription.html' title='List emails from SSRS Subscription '/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06113952100169459610</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6786711781036653113.post-2123957989258785307</id><published>2013-01-07T14:53:00.002+00:00</published><updated>2013-01-07T14:53:45.616+00:00</updated><title type='text'>List the backups for a database</title><content type='html'>&lt;br /&gt;
&lt;br /&gt;
select backup_start_date, backup_finish_date, physical_device_name &amp;nbsp;from backupset bs&lt;br /&gt;
inner join backupmediafamily bmf on bs.media_set_id = bmf.media_set_id&lt;br /&gt;
where database_name = &#39;&lt;dbname&gt;&#39;&lt;/dbname&gt;&lt;br /&gt;
order by backup_start_date desc&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://nazermohamed.blogspot.com/feeds/2123957989258785307/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://nazermohamed.blogspot.com/2013/01/list-backups-for-database.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/2123957989258785307'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/2123957989258785307'/><link rel='alternate' type='text/html' href='http://nazermohamed.blogspot.com/2013/01/list-backups-for-database.html' title='List the backups for a database'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06113952100169459610</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6786711781036653113.post-9036516135967053819</id><published>2012-10-11T13:11:00.001+01:00</published><updated>2012-10-11T13:15:52.412+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><title type='text'>Script all indexes of a database</title><content type='html'>Does not Support advanced options (fill factor, options....)&lt;br /&gt;
Supports Include&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&lt;span style=&quot;font-family: Verdana, sans-serif; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;SELECT&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;Identity(int, 1,1) Id,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;OBJECT_NAME([ixs].[object_id]) &#39;table_name&#39;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;,[ixs].[type] &#39;index_type&#39;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;,[ixs].[type_desc]&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;,[ixs].[name] &#39;index_name&#39;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;,[ixs].[is_unique]&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;,[ixs].[fill_factor]&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;,[ix_col].[key_ordinal]&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;,[col].[name] &#39;column_name&#39;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;,[ix_col].[is_descending_key]&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;,[is_included_column]&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;INTO&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;#Indexes&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;FROM&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;[sys].[tables] tbls&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;INNER JOIN [sys].[indexes] ixs&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;ON [tbls].[object_id] = [ixs].[object_id]&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;AND [tbls].[type] = &#39;U&#39;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;INNER JOIN [sys].[index_columns] ix_col&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;ON [ixs].[object_id] = [ix_col].[object_id]&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;AND [ixs].[index_id] = [ix_col].[index_id]&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;INNER JOIN [sys].[columns] col&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;ON [col].[object_id] = [ix_col].[object_id]&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;AND [col].[column_id] = [ix_col].[column_id]&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;WHERE&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;[ixs].[type] IN ( 1 , 2 )&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;ORDER BY&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;OBJECT_NAME([ixs].[object_id])&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;,[ixs].[type]&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;,[ixs].[name]&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;,[is_included_column]&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;,[ix_col].[key_ordinal]&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;Declare @index_name varchar(500)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;Declare @tmp table (index_name varchar(500) primary key, isProcessed tinyInt default 0)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;insert into @tmp (index_name)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;select distinct Index_name from #Indexes&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;Declare @cols varchar(max), @include varchar(max)&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;Declare @sql varchar(max)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;while (1 = 1)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;Begin&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;select top 1 @index_name = index_name from @tmp where isProcessed = 0&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;if (@@ROWCOUNT = 0) break;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;update @tmp set isProcessed = 2 where index_name = @index_name&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; select @cols = &#39;&#39;, @include = &#39;&#39;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; select @cols = @cols + CASE WHEN is_included_column = 0 then&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&#39;, [&#39; + column_name + &#39;] &#39; + case when is_descending_key = 0 then &#39;ASC&#39; else &#39;DESC&#39; end&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;else &#39;&#39; end,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;@include = @include + CASE WHEN is_included_column = 1 then &#39;, [&#39; + column_name + &#39;]&#39; else &#39;&#39; end&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;from #indexes where index_name = @index_name order by Id&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; Select top 1 @sql = &#39;IF NOT EXISTS (SELECT [Name] FROM [sys].[indexes] WHERE [name] = &#39;&#39;&#39; + @index_name + &#39;&#39;&#39;) &#39; &amp;nbsp;+&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&#39;CREATE &#39; + case when is_unique = &#39;1&#39; THEN &#39;UNIQUE &#39; &amp;nbsp;ELSE &#39;&#39; END + type_desc + &#39;INDEX [&#39; + @index_name + &#39;] ON [&#39; + table_name COLLATE Latin1_General_CI_AS &amp;nbsp;+ &#39;] (&#39; + SUBSTRING(@cols, 2, 8000) + &#39; ) &#39;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;+ case when @include &amp;lt;&amp;gt; &#39;&#39; then &#39;INCLUDE ( &#39; + SUBSTRING(@include, 2, 8000) + &#39; )&#39; else &#39;&#39; end &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; from #Indexes where index_name = @index_name &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; Print @sql&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;End&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;Drop table #Indexes&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://nazermohamed.blogspot.com/feeds/9036516135967053819/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://nazermohamed.blogspot.com/2012/10/script-all-indexes-of-database.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/9036516135967053819'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/9036516135967053819'/><link rel='alternate' type='text/html' href='http://nazermohamed.blogspot.com/2012/10/script-all-indexes-of-database.html' title='Script all indexes of a database'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06113952100169459610</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6786711781036653113.post-1023958399854260215</id><published>2012-06-21T14:19:00.002+01:00</published><updated>2012-06-21T14:19:23.843+01:00</updated><title type='text'>Query Excel data from Sql server</title><content type='html'>&lt;br /&gt;
1. Download drivers and install in Sql server&lt;br /&gt;
http://download.microsoft.com/download/2/4/3/24375141-E08D-4803-AB0E-10F2E3A07AAA/AccessDatabaseEngine_x64.exe&lt;br /&gt;
&lt;br /&gt;
2.&lt;br /&gt;
select * from&lt;br /&gt;
OPENROWSET(&#39;Microsoft.ACE.OLEDB.12.0&#39;,&lt;br /&gt;
&#39;Excel 12.0;Database=D:\temp\temp.xlsx;&#39;,&lt;br /&gt;
&#39;SELECT * FROM [Sheet1$]&#39;)&lt;br /&gt;
&lt;div&gt;
3. if user is not sysadmin, locate the provider in following&amp;nbsp;registry&amp;nbsp;path&amp;nbsp;&lt;b style=&quot;background-color: white; font-family: &#39;Segoe UI&#39;, Arial, Verdana, Tahoma, sans-serif; font-size: 11px; line-height: 16px; text-align: left;&quot;&gt;HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Providers\&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b style=&quot;background-color: white; font-family: &#39;Segoe UI&#39;, Arial, Verdana, Tahoma, sans-serif; font-size: 11px; line-height: 16px; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b style=&quot;background-color: white; font-family: &#39;Segoe UI&#39;, Arial, Verdana, Tahoma, sans-serif; font-size: 11px; line-height: 16px; text-align: left;&quot;&gt;and add&amp;nbsp;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;pre class=&quot;in_text&quot; style=&quot;color: #333333; font-family: Consolas, &#39;Courier New&#39;, Courier, monospace; font-size: 11px; line-height: 16px; padding-bottom: 20px; padding-left: 10px; padding-right: 10px; padding-top: 10px; position: relative; text-align: left; width: auto;&quot;&gt;Value name: DisallowAdHocAccess
   Data type:  REG_DWORD
   Radix:      Hex
   Value: 0&lt;/pre&gt;
&lt;pre class=&quot;in_text&quot; style=&quot;color: #333333; font-family: Consolas, &#39;Courier New&#39;, Courier, monospace; font-size: 11px; line-height: 16px; padding-bottom: 20px; padding-left: 10px; padding-right: 10px; padding-top: 10px; position: relative; text-align: left; width: auto;&quot;&gt;
&lt;/pre&gt;
&lt;pre class=&quot;in_text&quot; style=&quot;color: #333333; font-family: Consolas, &#39;Courier New&#39;, Courier, monospace; font-size: 11px; line-height: 16px; padding-bottom: 20px; padding-left: 10px; padding-right: 10px; padding-top: 10px; position: relative; text-align: left; width: auto;&quot;&gt;
&lt;/pre&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://nazermohamed.blogspot.com/feeds/1023958399854260215/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://nazermohamed.blogspot.com/2012/06/query-excel-data-from-sql-server.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/1023958399854260215'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/1023958399854260215'/><link rel='alternate' type='text/html' href='http://nazermohamed.blogspot.com/2012/06/query-excel-data-from-sql-server.html' title='Query Excel data from Sql server'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06113952100169459610</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6786711781036653113.post-7035698100550850153</id><published>2012-06-13T19:23:00.001+01:00</published><updated>2012-06-13T19:24:12.640+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><title type='text'>Search a string in all tables</title><content type='html'>&lt;br /&gt;
TODO:&lt;br /&gt;
1. Handle schema, currently assumes all tables to be in dbo schema&lt;br /&gt;
2. Check for table existence before execution&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
declare @searchString varchar(1000), @sql varchar(max)&lt;br /&gt;
&lt;br /&gt;
select @searchString = &#39;**search string **&#39;, @sql = &#39;&#39;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Declare @sqlTable table (id int identity Primary Key, selectsql varchar(7000), isComplete bit)&lt;br /&gt;
&lt;br /&gt;
Insert into @sqlTable&lt;br /&gt;
select &#39;&lt;br /&gt;
&lt;br /&gt;
Select top 1 &#39;&#39;&#39; + st.name + &#39;&#39;&#39; _sc12456_TableName, * into #temp&lt;br /&gt;
from [&#39; + st.name + &#39;] where [&#39; + sc.name + &#39;] = &#39;&#39;&#39; + @searchString + &#39;&#39;&#39;&lt;br /&gt;
if (@@rowcount &amp;gt; 0)&lt;br /&gt;
&amp;nbsp; select * from #temp&lt;br /&gt;
go&lt;br /&gt;
&#39;, 0&lt;br /&gt;
from sys.columns sc inner join sys.tables st&lt;br /&gt;
on sc.object_id = st.object_id&lt;br /&gt;
inner join sys.types sc_type on sc.user_type_id = sc_type.user_type_id&lt;br /&gt;
where sc_type.name in (&#39;nvarchar&#39;, &#39;nchar&#39;, &#39;varchar&#39;, &#39;char&#39;) and sc.max_length &amp;gt;= len(@searchString)&lt;br /&gt;
order by st.name&lt;br /&gt;
&lt;br /&gt;
set nocount on&lt;br /&gt;
&lt;br /&gt;
Declare @id int&lt;br /&gt;
while (1 = 1)&lt;br /&gt;
begin&lt;br /&gt;
&amp;nbsp; set @id = null&lt;br /&gt;
&amp;nbsp; select top 1 @id = id, @sql = selectsql from @sqlTable where isComplete = 0&lt;br /&gt;
&amp;nbsp; if (@id is null) break;&lt;br /&gt;
&amp;nbsp; exec (@sql) &lt;br /&gt;
&amp;nbsp; Update @sqlTable set isComplete = 1 where id = @id&lt;br /&gt;
End&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://nazermohamed.blogspot.com/feeds/7035698100550850153/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://nazermohamed.blogspot.com/2012/06/search-string-in-all-tables.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/7035698100550850153'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/7035698100550850153'/><link rel='alternate' type='text/html' href='http://nazermohamed.blogspot.com/2012/06/search-string-in-all-tables.html' title='Search a string in all tables'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06113952100169459610</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6786711781036653113.post-6496129700510555076</id><published>2012-06-11T17:05:00.001+01:00</published><updated>2012-06-11T17:05:28.346+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><title type='text'>List all invalid views</title><content type='html'>&lt;br /&gt;
&lt;br /&gt;
declare @t TAble (Id int identity(1, 1) Primary key, vName varchar(max), isComplete bit)&lt;br /&gt;
declare @badViews Table (vName varchar(max), errNumber int, errMsg varchar(max))&lt;br /&gt;
Insert into @t&lt;br /&gt;
SELECT [name], 0&lt;br /&gt;
FROM sysObjects&lt;br /&gt;
WHERE&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;xType = &#39;V&#39;&lt;br /&gt;
AND [name] NOT IN (&#39;syssegments&#39;, &#39;sysconstraints&#39;)&lt;br /&gt;
AND category=0&lt;br /&gt;
ORDER BY crdate&lt;br /&gt;
&lt;br /&gt;
Declare @id int, @tView varchar(max)&lt;br /&gt;
&lt;br /&gt;
set nocount on&lt;br /&gt;
&lt;br /&gt;
while (1 = 1)&lt;br /&gt;
Begin&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;set @id = null&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;select top 1 @id = Id, @tView = vName from @t&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;where isComplete = 0&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if (@id is null) break;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;BEGIN TRY&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;exec sp_refreshview @tView&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Print @tView + &#39; Valid&#39;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;END TRY&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;BEGIN CATCH&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;if (ERROR_NUMBER() != 15165) -- Ignore views with Schema binding&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Begin&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;INSERT into @badViews VALUES (@tView, ERROR_NUMBER(), ERROR_MESSAGE())&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;Print @tView + &#39; InValid&#39;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;End&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Else&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;Print @tView + &#39; Ignored&#39;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;END CATCH&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;update @t set isComplete = 1 where id = @id&lt;br /&gt;
End&lt;br /&gt;
&lt;br /&gt;
select * from @badViews&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://nazermohamed.blogspot.com/feeds/6496129700510555076/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://nazermohamed.blogspot.com/2012/06/list-all-invalid-views.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/6496129700510555076'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/6496129700510555076'/><link rel='alternate' type='text/html' href='http://nazermohamed.blogspot.com/2012/06/list-all-invalid-views.html' title='List all invalid views'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06113952100169459610</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6786711781036653113.post-7198409969172804640</id><published>2012-06-08T11:47:00.000+01:00</published><updated>2012-06-08T11:47:31.979+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><title type='text'>makeCert</title><content type='html'>Source: http://www.source-code.biz/snippets/vbasic/3.htm&lt;br /&gt;
&lt;br /&gt;
How to create a self-signed certificate that can be used to sign MS-Office VBA projects (Excel/Word macros) on multiple computers&lt;br /&gt;
&lt;br /&gt;
Problem: When a certificate is created by using selfcert.exe, it&#39;s private key cannot be exported. The export wizard of the Windows certificate console says &quot;the associated private key is marked as not exportable&quot;.&lt;br /&gt;
&lt;br /&gt;
Solution version 1: Use makecert.exe with the &quot;-pe&quot; option to create and store the certificate with an exportable private key:&lt;br /&gt;
&lt;br /&gt;
makecert -r -pe -n &quot;CN=Your Name&quot; -b 01/01/2000 -e 01/01/2099 -eku 1.3.6.1.5.5.7.3.3 -ss My&lt;br /&gt;
Then you can export the certificate from the Windows certificate store, including the private key.&lt;br /&gt;
&lt;br /&gt;
Note: Old versions of makecert.exe do not support the &quot;-pe&quot; option. The .NET Framework SDK 2.0 and the October 2002 version of the Platform SDK (build 3718.1) contain a new version of makecert.exe (5.131) that supports the &quot;-pe&quot; option.&lt;br /&gt;
(The .NET Framework SDKs 1.0 and 1.1 both contain old versions of makecert.exe that do not support the &quot;-pe&quot; option).&lt;br /&gt;
&lt;br /&gt;
Solution version 2: The following commands can be used to create a PFX file (PKCS #12) that contains the a self-signed certificate together with the associated private key:&lt;br /&gt;
&lt;br /&gt;
makecert -r -n &quot;CN=Your Name&quot; -b 01/01/2000 -e 01/01/2099 -eku 1.3.6.1.5.5.7.3.3 -sv selfcert.pvk selfcert.cercert2spc selfcert.cer selfcert.spcpvkimprt -pfx selfcert.spc selfcert.pvk&lt;br /&gt;
The last command (pvkimprt -pfx) creates the file selfcert.pfx. This PFX file can then be imported into the Windows certificate store and used for code signing.&lt;br /&gt;
(makecert.exe and cert2spc.exe are part of several Microsoft SDKs, e.g. the Platform SDK or the DotNet SDKs, which can be downloaded from microsoft.com).&lt;br /&gt;
&lt;br /&gt;
Author: Christian d&#39;Heureuse (www.source-code.biz, www.inventec.ch/chdh)</content><link rel='replies' type='application/atom+xml' href='http://nazermohamed.blogspot.com/feeds/7198409969172804640/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://nazermohamed.blogspot.com/2010/11/makecert.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/7198409969172804640'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/7198409969172804640'/><link rel='alternate' type='text/html' href='http://nazermohamed.blogspot.com/2010/11/makecert.html' title='makeCert'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06113952100169459610</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6786711781036653113.post-470109109902265841</id><published>2012-06-07T15:06:00.002+01:00</published><updated>2012-06-08T11:46:42.660+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><title type='text'>Quick way to populate Time Dimension</title><content type='html'>&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CREATE TABLE [dbo].[DimPeriod](&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;[PK_Date] [datetime] Primary key NOT NULL,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Day_Name varchar(150) not null,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;[Year] datetime not null,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;[Year_Name] varchar (50) not null,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;[Quarter] datetime not null,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;[Quarter_Name] [varchar](50) not null,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;[Month] datetime not null,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;[Month_Name] [varchar](50) not null,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;[Day_Of_Year] [int] not null,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;[Day_Of_Month] [int] not null&lt;br /&gt;
)&lt;br /&gt;
go&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Declare @stdate datetime, @enddate datetime&lt;br /&gt;
select&lt;br /&gt;
&amp;nbsp;@stdate = &#39;2006-01-01&#39;,&lt;br /&gt;
&amp;nbsp;@enddate = &#39;2020-12-31&#39;&lt;br /&gt;
&lt;br /&gt;
set @stdate = DATEADD(dd, -1, @stdate)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Insert into DimPeriod&lt;br /&gt;
select dt,&lt;br /&gt;
DateName(WEEKDAY, dt) + &#39;, &#39; + CONVERT(varchar(11), dt, 100),&lt;br /&gt;
--CONVERT(varchar(100), dt,&lt;br /&gt;
cast(yy as datetime),&lt;br /&gt;
&#39;Year &#39; + cast(YEAR(dt) as CHAR(4)), &lt;br /&gt;
dateadd(q, DATEPART(Q, dt) - 1, yy),&lt;br /&gt;
&#39;Quater &#39; + CAST(DATEPART(q, dt) as CHAR(1)),&lt;br /&gt;
cast(cast(YEAR(dt) as CHAR(4)) + &#39;-&#39; + cast(DATEPART(Month, dt) as CHAR(2)) + &#39;-1&#39; as datetime),&lt;br /&gt;
DATENAME(Month, dt) + &#39; &#39; + cast(YEAR(dt) as CHAR(4)),&lt;br /&gt;
DATEPART(DAYOFYEAR, dt), DAY(dt)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; from (&lt;br /&gt;
SELECT TOP (DATEDIFF(DD, @stdate, @enddate))&lt;br /&gt;
&amp;nbsp;cast(DatePart(YEAR, DATEADD(dd, row_number() &amp;nbsp;over(order by t1.number), &#39;2005-12-31&#39;)) as CHAR(4))&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;+ &#39;-01-01&#39; yy,&lt;br /&gt;
&amp;nbsp;DATEADD(dd, row_number() &amp;nbsp;over(order by t1.number), &#39;2005-12-31&#39;) as dt&lt;br /&gt;
FROM master..spt_values t1&lt;br /&gt;
&amp;nbsp; &amp;nbsp; CROSS JOIN master..spt_values t2&lt;br /&gt;
)sq</content><link rel='replies' type='application/atom+xml' href='http://nazermohamed.blogspot.com/feeds/470109109902265841/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://nazermohamed.blogspot.com/2012/06/quick-way-to-populate-time-dimension.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/470109109902265841'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/470109109902265841'/><link rel='alternate' type='text/html' href='http://nazermohamed.blogspot.com/2012/06/quick-way-to-populate-time-dimension.html' title='Quick way to populate Time Dimension'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06113952100169459610</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6786711781036653113.post-4339608790033946424</id><published>2012-03-26T10:13:00.002+01:00</published><updated>2012-03-26T10:57:00.679+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><title type='text'>Quick dump of All table Sizes of a database</title><content type='html'>Option #1 - Clear documented and robust&lt;br /&gt;&lt;br /&gt;create table tempdb.dbo.AllTableSize058(name varchar(150), rows int, reserved varchar(100), data varchar(100), index_size varchar(100), unused varchar(100))&lt;br /&gt;go&lt;br /&gt;sp_msforeachtable &#39;Insert into tempdb.dbo.AllTableSize058 Exec sp_spaceused &quot;?&quot;&#39;&lt;br /&gt;&lt;br /&gt;Update tempdb.dbo.AllTableSize058 set reserved = replace(reserved, &#39;KB&#39;, &#39;&#39;), data = replace(data, &#39;KB&#39;, &#39;&#39;), index_size = replace(index_size, &#39;KB&#39;, &#39;&#39;), unused = replace(unused, &#39;KB&#39;, &#39;&#39;)&lt;br /&gt;&lt;br /&gt;select * from tempdb.dbo.AllTableSize058 order by cast(reserved as int) desc&lt;br /&gt;&lt;br /&gt;--Drop table tempdb.dbo.AllTableSize058&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Option #2&lt;br /&gt;&lt;br /&gt;Undocumented way, but efficient and clean. Does not look for internal tables (service broker queues etc)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;select Name, rows, reserved, used, unused, data, used - data index_size from&lt;br /&gt;(&lt;br /&gt;select a.object_id, a.name,&lt;br /&gt;Sum(CASE WHEN (index_id &lt; 2) THEN row_count ELSE 0 END) rows,&lt;br /&gt; Sum(reserved_page_count * 8) reserved,  &lt;br /&gt; Sum(used_page_count * 8) used,&lt;br /&gt; Sum((reserved_page_count - used_page_count) * 8) unUsed,&lt;br /&gt; Sum(CASE WHEN (index_id &lt; 2) THEN (in_row_data_page_count + lob_used_page_count + row_overflow_used_page_count) ELSE lob_used_page_count + row_overflow_used_page_count END * 8) data&lt;br /&gt; from sys.tables a inner join sys.dm_db_partition_stats b&lt;br /&gt; on a.object_id = b.object_id&lt;br /&gt; Group by a.object_id, a.name&lt;br /&gt;) a&lt;br /&gt;order by reserved desc</content><link rel='replies' type='application/atom+xml' href='http://nazermohamed.blogspot.com/feeds/4339608790033946424/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://nazermohamed.blogspot.com/2012/03/quick-dump-of-all-table-sizes-of.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/4339608790033946424'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/4339608790033946424'/><link rel='alternate' type='text/html' href='http://nazermohamed.blogspot.com/2012/03/quick-dump-of-all-table-sizes-of.html' title='Quick dump of All table Sizes of a database'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06113952100169459610</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6786711781036653113.post-8857629824421084391</id><published>2012-01-27T16:45:00.002+00:00</published><updated>2012-01-27T16:46:15.804+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><title type='text'>Difference in Identity Functions</title><content type='html'>Small script to demo the usage of different Identites&lt;br /&gt;&lt;br /&gt;Create table testIdentity (Id int Identity Primary Key, name varchar(100))&lt;br /&gt;go&lt;br /&gt;&lt;br /&gt;Create Table testIdentityLog (Id int Identity(1000, 1) Primary Key, dt dateTime)&lt;br /&gt;go&lt;br /&gt;&lt;br /&gt;Create Trigger trigtestIdentity on testIdentity &lt;br /&gt;after insert&lt;br /&gt;as&lt;br /&gt; Insert into testIdentityLog Values (getdate())&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Insert into testIdentity Values (&#39;One&#39;)&lt;br /&gt;select @@IDENTITY id, SCOPE_IDENTITY() ActualId&lt;br /&gt;&lt;br /&gt;Insert into testIdentityLog Values (getdate())&lt;br /&gt;select @@IDENTITY id, SCOPE_IDENTITY() ActualId, IDENT_CURRENT(&#39;testIdentity&#39;), IDENT_CURRENT(&#39;testIdentityLog&#39;)</content><link rel='replies' type='application/atom+xml' href='http://nazermohamed.blogspot.com/feeds/8857629824421084391/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://nazermohamed.blogspot.com/2012/01/difference-in-identities.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/8857629824421084391'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/8857629824421084391'/><link rel='alternate' type='text/html' href='http://nazermohamed.blogspot.com/2012/01/difference-in-identities.html' title='Difference in Identity Functions'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06113952100169459610</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6786711781036653113.post-404294892522225851</id><published>2011-03-26T02:30:00.001+00:00</published><updated>2012-06-08T11:47:11.169+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="VOIP"/><title type='text'>Asterisk GUI Not found</title><content type='html'>After installing Asterisk GUI 2.0 I was getting the &quot;http 404 not found&quot; error. &lt;br /&gt;
&lt;br /&gt;
remove the /usr/share/asterisk/&#39;http-static&#39; directory&lt;br /&gt;
ln -s /var/lib/asterisk/staic-http/ /usr/share/asterisk/</content><link rel='replies' type='application/atom+xml' href='http://nazermohamed.blogspot.com/feeds/404294892522225851/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://nazermohamed.blogspot.com/2011/03/asterisk-gui-not-found.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/404294892522225851'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/404294892522225851'/><link rel='alternate' type='text/html' href='http://nazermohamed.blogspot.com/2011/03/asterisk-gui-not-found.html' title='Asterisk GUI Not found'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06113952100169459610</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6786711781036653113.post-7492557559419686745</id><published>2010-07-23T18:02:00.005+01:00</published><updated>2015-12-17T12:37:32.088+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Social"/><title type='text'>PGP Chat Google Talk (Gtalk)</title><content type='html'>&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;-- No Longer works - due to change in Gtalk Api change. --&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Wanted to create this software for a very long time. Atlast, it is done. &lt;br /&gt;
&lt;br /&gt;
Copied the basic application from codeProject (http://www.codeproject.com/KB/gadgets/googletalk.aspx)&lt;br /&gt;
&lt;br /&gt;
Then added the functionality to get Secure. &lt;br /&gt;
&lt;br /&gt;
1. As soon as a chat session is opened with the operand, a RSA key pair is generated. The key pair is kept until the applicaiton quits.&lt;br /&gt;
&lt;br /&gt;
2. Sends the public key and expects one from the operand&lt;br /&gt;
&lt;br /&gt;
3. If key recieved, then secure Chat is turned on&lt;br /&gt;
&lt;br /&gt;
4. if not, the chat session will be unsecure&lt;br /&gt;
&lt;br /&gt;
5. To check, if it is really secure, you can open Gtalk, and monitor. Gtalk allows multiple sessions. So you can see encrypted messages passisng arround.&lt;br /&gt;
&lt;br /&gt;
Download it from:&lt;br /&gt;
&lt;a href=&quot;https://docs.google.com/file/d/0By6OGZauI7FvZjllOTJkMDItODQ1OC00OGZhLWJiMGQtN2M1Yjk5NzI1ZmU5/edit?authkey=CLfFv98B&quot;&gt;https://docs.google.com/file/d/0By6OGZauI7FvZjllOTJkMDItODQ1OC00OGZhLWJiMGQtN2M1Yjk5NzI1ZmU5/edit?authkey=CLfFv98B&lt;/a&gt;&amp;nbsp;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Source:&lt;br /&gt;
&lt;a href=&quot;http://dl.dropbox.com/u/1784903/Gtalk_Source.zip&quot; style=&quot;background-color: rgba(255, 255, 255, 0.917969); color: #1155cc; font-family: arial, sans-serif; font-size: 13px;&quot; target=&quot;_blank&quot;&gt;http://dl.dropbox.com/u/&lt;wbr&gt;&lt;/wbr&gt;1784903/Gtalk_Source.zip&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://nazermohamed.blogspot.com/feeds/7492557559419686745/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://nazermohamed.blogspot.com/2010/07/secure-chat-google-talk-gtalk.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/7492557559419686745'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/7492557559419686745'/><link rel='alternate' type='text/html' href='http://nazermohamed.blogspot.com/2010/07/secure-chat-google-talk-gtalk.html' title='PGP Chat Google Talk (Gtalk)'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06113952100169459610</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6786711781036653113.post-7351717601854802537</id><published>2010-06-09T17:38:00.001+01:00</published><updated>2010-06-09T17:40:37.432+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><title type='text'>Shortest route, non-weighted and bidirectional</title><content type='html'>create table Friendship(id int identity(1,1) primary key, user1ID int, user2ID int)&lt;br /&gt;&lt;br /&gt;Insert into Friendship &lt;br /&gt;select 1, 2 Union all&lt;br /&gt;select 3, 4 Union all&lt;br /&gt;select 2, 5 Union all&lt;br /&gt;select 4, 5 Union all&lt;br /&gt;select 6, 7 Union all&lt;br /&gt;select 8, 9 Union all&lt;br /&gt;select 1, 5 Union all&lt;br /&gt;select 6, 9 Union all &lt;br /&gt;select 3, 7 Union all &lt;br /&gt;select 7, 6&lt;br /&gt;&lt;br /&gt;Exec dbo.usp_ShortestRoute 9, 1, 8&lt;br /&gt;&lt;br /&gt;Create Procedure usp_ShortestRoute (@StartNode int, @EndNode int, @depth int = null)&lt;br /&gt;as&lt;br /&gt;Begin&lt;br /&gt;&lt;br /&gt; Declare @routes Table (RouteMap varchar(150), EndNode int, depth Int)&lt;br /&gt; Declare @isRouteFound bit, @rows int, @msg varchar(150), @activedepth int&lt;br /&gt;&lt;br /&gt; Select @isRouteFound  = 0, @activedepth = 1&lt;br /&gt;&lt;br /&gt; if (@StartNode = @EndNode)&lt;br /&gt;    select @msg = &#39;Start and End node are same&#39;&lt;br /&gt; else if not exists (select top 1 Id from Friendship Where user1ID = @StartNode or user2ID = @StartNode)&lt;br /&gt;   or not exists (select top 1 Id from Friendship Where user1id = @endNode or user2ID = @EndNode)&lt;br /&gt;    select @msg = &#39;No possible Route&#39;&lt;br /&gt; else&lt;br /&gt; Begin&lt;br /&gt;  Insert into @routes&lt;br /&gt;  select CAST(user1ID as varchar(3)) + &#39; - &#39; + CAST(user2ID as varchar(3)), user2ID, 1 from Friendship where user1ID = @StartNode &lt;br /&gt;  Union &lt;br /&gt;  select CAST(user2ID as varchar(3)) + &#39; - &#39; + CAST(user1ID as varchar(3)), user1ID, 1 from Friendship where user2ID = @StartNode &lt;br /&gt;    &lt;br /&gt;  set @rows = @@ROWCOUNT&lt;br /&gt;&lt;br /&gt;  While (1 = 1)&lt;br /&gt;  Begin&lt;br /&gt;   if (@rows = 0) &lt;br /&gt;   Begin&lt;br /&gt;    Select @isRouteFound = 0, @msg = &#39;Passed the end of routes. Route Incomplete&#39;&lt;br /&gt;    break;&lt;br /&gt;   End&lt;br /&gt;&lt;br /&gt;   if exists (select top 1 * from @routes where EndNode = @EndNode) &lt;br /&gt;   Begin&lt;br /&gt;    select @isRouteFound = 1, @msg = &#39;Route Found&#39;&lt;br /&gt;    break;&lt;br /&gt;   End     &lt;br /&gt;   &lt;br /&gt;   if (@activedepth &gt;= isNull(@depth, @activedepth)) &lt;br /&gt;   Begin&lt;br /&gt;    set @msg = &#39;Depth Reached - Route not found&#39; &lt;br /&gt;    break;&lt;br /&gt;   End&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   /*&lt;br /&gt;    1. Forget lower depth routes&lt;br /&gt;    2. Make sure we dont loop the same route&lt;br /&gt;     2.1 Node will either be in the begining of the route or in the mid.&lt;br /&gt;     2.2 The node that is at the end the recent node, so we should not check that&lt;br /&gt;    3. Insert records with active depth + 1    &lt;br /&gt;   */      &lt;br /&gt;   Insert into @routes&lt;br /&gt;   select RouteMap + &#39; - &#39; + CAST(b.user2ID as varchar(3)), b.user2ID, @activedepth + 1 from @routes a left join Friendship b on a.EndNode = b.user1ID &lt;br /&gt;     where depth = @activedepth and RouteMap not like &#39;%- &#39; + CAST(b.user2ID as varchar(3)) + &#39; -%&#39; and RouteMap not like CAST(b.user2ID as varchar(3)) + &#39; -%&#39;&lt;br /&gt;   Union&lt;br /&gt;   select RouteMap + &#39; - &#39; + CAST(b.user1ID as varchar(3)), b.user1ID, @activedepth + 1 from @routes a left join Friendship b on a.EndNode = b.user2ID &lt;br /&gt;     where depth = @activedepth  and RouteMap not like &#39;%- &#39; + CAST(b.user1ID as varchar(3)) + &#39; -%&#39; and RouteMap not like CAST(b.user1ID as varchar(3)) + &#39; -%&#39; &lt;br /&gt;    &lt;br /&gt;   select @rows = @@ROWCOUNT, @activedepth = @activedepth + 1&lt;br /&gt;   &lt;br /&gt;   --select  *from @routes&lt;br /&gt;  End  &lt;br /&gt; End &lt;br /&gt;&lt;br /&gt; --select * from @routes&lt;br /&gt; --select @isRouteFound  Result, @depth Depth&lt;br /&gt;&lt;br /&gt; if (@isRouteFound = 1)&lt;br /&gt;  select RouteMap, depth, @msg Result from @routes where EndNode = @EndNode&lt;br /&gt; else&lt;br /&gt;  select null RouteMap, -1 depth, @msg Result&lt;br /&gt;End</content><link rel='replies' type='application/atom+xml' href='http://nazermohamed.blogspot.com/feeds/7351717601854802537/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://nazermohamed.blogspot.com/2010/06/shortest-route-non-weighted-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/7351717601854802537'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/7351717601854802537'/><link rel='alternate' type='text/html' href='http://nazermohamed.blogspot.com/2010/06/shortest-route-non-weighted-and.html' title='Shortest route, non-weighted and bidirectional'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06113952100169459610</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6786711781036653113.post-6722142787824697494</id><published>2010-04-19T11:13:00.000+01:00</published><updated>2010-04-19T11:14:14.036+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><title type='text'>Find TimeZone of server</title><content type='html'>Declare @temp Table (Cmdoutput varchar(max))&lt;br /&gt;&lt;br /&gt;Insert into @temp&lt;br /&gt;Exec xp_cmdshell &#39;reg query HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TimeZoneInformation /v StandardName&#39;&lt;br /&gt;select Ltrim(REPLACE(CmdOutput, &#39;StandardName&#39; + CHAR(9) + &#39;REG_SZ&#39;, &#39;&#39;)) from @temp where Cmdoutput like &#39;%standardName%&#39;</content><link rel='replies' type='application/atom+xml' href='http://nazermohamed.blogspot.com/feeds/6722142787824697494/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://nazermohamed.blogspot.com/2010/04/find-timezone-of-server.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/6722142787824697494'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/6722142787824697494'/><link rel='alternate' type='text/html' href='http://nazermohamed.blogspot.com/2010/04/find-timezone-of-server.html' title='Find TimeZone of server'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06113952100169459610</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6786711781036653113.post-260869319648607472</id><published>2010-04-16T11:39:00.001+01:00</published><updated>2010-04-16T11:51:29.065+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><title type='text'>send a CSV attachment by Email (ANSI attachment)</title><content type='html'>Declare @filename varchar(100), @cmd varchar(max)&lt;br /&gt; set @filename = &#39;output-&#39; + convert(varchar(10), getdate(), 121) + &#39;.csv&#39;&lt;br /&gt;&lt;br /&gt; set nocount off&lt;br /&gt; set @cmd = &#39;exec xp_cmdShell &#39;&#39;bcp &quot;query&quot; queryout &#39; + @fileName + &#39; -S server -U user -P pass -f&quot;bcp.fmt&quot;&#39;&#39;, no_output&#39;&lt;br /&gt; Exec (@cmd)&lt;br /&gt;&lt;br /&gt; EXEC msdb.dbo.sp_send_dbmail&lt;br /&gt; @recipients=N&#39;email@domain.com&#39;,&lt;br /&gt; @body=&#39;Hi, &lt;br /&gt;    this is email body&lt;br /&gt; &#39;, &lt;br /&gt; @subject =&#39;this is email sub&#39;,&lt;br /&gt; @profile_name =&#39;profile&#39;,&lt;br /&gt; @file_attachments= @filename</content><link rel='replies' type='application/atom+xml' href='http://nazermohamed.blogspot.com/feeds/260869319648607472/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://nazermohamed.blogspot.com/2010/04/send-csv-attachment-by-email-ansi.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/260869319648607472'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/260869319648607472'/><link rel='alternate' type='text/html' href='http://nazermohamed.blogspot.com/2010/04/send-csv-attachment-by-email-ansi.html' title='send a CSV attachment by Email (ANSI attachment)'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06113952100169459610</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6786711781036653113.post-8220519994160845695</id><published>2010-04-13T08:47:00.003+01:00</published><updated>2010-04-13T08:49:12.022+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SSIS"/><title type='text'>Excel Destination - using Script</title><content type='html'>Recently faced a problem with the Excel Destination Data Flow component. It does not write formulas properly. &lt;br /&gt;So developed this script that will use a File Connection and write directly to Excel. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;using System;&lt;br /&gt;using System.Data;&lt;br /&gt;using Microsoft.SqlServer.Dts.Pipeline.Wrapper;&lt;br /&gt;using Microsoft.SqlServer.Dts.Runtime.Wrapper;&lt;br /&gt;using System.Reflection;&lt;br /&gt;&lt;br /&gt;[Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]&lt;br /&gt;public class ScriptMain : UserComponent&lt;br /&gt;{&lt;br /&gt;    string filename;&lt;br /&gt;    Microsoft.Office.Interop.Excel.Application excelApp;&lt;br /&gt;    Microsoft.Office.Interop.Excel.Workbook wbook;&lt;br /&gt;    Microsoft.Office.Interop.Excel.Worksheet wsht;&lt;br /&gt;    &lt;br /&gt;    int row;&lt;br /&gt;&lt;br /&gt;    public override void PreExecute()&lt;br /&gt;    {&lt;br /&gt;        row = 1;&lt;br /&gt;        filename = (string)this.Connections.OutputFileConnection.AcquireConnection(null);&lt;br /&gt;        excelApp = new Microsoft.Office.Interop.Excel.Application();&lt;br /&gt;        wbook = excelApp.Workbooks.Add(Missing.Value);&lt;br /&gt;        wsht = (Microsoft.Office.Interop.Excel.Worksheet)wbook.Worksheets.get_Item(1);&lt;br /&gt;        &lt;br /&gt;        base.PreExecute();&lt;br /&gt;        /*&lt;br /&gt;          Add your code here for preprocessing or remove if not needed&lt;br /&gt;        */&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public override void PostExecute()&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        //wbook.SaveAs(filename, Missing.Value, Missing.Value, Missing.Value, true, false, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive, &lt;br /&gt;        //        Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);&lt;br /&gt;        wbook.Close(true, filename, false);&lt;br /&gt;        excelApp.Quit();&lt;br /&gt;        base.PostExecute();&lt;br /&gt;        /*&lt;br /&gt;          Add your code here for postprocessing or remove if not needed&lt;br /&gt;          You can set read/write variables here, for example:&lt;br /&gt;          Variables.MyIntVar = 100&lt;br /&gt;        */&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public override void Input0_ProcessInputRow(Input0Buffer Row)&lt;br /&gt;    {&lt;br /&gt;        wsht.Cells[row, &quot;A&quot;] = Row.ID;&lt;br /&gt;        wsht.Cells[row, &quot;B&quot;] = Row.CountryName;&lt;br /&gt;        //wsht.Cells[row, &quot;C&quot;] = &quot;=INDIRECT(ADDRESS(ROW(),1, 4)) * 2&quot;;&lt;br /&gt;        row++;&lt;br /&gt;    }&lt;br /&gt;}</content><link rel='replies' type='application/atom+xml' href='http://nazermohamed.blogspot.com/feeds/8220519994160845695/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://nazermohamed.blogspot.com/2010/04/excel-destination-using-script.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/8220519994160845695'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/8220519994160845695'/><link rel='alternate' type='text/html' href='http://nazermohamed.blogspot.com/2010/04/excel-destination-using-script.html' title='Excel Destination - using Script'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06113952100169459610</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6786711781036653113.post-8956167119698845578</id><published>2010-04-09T12:17:00.001+01:00</published><updated>2010-04-09T12:18:26.615+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><title type='text'>SQL XML Modify</title><content type='html'>Insert / Delete inside XML&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Declare @xml xml&lt;br /&gt;SET @xml = &#39;&lt;Report id=&quot;9&quot;&gt;&lt;Folder/&gt;Test/Test&lt;/Report&gt;&#39;&lt;br /&gt;&lt;br /&gt;set @xml.modify(&#39;insert attribute txt {/Report/text()} into  (/Report/Folder)[1]&#39;)  &lt;br /&gt;set @xml.modify(&#39;delete /Report/text()&#39;)&lt;br /&gt;select @xml</content><link rel='replies' type='application/atom+xml' href='http://nazermohamed.blogspot.com/feeds/8956167119698845578/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://nazermohamed.blogspot.com/2010/04/sql-xml-modify.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/8956167119698845578'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/8956167119698845578'/><link rel='alternate' type='text/html' href='http://nazermohamed.blogspot.com/2010/04/sql-xml-modify.html' title='SQL XML Modify'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06113952100169459610</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6786711781036653113.post-7731665854116320325</id><published>2010-04-09T10:33:00.006+01:00</published><updated>2012-03-26T11:10:24.828+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><title type='text'>Configure Network Trace in your application</title><content type='html'>&lt;div&gt;&lt;configuration&gt;&lt;/configuration&gt;&lt;/div&gt;&lt;div&gt;  &lt;system.diagnostics&gt;&lt;/system.diagnostics&gt;&lt;/div&gt;&lt;div&gt;    &lt;sources&gt;&lt;/sources&gt;&lt;/div&gt;&lt;div&gt;      &lt;source name=&quot;System.Net&quot; tracemode=&quot;includehex&quot; maxdatasize=&quot;1024&quot;&gt;&lt;/div&gt;&lt;div&gt;        &lt;listeners&gt;&lt;/listeners&gt;&lt;/div&gt;&lt;div&gt;          &lt;add name=&quot;System.Net&quot;&gt;&lt;/add&gt;&lt;/div&gt;&lt;div&gt;        &lt;/div&gt;&lt;div&gt;      &lt;/div&gt;&lt;div&gt;      &lt;source name=&quot;System.Net.Sockets&quot;&gt;&lt;/div&gt;&lt;div&gt;        &lt;listeners&gt;&lt;/listeners&gt;&lt;/div&gt;&lt;div&gt;          &lt;add name=&quot;System.Net&quot;&gt;&lt;/add&gt;&lt;/div&gt;&lt;div&gt;        &lt;/div&gt;&lt;div&gt;      &lt;/div&gt;&lt;div&gt;      &lt;source name=&quot;System.Net.Cache&quot;&gt;&lt;/div&gt;&lt;div&gt;        &lt;listeners&gt;&lt;/listeners&gt;&lt;/div&gt;&lt;div&gt;          &lt;add name=&quot;System.Net&quot;&gt;&lt;/add&gt;&lt;/div&gt;&lt;div&gt;        &lt;/div&gt;&lt;div&gt;      &lt;/div&gt;&lt;div&gt;    &lt;/div&gt;&lt;div&gt;    &lt;switches&gt;&lt;/switches&gt;&lt;/div&gt;&lt;div&gt;      &lt;add name=&quot;System.Net&quot; value=&quot;Verbose&quot;&gt;&lt;/add&gt;&lt;/div&gt;&lt;div&gt;      &lt;add name=&quot;System.Net.Sockets&quot; value=&quot;Verbose&quot;&gt;&lt;/add&gt;&lt;/div&gt;&lt;div&gt;      &lt;add name=&quot;System.Net.Cache&quot; value=&quot;Verbose&quot;&gt;&lt;/add&gt;&lt;/div&gt;&lt;div&gt;    &lt;/div&gt;&lt;div&gt;    &lt;sharedlisteners&gt;&lt;/sharedlisteners&gt;&lt;/div&gt;&lt;div&gt;      &lt;add name=&quot;System.Net&quot; div=&quot;&quot;&gt;&lt;div&gt;&lt;div&gt;&amp;lt;configuration&amp;gt;&lt;/div&gt;&lt;div&gt;  &amp;lt;system.diagnostics&amp;gt;&lt;/div&gt;&lt;div&gt;    &amp;lt;sources&amp;gt;&lt;/div&gt;&lt;div&gt;      &amp;lt;source name=&quot;System.Net&quot; tracemode=&quot;includehex&quot; maxdatasize=&quot;1024&quot;&amp;gt;&lt;/div&gt;&lt;div&gt;        &amp;lt;listeners&amp;gt;&lt;/div&gt;&lt;div&gt;          &amp;lt;add name=&quot;System.Net&quot;/&amp;gt;&lt;/div&gt;&lt;div&gt;        &amp;lt;/listeners&amp;gt;&lt;/div&gt;&lt;div&gt;      &amp;lt;/source&amp;gt;&lt;/div&gt;&lt;div&gt;      &amp;lt;source name=&quot;System.Net.Sockets&quot;&amp;gt;&lt;/div&gt;&lt;div&gt;        &amp;lt;listeners&amp;gt;&lt;/div&gt;&lt;div&gt;          &amp;lt;add name=&quot;System.Net&quot;/&amp;gt;&lt;/div&gt;&lt;div&gt;        &amp;lt;/listeners&amp;gt;&lt;/div&gt;&lt;div&gt;      &amp;lt;/source&amp;gt;&lt;/div&gt;&lt;div&gt;      &amp;lt;source name=&quot;System.Net.Cache&quot;&amp;gt;&lt;/div&gt;&lt;div&gt;        &amp;lt;listeners&amp;gt;&lt;/div&gt;&lt;div&gt;          &amp;lt;add name=&quot;System.Net&quot;/&amp;gt;&lt;/div&gt;&lt;div&gt;        &amp;lt;/listeners&amp;gt;&lt;/div&gt;&lt;div&gt;      &amp;lt;/source&amp;gt;&lt;/div&gt;&lt;div&gt;    &amp;lt;/sources&amp;gt;&lt;/div&gt;&lt;div&gt;    &amp;lt;switches&amp;gt;&lt;/div&gt;&lt;div&gt;      &amp;lt;add name=&quot;System.Net&quot; value=&quot;Verbose&quot;/&amp;gt;&lt;/div&gt;&lt;div&gt;      &amp;lt;add name=&quot;System.Net.Sockets&quot; value=&quot;Verbose&quot;/&amp;gt;&lt;/div&gt;&lt;div&gt;      &amp;lt;add name=&quot;System.Net.Cache&quot; value=&quot;Verbose&quot;/&amp;gt;&lt;/div&gt;&lt;div&gt;    &amp;lt;/switches&amp;gt;&lt;/div&gt;&lt;div&gt;    &amp;lt;sharedListeners&amp;gt;&lt;/div&gt;&lt;div&gt;      &amp;lt;add name=&quot;System.Net&quot;&lt;/div&gt;&lt;div&gt;        type=&quot;System.Diagnostics.TextWriterTraceListener&quot;&lt;/div&gt;&lt;div&gt;        initializeData=&quot;network.log&quot;&lt;/div&gt;&lt;div&gt;      /&amp;gt;&lt;/div&gt;&lt;div&gt;    &amp;lt;/sharedListeners&amp;gt;&lt;/div&gt;&lt;div&gt;    &amp;lt;trace autoflush=&quot;true&quot;/&amp;gt;&lt;/div&gt;&lt;div&gt;  &amp;lt;/system.diagnostics&amp;gt;&lt;/div&gt;&lt;div&gt;&amp;lt;/configuration&amp;gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;    &lt;/div&gt;&lt;div&gt;    &lt;trace autoflush=&quot;true&quot;&gt;&lt;/trace&gt;&lt;/div&gt;&lt;div&gt;  &lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;/add&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://nazermohamed.blogspot.com/feeds/7731665854116320325/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://nazermohamed.blogspot.com/2010/04/configure-network-trace-in-your.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/7731665854116320325'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/7731665854116320325'/><link rel='alternate' type='text/html' href='http://nazermohamed.blogspot.com/2010/04/configure-network-trace-in-your.html' title='Configure Network Trace in your application'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06113952100169459610</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6786711781036653113.post-5580431926518322504</id><published>2010-04-06T16:48:00.003+01:00</published><updated>2010-04-06T16:50:50.723+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><title type='text'>Registering additional assemblies in SQL CLR</title><content type='html'>By default not all assemblies are included for the CLR to use with. To add other assemblies, &lt;br /&gt;&lt;br /&gt;ALTER DATABASE AdventureWorks SET TRUSTWORTHY ON&lt;br /&gt;&lt;br /&gt;CREATE ASSEMBLY Messaging&lt;br /&gt;AUTHORIZATION dbo&lt;br /&gt;FROM &#39;C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Messaging.dll&#39;&lt;br /&gt;WITH PERMISSION_SET = UNSAFE</content><link rel='replies' type='application/atom+xml' href='http://nazermohamed.blogspot.com/feeds/5580431926518322504/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://nazermohamed.blogspot.com/2010/04/registering-additional-assemblies-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/5580431926518322504'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/5580431926518322504'/><link rel='alternate' type='text/html' href='http://nazermohamed.blogspot.com/2010/04/registering-additional-assemblies-in.html' title='Registering additional assemblies in SQL CLR'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06113952100169459610</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6786711781036653113.post-5397470319244731255</id><published>2010-03-23T12:04:00.003+00:00</published><updated>2010-03-23T12:08:24.525+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><title type='text'>Extract Numbers / Text from String</title><content type='html'>Create Function Extract(@NumStr Varchar(1000), @option int = 0)&lt;br /&gt;returns Varchar(1000)&lt;br /&gt;as&lt;br /&gt;Begin&lt;br /&gt; Declare @tmpStr Varchar(1000), @c int, @n int&lt;br /&gt; Declare @Result Varchar(1000)&lt;br /&gt; select @Result = &#39;&#39;, @n = 1&lt;br /&gt; While @NumStr != &#39;&#39;&lt;br /&gt; Begin&lt;br /&gt;  select @c = CHARINDEX(&#39; &#39;, @NumStr, @n)&lt;br /&gt;  if (@c = 0) Break;&lt;br /&gt;  select @tmpStr = SUBSTRING(@NumStr, @n, @c)&lt;br /&gt;  &lt;br /&gt;  if (@option = 0) &lt;br /&gt;  Begin&lt;br /&gt;    if (@tmpStr  like &#39;%[0-9]%&#39;) &lt;br /&gt;     set @Result = @Result + @tmpStr &lt;br /&gt;  End&lt;br /&gt;  else &lt;br /&gt;  Begin&lt;br /&gt;    if (@tmpStr Not like &#39;%[0-9]%&#39;) &lt;br /&gt;     set @Result = @Result + @tmpStr &lt;br /&gt;  End &lt;br /&gt;  select @NumStr = SUBSTRING(@NumStr, @c + 1, 1000) &lt;br /&gt; End&lt;br /&gt; if (@option = 0)&lt;br /&gt; Begin&lt;br /&gt;  if (@numStr  like &#39;%[0-9]%&#39;) &lt;br /&gt;   set @Result = @Result + @numStr &lt;br /&gt; End&lt;br /&gt; else&lt;br /&gt; Begin &lt;br /&gt;  if (@numStr  Not like &#39;%[0-9]%&#39;) &lt;br /&gt;   set @Result = @Result + @numStr &lt;br /&gt; End&lt;br /&gt; Return (@Result);&lt;br /&gt;End&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;go&lt;br /&gt;&lt;br /&gt;-- Test&lt;br /&gt;select dbo.Extract(&#39;This string contains 5 words and3 now 9 words. And also 9ahs asd&#39;, 1)</content><link rel='replies' type='application/atom+xml' href='http://nazermohamed.blogspot.com/feeds/5397470319244731255/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://nazermohamed.blogspot.com/2010/03/extract-numbers-text-from-string.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/5397470319244731255'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/5397470319244731255'/><link rel='alternate' type='text/html' href='http://nazermohamed.blogspot.com/2010/03/extract-numbers-text-from-string.html' title='Extract Numbers / Text from String'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06113952100169459610</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6786711781036653113.post-1311476354510378314</id><published>2009-12-23T12:28:00.005+00:00</published><updated>2012-03-26T10:17:45.394+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><title type='text'>Service Availability Calculation</title><content type='html'>&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Service Availability % = [(TM – SM – DM)/(TM – SM)] * 100&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Where:&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;TM = Total Minutes in the calendar month (i.e.: #days*24hrs*60mins)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;SM = Scheduled Maintenance Time (in minutes)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;DM = Unscheduled Downtime.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Eg:&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Scheduled Maintenance - 10 mintues in a month&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Downtime: 5 minutes in a month&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;(43200 - 10 - 5) / (43200 - 10) = 99.98%&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://nazermohamed.blogspot.com/feeds/1311476354510378314/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://nazermohamed.blogspot.com/2009/12/service-availability-calculation.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/1311476354510378314'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6786711781036653113/posts/default/1311476354510378314'/><link rel='alternate' type='text/html' href='http://nazermohamed.blogspot.com/2009/12/service-availability-calculation.html' title='Service Availability Calculation'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06113952100169459610</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>