<?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-26554202</id><updated>2024-09-05T17:04:59.529+07:00</updated><category term="some code"/><category term="sharing"/><category term="my thoughts"/><category term="the Web"/><category term="MSSQL"/><category term="IIS"/><category term="MCSD"/><category term="MVC"/><category term="MVC 3"/><category term="SQL Server"/><category term="Web API"/><category term="myth"/><category term="network"/><category term="printer"/><category term="timeout"/><title type='text'>...it&#39;s me...eRiCk</title><subtitle type='html'>this is my personal web blog..anything that i do each day hopefully can get in this blog since i only able to write it if i have spare time at the office..(ky g kerja aj ya hahaa)</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://erickwidya.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://erickwidya.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>eRiCk</name><uri>http://www.blogger.com/profile/06607831852417429737</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>149</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-26554202.post-7838667208796008824</id><published>2021-03-24T15:42:00.004+07:00</published><updated>2021-03-24T15:42:38.650+07:00</updated><title type='text'>hi..it&#39;s me :D</title><content type='html'>&lt;p&gt;&amp;nbsp;it&#39;s been a long time since my last post&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;i will try to blog again in my journey&lt;/p&gt;&lt;p&gt;the journey paths will be in: Blazor, IIS, Crystal Report, SAP Business One, ClickOnce, Nuget, SQL Server Query.&lt;/p&gt;&lt;p&gt;most will be using MS tech of course&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;until then&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://erickwidya.blogspot.com/feeds/7838667208796008824/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/26554202/7838667208796008824' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/7838667208796008824'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/7838667208796008824'/><link rel='alternate' type='text/html' href='http://erickwidya.blogspot.com/2021/03/hiits-me-d.html' title='hi..it&#39;s me :D'/><author><name>eRiCk</name><uri>http://www.blogger.com/profile/06607831852417429737</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-26554202.post-1578892153285716153</id><published>2017-08-02T09:49:00.002+07:00</published><updated>2017-08-02T09:49:50.647+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="MSSQL"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server"/><title type='text'>SQL SERVER – FIX : ERROR : (provider: Named Pipes Provider, error: 40 – Could not open a connection to SQL Server)</title><content type='html'>Hi all,&lt;br /&gt;
&lt;br /&gt;
Found another repeating issue regarding unable to connect to network SQL Server&lt;br /&gt;
So here is the step by step i made&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Enable TCP /IP in SQL Server Configuration Manager&lt;/li&gt;
&lt;li&gt;Open Port in Window Firewall&lt;/li&gt;
&lt;li&gt;Enable Allow remote connections to this server in SQL Server&lt;/li&gt;
&lt;li&gt;Enable SQL Server Browser Service&amp;nbsp;&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
for step by step with Image please check this &lt;a href=&quot;https://blog.sqlauthority.com/2009/05/21/sql-server-fix-error-provider-named-pipes-provider-error-40-could-not-open-a-connection-to-sql-server-microsoft-sql-server-error/&quot; target=&quot;_blank&quot;&gt;link&lt;/a&gt;. Credit goes to &lt;b&gt;Pinal Dave&lt;/b&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://erickwidya.blogspot.com/feeds/1578892153285716153/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/26554202/1578892153285716153' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/1578892153285716153'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/1578892153285716153'/><link rel='alternate' type='text/html' href='http://erickwidya.blogspot.com/2017/08/sql-server-fix-error-provider-named.html' title='SQL SERVER – FIX : ERROR : (provider: Named Pipes Provider, error: 40 – Could not open a connection to SQL Server)'/><author><name>eRiCk</name><uri>http://www.blogger.com/profile/06607831852417429737</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-26554202.post-5171432292492404280</id><published>2017-06-26T16:30:00.003+07:00</published><updated>2017-06-26T16:31:01.061+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="MVC"/><category scheme="http://www.blogger.com/atom/ns#" term="some code"/><category scheme="http://www.blogger.com/atom/ns#" term="the Web"/><category scheme="http://www.blogger.com/atom/ns#" term="Web API"/><title type='text'>Value cannot be null when trying to get WebAPI Token using Postman</title><content type='html'>Well,&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;h1 style=&quot;background: rgb(255, 251, 233); border: 0px; color: #222222; font-family: &amp;quot;Segoe UI Light&amp;quot;, &amp;quot;Segoe UI&amp;quot;, Tahoma, Arial, Helvetica, sans-serif; font-size: 36px; font-weight: normal; line-height: 1.4em; margin: 0px 0px 13px; outline: 0px; padding: 0px; position: relative; vertical-align: baseline; z-index: 1;&quot;&gt;
Server Error in &#39;/&#39; Application.&lt;/h1&gt;
&lt;hr color=&quot;silver&quot; size=&quot;1&quot; style=&quot;color: #222222; font-family: &amp;quot;Segoe UI&amp;quot;, Tahoma, Arial, Helvetica, sans-serif; font-size: 13.008px;&quot; width=&quot;100%&quot; /&gt;
&lt;h2 style=&quot;background: rgb(255, 251, 233); border: 0px; color: #222222; font-family: &amp;quot;Segoe UI&amp;quot;, Tahoma, Arial, Helvetica, sans-serif; font-size: 18px; font-weight: normal; line-height: 1.4em; margin: 0px 0px 13px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;i style=&quot;background: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Value cannot be null.&lt;br /&gt;Parameter name: value&lt;/i&gt;&lt;/h2&gt;
&lt;div style=&quot;background: rgb(255, 251, 233); border: 0px; color: #222222; font-family: &amp;quot;Segoe UI&amp;quot;, Tahoma, Arial, Helvetica, sans-serif; font-size: 13.008px; margin-bottom: 18px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;background: transparent; border: 0px; font-size: 13.008px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;background: transparent; border: 0px; font-family: Arial, Helvetica, Geneva, SunSans-Regular, sans-serif; font-size: 13.008px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;b style=&quot;background: transparent; border: 0px; font-size: 13.008px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Description:&amp;nbsp;&lt;/b&gt;An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.&lt;br /&gt;&lt;br /&gt;&lt;b style=&quot;background: transparent; border: 0px; font-size: 13.008px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Exception Details:&amp;nbsp;&lt;/b&gt;System.ArgumentNullException: Value cannot be null.&lt;br /&gt;Parameter name: value&lt;br /&gt;&lt;br /&gt;&lt;b style=&quot;background: transparent; border: 0px; font-size: 13.008px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Source Error:&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;table bgcolor=&quot;#ffffcc&quot; style=&quot;background: rgb(255, 251, 233); border-collapse: collapse; border-spacing: 0px; border: 0px; color: #222222; font-family: &amp;quot;Segoe UI&amp;quot;, Tahoma, Arial, Helvetica, sans-serif; font-size: 13.008px; margin: 0px 0px 18px; outline: 0px; padding: 0px; vertical-align: baseline; width: 100%px;&quot;&gt;&lt;tbody style=&quot;background: transparent; border: 0px; font-size: 13.008px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;tr style=&quot;background: transparent; border: 0px; font-size: 13.008px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;td style=&quot;background: transparent; border: 0px; font-size: 13.008px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;pre style=&quot;background: rgb(255, 255, 255); border: 1px solid rgb(225, 226, 226); font-family: Consolas, monospace; font-size: 13.008px; margin-bottom: 30px; margin-top: 18px; outline: 0px; overflow: auto; padding: 5px; vertical-align: baseline;&quot;&gt;Line 431:        {
Line 432:            AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie);
&lt;span style=&quot;background: transparent; border: 0px; color: red; font-size: 13.008px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Line 433:            var identity = await UserManager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie);
&lt;/span&gt;Line 434:            AuthenticationManager.SignIn(new AuthenticationProperties() { IsPersistent = isPersistent }, identity);
Line 435: &lt;/pre&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/blockquote&gt;
It happened because when i created the user using Configuration Seed (i&#39;m using EF Code First), i&#39;m not filled the Security Stamp that is why the error occured because when the Security Stamp is null, it can not generate Claims Identity&lt;br /&gt;
&lt;br /&gt;
After i change the Seed to fill the Security Stamp then it works like a charm :D&lt;br /&gt;
&lt;br /&gt;
until then</content><link rel='replies' type='application/atom+xml' href='http://erickwidya.blogspot.com/feeds/5171432292492404280/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/26554202/5171432292492404280' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/5171432292492404280'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/5171432292492404280'/><link rel='alternate' type='text/html' href='http://erickwidya.blogspot.com/2017/06/value-cannot-be-null-when-trying-to-get.html' title='Value cannot be null when trying to get WebAPI Token using Postman'/><author><name>eRiCk</name><uri>http://www.blogger.com/profile/06607831852417429737</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-26554202.post-4774891191712445634</id><published>2017-06-20T10:27:00.002+07:00</published><updated>2017-08-02T09:42:27.997+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="IIS"/><category scheme="http://www.blogger.com/atom/ns#" term="timeout"/><title type='text'>Session timeout problem in IIS</title><content type='html'>Hi,&lt;br /&gt;
&lt;br /&gt;
Long time no post, i will try to post again since i came out searching a typical solution over and over again :D&lt;br /&gt;
&lt;br /&gt;
Now i&#39;m gonna post about session. Since i got this from other link so here it is&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;div style=&quot;background-color: white; box-sizing: inherit; color: #444444; font-family: Ubuntu, sans-serif; font-size: 18px; margin-bottom: 1.1em; margin-top: 1em;&quot;&gt;
So I started looking into the IIS settings and came to know that i missed two things to change :&lt;/div&gt;
&lt;ol style=&quot;background-color: white; box-sizing: inherit; color: #444444; font-family: Ubuntu, sans-serif; font-size: 18px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 1.5em; padding: 0px 0px 0px 1.2em;&quot;&gt;
&lt;li style=&quot;box-sizing: inherit;&quot;&gt;&lt;strong style=&quot;box-sizing: inherit;&quot;&gt;Application pool’s Idle Time-out&lt;/strong&gt;(minutes)&lt;/li&gt;
&lt;li style=&quot;box-sizing: inherit;&quot;&gt;&lt;strong style=&quot;box-sizing: inherit;&quot;&gt;Session state&lt;/strong&gt;&amp;nbsp;– State server’s Time-out (seconds)&lt;/li&gt;
&lt;/ol&gt;
&lt;div style=&quot;background-color: white; box-sizing: inherit; color: #444444; font-family: Ubuntu, sans-serif; font-size: 18px; margin-bottom: 1.1em; margin-top: 1em;&quot;&gt;
Once I have changed above settings than after Session timeout worked.&lt;/div&gt;
&lt;div style=&quot;background-color: white; box-sizing: inherit; color: #444444; font-family: Ubuntu, sans-serif; font-size: 18px; margin-bottom: 1.1em; margin-top: 1em;&quot;&gt;
So after that I have made one checklist that can help us to validate Session timeout settings, here i am sharing it with you as well so that you will also get some benefits from it :&lt;/div&gt;
&lt;ol style=&quot;background-color: white; box-sizing: inherit; color: #444444; font-family: Ubuntu, sans-serif; font-size: 18px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 1.5em; padding: 0px 0px 0px 1.2em;&quot;&gt;
&lt;li style=&quot;box-sizing: inherit;&quot;&gt;&lt;strong style=&quot;box-sizing: inherit;&quot;&gt;Application Pool&lt;/strong&gt;&amp;nbsp;– Advanced Settings Menu – Process Model – Idle Time-out (minutes)&lt;/li&gt;
&lt;li style=&quot;box-sizing: inherit;&quot;&gt;Sites –&amp;nbsp;&lt;strong style=&quot;box-sizing: inherit;&quot;&gt;Session State&lt;/strong&gt;&amp;nbsp;– Cookie Settings – Time-out (minutes)&lt;/li&gt;
&lt;li style=&quot;box-sizing: inherit;&quot;&gt;If you are using&amp;nbsp;&lt;strong style=&quot;box-sizing: inherit;&quot;&gt;State Server&lt;/strong&gt;&amp;nbsp;or&amp;nbsp;&lt;strong style=&quot;box-sizing: inherit;&quot;&gt;SQL Server&lt;/strong&gt;&amp;nbsp;to manage your session (instead of InProcess), Here is the steps to follow :&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Sites – Session State – Session State Mode Settings – Time-out (seconds)&lt;/li&gt;
&lt;li style=&quot;box-sizing: inherit;&quot;&gt;Under&amp;nbsp;&lt;strong style=&quot;box-sizing: inherit;&quot;&gt;Web.config&lt;/strong&gt;&amp;nbsp;–&amp;nbsp;&lt;span class=&quot;skimlinks-unlinked&quot; style=&quot;box-sizing: inherit;&quot;&gt;system.web&lt;/span&gt;&amp;nbsp;– authentication mode – forms – timeout (for form authentication)&lt;/li&gt;
&lt;/ol&gt;
&lt;div style=&quot;background-color: white; box-sizing: inherit; color: #444444; font-family: Ubuntu, sans-serif; font-size: 18px; margin-bottom: 1.1em; margin-top: 1em;&quot;&gt;
That is all , no more things you need to set in order to increase session timeout from its default value.&lt;/div&gt;
&lt;div style=&quot;background-color: white; box-sizing: inherit; color: #444444; font-family: Ubuntu, sans-serif; font-size: 18px; margin-bottom: 1.1em; margin-top: 1em;&quot;&gt;
Simple but very useful tips.&lt;/div&gt;
&lt;/blockquote&gt;
thanks for sharing it. Credit goes to&amp;nbsp;&lt;a href=&quot;https://ramanisandeep.wordpress.com/2011/03/19/tipstrick-session-timeout-problem-in-iis7/&quot; target=&quot;_blank&quot;&gt;Jay Ganesh&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://erickwidya.blogspot.com/feeds/4774891191712445634/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/26554202/4774891191712445634' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/4774891191712445634'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/4774891191712445634'/><link rel='alternate' type='text/html' href='http://erickwidya.blogspot.com/2017/06/session-timeout-problem-in-iis.html' title='Session timeout problem in IIS'/><author><name>eRiCk</name><uri>http://www.blogger.com/profile/06607831852417429737</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-26554202.post-7428138715328199422</id><published>2015-10-23T09:38:00.001+07:00</published><updated>2015-10-23T09:38:22.226+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="sharing"/><category scheme="http://www.blogger.com/atom/ns#" term="some code"/><title type='text'>Dropdown List from object List in MVC View</title><content type='html'>In previous months, i have opportunity to play along with MVC after a while using EF Code First and MVC 5.&lt;br /&gt;
&lt;br /&gt;
So today the snippet about creating DropdownList from object List rather than List of SelectListItem &lt;br /&gt;
&lt;br /&gt;
let&#39;s say u have this Company Class&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
[Key]&lt;br /&gt;
public int CompanyId { get; set; }&lt;br /&gt;
public string Name { get; set; }&lt;br /&gt;
public string Code { get; set; }&lt;/blockquote&gt;
&lt;br /&gt;
and u want to display dropdown list based on Code as Text and Id as Value&lt;br /&gt;
in the View u create a SelectList based on that field&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;
&lt;div class=&quot;form-group&quot;&gt;
@Html.LabelFor(model =&amp;gt; model.Brand.Company, htmlAttributes: new { @class = &quot;control-label col-md-2&quot; })&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;
@Html.DropDownList(&quot;selectedCompany&quot;, Model.Companies.Select(_ =&amp;gt; new SelectListItem&lt;br /&gt;
{&lt;br /&gt;
Text = _.Code,&lt;br /&gt;
Value = _.CompanyId.ToString(),&lt;br /&gt;
Selected = _.CompanyId.ToString() == Model.Brand.Company.CompanyId.ToString()&lt;br /&gt;
})&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
)&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/blockquote&gt;
&lt;br /&gt;
the Model is a simple ViewModel that have Brands and Brand object&lt;br /&gt;
&lt;br /&gt;
sorry for the format, can not make it right :D&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://erickwidya.blogspot.com/feeds/7428138715328199422/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/26554202/7428138715328199422' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/7428138715328199422'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/7428138715328199422'/><link rel='alternate' type='text/html' href='http://erickwidya.blogspot.com/2015/10/dropdown-list-from-object-list-in-mvc.html' title='Dropdown List from object List in MVC View'/><author><name>eRiCk</name><uri>http://www.blogger.com/profile/06607831852417429737</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-26554202.post-532227989300924081</id><published>2014-12-19T12:54:00.002+07:00</published><updated>2014-12-19T13:25:46.140+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="sharing"/><category scheme="http://www.blogger.com/atom/ns#" term="some code"/><title type='text'>sp_msforeachtable - Quick counting table rows</title><content type='html'>i just starting to play along with SSIS and SSAS&lt;br /&gt;
and i came up with this trick to show wether my data has been populate into staging or data warehouse table&lt;br /&gt;
&lt;br /&gt;
so here is the script&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
EXEC sp_MSForEachTable &quot;&lt;br /&gt;
DECLARE @count AS INT SET @count=0&lt;br /&gt;
SELECT @count = ISNULL(SUM(1), 0) FROM ?&lt;br /&gt;
PRINT &quot;&quot;?: &quot;&quot; + CONVERT(VARCHAR, @Count)&lt;br /&gt;
, @whereand = &quot;ORDER BY 1&quot;
&quot;&amp;nbsp;&lt;/blockquote&gt;
&lt;/blockquote&gt;
until then</content><link rel='replies' type='application/atom+xml' href='http://erickwidya.blogspot.com/feeds/532227989300924081/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/26554202/532227989300924081' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/532227989300924081'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/532227989300924081'/><link rel='alternate' type='text/html' href='http://erickwidya.blogspot.com/2014/12/spmsforeachtable-quick-count-table-rows.html' title='sp_msforeachtable - Quick counting table rows'/><author><name>eRiCk</name><uri>http://www.blogger.com/profile/06607831852417429737</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-26554202.post-3802404580247442047</id><published>2014-12-05T15:52:00.001+07:00</published><updated>2014-12-19T12:52:16.957+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="sharing"/><category scheme="http://www.blogger.com/atom/ns#" term="some code"/><title type='text'>sp_msforeachtable  - Delete data in all tables in SQL Server database</title><content type='html'>hi all, just remember to post this useful tips&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- disable all constraints&lt;br /&gt;
EXEC sp_msforeachtable &quot;ALTER TABLE ? NOCHECK CONSTRAINT all&quot;&lt;br /&gt;
&lt;br /&gt;
-- delete data in all tables&lt;br /&gt;
EXEC sp_MSForEachTable &quot;DELETE FROM ?&quot;&lt;br /&gt;
&lt;br /&gt;
-- enable all constraints&lt;br /&gt;
exec sp_msforeachtable &quot;ALTER TABLE ? WITH CHECK CHECK CONSTRAINT all&quot;&lt;br /&gt;
&lt;br /&gt;
--if some of the tables have identity columns we may want to reseed them&lt;br /&gt;
EXEC sp_MSforeachtable &quot;DBCC CHECKIDENT ( &#39;?&#39;, RESEED, 0)&quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
see u then</content><link rel='replies' type='application/atom+xml' href='http://erickwidya.blogspot.com/feeds/3802404580247442047/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/26554202/3802404580247442047' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/3802404580247442047'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/3802404580247442047'/><link rel='alternate' type='text/html' href='http://erickwidya.blogspot.com/2014/12/delete-data-in-all-tables-in-sql-server.html' title='sp_msforeachtable  - Delete data in all tables in SQL Server database'/><author><name>eRiCk</name><uri>http://www.blogger.com/profile/06607831852417429737</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-26554202.post-2594500991406114315</id><published>2014-06-23T09:31:00.002+07:00</published><updated>2014-12-19T12:52:27.624+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="sharing"/><category scheme="http://www.blogger.com/atom/ns#" term="some code"/><title type='text'>sp_MsForEachTable - compare data between tables</title><content type='html'>usually i will using temporary table to build dynamic query to compare the value for two indentical database between two servers&lt;br /&gt;
&lt;br /&gt;
but few weeks ago i know undocumented sp_msforeachtable stored procedure and gain some advantage for using it&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
exec sp_MSforeachtable&amp;nbsp;&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
@command1 = &#39;&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;IF EXISTS(&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;SELECT top 1 * FROM [server2].db_name.?&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;EXCEPT&amp;nbsp;&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;SELECT top 1 * FROM ? &amp;nbsp;&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;)&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;PRINT &#39;&#39;?&#39;&#39;&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&#39;&lt;/blockquote&gt;
&lt;/blockquote&gt;
just make sure u use &quot;.&quot; in first syntax because sp_msforeachtable return &quot;dbo.table_name&quot;&lt;br /&gt;
&lt;br /&gt;
for parameters reference please see this &lt;a href=&quot;http://www.databasejournal.com/features/mssql/article.php/3441031/SQL-Server-Undocumented-Stored-Procedures-spMSforeachtable-and-spMSforeachdb.htm&quot; target=&quot;_blank&quot;&gt;link&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
see u</content><link rel='replies' type='application/atom+xml' href='http://erickwidya.blogspot.com/feeds/2594500991406114315/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/26554202/2594500991406114315' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/2594500991406114315'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/2594500991406114315'/><link rel='alternate' type='text/html' href='http://erickwidya.blogspot.com/2014/06/spmsforeachtable-to-compare-data.html' title='sp_MsForEachTable - compare data between tables'/><author><name>eRiCk</name><uri>http://www.blogger.com/profile/06607831852417429737</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-26554202.post-4317069088851082281</id><published>2014-06-20T09:16:00.001+07:00</published><updated>2014-06-20T09:27:14.549+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="sharing"/><title type='text'>Scheduled ClickOnce Application in Windows Task Scheduler </title><content type='html'>it can :D&lt;br /&gt;
u have to publish it to iis i think, not testing when publish it using ftp&lt;br /&gt;
&lt;br /&gt;
just add this line&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&quot;C:\Program Files\Internet Explorer\iexplore.exe&quot; http://yoururltoapplication/applicationname&lt;span style=&quot;color: red; font-weight: bold;&quot;&gt;.application&lt;/span&gt;&lt;/div&gt;
&lt;/blockquote&gt;
&lt;br /&gt;
just make sure u put the red word at behind&lt;br /&gt;
&lt;br /&gt;
until then</content><link rel='replies' type='application/atom+xml' href='http://erickwidya.blogspot.com/feeds/4317069088851082281/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/26554202/4317069088851082281' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/4317069088851082281'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/4317069088851082281'/><link rel='alternate' type='text/html' href='http://erickwidya.blogspot.com/2014/06/scheduled-clickonce-application-in.html' title='Scheduled ClickOnce Application in Windows Task Scheduler '/><author><name>eRiCk</name><uri>http://www.blogger.com/profile/06607831852417429737</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-26554202.post-4102852006425589992</id><published>2014-06-18T16:38:00.001+07:00</published><updated>2014-06-18T16:38:03.993+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="sharing"/><category scheme="http://www.blogger.com/atom/ns#" term="some code"/><title type='text'>create ClickOnce shortcut at Startup</title><content type='html'>currently there are needs to add some shortcut based on ClickOnce Application that being deployed,&lt;br /&gt;
it&#39;s obvious we can&#39;t create it manually because of the installation path&lt;br /&gt;
&lt;br /&gt;
here is some remedy :D, u need to add reference to System.Deployment, System.IO, &amp;nbsp;System.Reflection&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;br /&gt;
&amp;nbsp;if (ApplicationDeployment.IsNetworkDeployed)&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;string publisherName = ((AssemblyCompanyAttribute)Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(),&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;typeof(AssemblyCompanyAttribute), false)).Company;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;string productName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;string startupPath = Environment.GetFolderPath(Environment.SpecialFolder.Startup);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;startupPath = Path.Combine(startupPath, productName) + &quot;.appref-ms&quot;;&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 (!File.Exists(startupPath))&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;string allProgramsPath = Environment.GetFolderPath(Environment.SpecialFolder.Programs);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;string shortcutPath = Path.Combine(allProgramsPath, publisherName);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;shortcutPath = Path.Combine(shortcutPath, productName) + &quot;.appref-ms&quot;;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;File.Copy(shortcutPath, startupPath);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;span 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;}&lt;/blockquote&gt;
&lt;br /&gt;
until then</content><link rel='replies' type='application/atom+xml' href='http://erickwidya.blogspot.com/feeds/4102852006425589992/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/26554202/4102852006425589992' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/4102852006425589992'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/4102852006425589992'/><link rel='alternate' type='text/html' href='http://erickwidya.blogspot.com/2014/06/create-clickonce-shortcut-at-startup.html' title='create ClickOnce shortcut at Startup'/><author><name>eRiCk</name><uri>http://www.blogger.com/profile/06607831852417429737</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-26554202.post-5538274805657578415</id><published>2014-06-17T09:13:00.003+07:00</published><updated>2014-06-17T13:00:01.105+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="sharing"/><title type='text'>Monitoring Table Size Growth in SQL Server</title><content type='html'>if u plan to check how much your database growth then u might need this script from&amp;nbsp;&lt;a href=&quot;http://www.sql-server-performance.com/2014/monitor-data-growth/&quot; target=&quot;_blank&quot;&gt;Yaniv Etrogi&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
it writes the growth to database so u can check it againts database threshold that u define&lt;br /&gt;
best of it: all the scripts already provided :D&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
until then</content><link rel='replies' type='application/atom+xml' href='http://erickwidya.blogspot.com/feeds/5538274805657578415/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/26554202/5538274805657578415' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/5538274805657578415'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/5538274805657578415'/><link rel='alternate' type='text/html' href='http://erickwidya.blogspot.com/2014/06/monitoring-table-size-growth-in-sql.html' title='Monitoring Table Size Growth in SQL Server'/><author><name>eRiCk</name><uri>http://www.blogger.com/profile/06607831852417429737</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-26554202.post-5094546140196895914</id><published>2014-06-17T08:16:00.003+07:00</published><updated>2014-06-17T09:11:04.797+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="some code"/><title type='text'>Find all Database size in SQL Server</title><content type='html'>hi, just came across a very good script from &lt;a href=&quot;http://blog.sqlauthority.com/2010/11/12/sql-server-get-all-the-information-of-database-using-sys-databases/&quot; target=&quot;_blank&quot;&gt;Pinal Dave&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
u can see all database information in one place&lt;br /&gt;
here the script&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
SELECT database_id,&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
CONVERT(VARCHAR(25), DB.name) AS dbName,&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
CONVERT(VARCHAR(10), DATABASEPROPERTYEX(name, &#39;status&#39;)) AS [Status],&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
state_desc,&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
(SELECT COUNT(1) FROM sys.master_files WHERE DB_NAME(database_id) = DB.name AND type_desc = &#39;rows&#39;) AS DataFiles,&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
(SELECT SUM((size*8)/1024) FROM sys.master_files WHERE DB_NAME(database_id) = DB.name AND type_desc = &#39;rows&#39;) AS [Data MB],&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
(SELECT COUNT(1) FROM sys.master_files WHERE DB_NAME(database_id) = DB.name AND type_desc = &#39;log&#39;) AS LogFiles,&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
(SELECT SUM((size*8)/1024) FROM sys.master_files WHERE DB_NAME(database_id) = DB.name AND type_desc = &#39;log&#39;) AS [Log MB],&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
user_access_desc AS [User access],&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
recovery_model_desc AS [Recovery model],&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
CASE compatibility_level&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
WHEN 60 THEN &#39;60 (SQL Server 6.0)&#39;&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
WHEN 65 THEN &#39;65 (SQL Server 6.5)&#39;&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
WHEN 70 THEN &#39;70 (SQL Server 7.0)&#39;&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
WHEN 80 THEN &#39;80 (SQL Server 2000)&#39;&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
WHEN 90 THEN &#39;90 (SQL Server 2005)&#39;&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
WHEN 100 THEN &#39;100 (SQL Server 2008)&#39;&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
END AS [compatibility level],&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
CONVERT(VARCHAR(20), create_date, 103) + &#39; &#39; + CONVERT(VARCHAR(20), create_date, 108) AS [Creation date],&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
-- last backup&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
ISNULL((SELECT TOP 1&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
CASE TYPE WHEN &#39;D&#39; THEN &#39;Full&#39; WHEN &#39;I&#39; THEN &#39;Differential&#39; WHEN &#39;L&#39; THEN &#39;Transaction log&#39; END + &#39; – &#39; +&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
LTRIM(ISNULL(STR(ABS(DATEDIFF(DAY, GETDATE(),Backup_finish_date))) + &#39; days ago&#39;, &#39;NEVER&#39;)) + &#39; – &#39; +&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
CONVERT(VARCHAR(20), backup_start_date, 103) + &#39; &#39; + CONVERT(VARCHAR(20), backup_start_date, 108) + &#39; – &#39; +&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
CONVERT(VARCHAR(20), backup_finish_date, 103) + &#39; &#39; + CONVERT(VARCHAR(20), backup_finish_date, 108) +&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&#39; (&#39; + CAST(DATEDIFF(second, BK.backup_start_date,&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
BK.backup_finish_date) AS VARCHAR(4)) + &#39; &#39;&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
+ &#39;seconds)&#39;&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
FROM msdb..backupset BK WHERE BK.database_name = DB.name ORDER BY backup_set_id DESC),&#39;-&#39;) AS [Last backup],&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
CASE WHEN is_fulltext_enabled = 1 THEN &#39;Fulltext enabled&#39; ELSE &#39;&#39; END AS [fulltext],&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
CASE WHEN is_auto_close_on = 1 THEN &#39;autoclose&#39; ELSE &#39;&#39; END AS [autoclose],&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
page_verify_option_desc AS [page verify option],&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
CASE WHEN is_read_only = 1 THEN &#39;read only&#39; ELSE &#39;&#39; END AS [read only],&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
CASE WHEN is_auto_shrink_on = 1 THEN &#39;autoshrink&#39; ELSE &#39;&#39; END AS [autoshrink],&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
CASE WHEN is_auto_create_stats_on = 1 THEN &#39;auto create statistics&#39; ELSE &#39;&#39; END AS [auto create statistics],&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
CASE WHEN is_auto_update_stats_on = 1 THEN &#39;auto update statistics&#39; ELSE &#39;&#39; END AS [auto update statistics],&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
CASE WHEN is_in_standby = 1 THEN &#39;standby&#39; ELSE &#39;&#39; END AS [standby],&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
CASE WHEN is_cleanly_shutdown = 1 THEN &#39;cleanly shutdown&#39; ELSE &#39;&#39; END AS [cleanly shutdown]&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
FROM sys.databases DB&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
ORDER BY dbName, [Last backup] DESC, NAME&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;br /&gt;
until then</content><link rel='replies' type='application/atom+xml' href='http://erickwidya.blogspot.com/feeds/5094546140196895914/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/26554202/5094546140196895914' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/5094546140196895914'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/5094546140196895914'/><link rel='alternate' type='text/html' href='http://erickwidya.blogspot.com/2014/06/find-all-database-size-in-sql-server.html' title='Find all Database size in SQL Server'/><author><name>eRiCk</name><uri>http://www.blogger.com/profile/06607831852417429737</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-26554202.post-8860201051873013105</id><published>2014-05-06T10:15:00.001+07:00</published><updated>2014-05-06T10:16:42.847+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="sharing"/><title type='text'>Force Application update in ClickOnce deployment</title><content type='html'>the key is to set minimum requirement version to be exactly like the one u published right now to remove the update popup dialog when starting clickonce program&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7_rFAf1vYJqrk0jj-4PVXuPs62aR1MgGkb46BLxIVMxVIWrSodcwMc4l4TuefNFVRiQrDWGRNJeej10Bq1Aob9ZrX2ulb6I3OQo6TYXSLDgIPhn41IgaBiePmSXSAsMYSzfpL/s1600/3.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7_rFAf1vYJqrk0jj-4PVXuPs62aR1MgGkb46BLxIVMxVIWrSodcwMc4l4TuefNFVRiQrDWGRNJeej10Bq1Aob9ZrX2ulb6I3OQo6TYXSLDgIPhn41IgaBiePmSXSAsMYSzfpL/s1600/3.png&quot; height=&quot;138&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
just make sure the version is the same between Publish version and Update the Project properties - Publish&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOBzWM1fvdZXSeT-kfOUOvc_FwL5r00HXSg2NZeVsLity77VkUZTb3jZZlQUn6Tx-lnIBaHm9lcNhtJH140OoFEVf3E-enOSJSAZfmsR4k3JDQ_w4TXNjtsk1zW5hWRpajHqsC/s1600/1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOBzWM1fvdZXSeT-kfOUOvc_FwL5r00HXSg2NZeVsLity77VkUZTb3jZZlQUn6Tx-lnIBaHm9lcNhtJH140OoFEVf3E-enOSJSAZfmsR4k3JDQ_w4TXNjtsk1zW5hWRpajHqsC/s1600/1.png&quot; height=&quot;155&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKqYJThCdE1KV1fdDe88_P8d5gmqPq5WBBNHckie5W7s1JM6tCpOSXrCxVTz7heyLXQHgf9tRzS043y7doX6em732m1lg0W1qerWB9BrgzOqlujcGKfC4Wg_x8buvJMbfiLKPJ/s1600/2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKqYJThCdE1KV1fdDe88_P8d5gmqPq5WBBNHckie5W7s1JM6tCpOSXrCxVTz7heyLXQHgf9tRzS043y7doX6em732m1lg0W1qerWB9BrgzOqlujcGKfC4Wg_x8buvJMbfiLKPJ/s1600/2.png&quot; height=&quot;283&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
until then</content><link rel='replies' type='application/atom+xml' href='http://erickwidya.blogspot.com/feeds/8860201051873013105/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/26554202/8860201051873013105' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/8860201051873013105'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/8860201051873013105'/><link rel='alternate' type='text/html' href='http://erickwidya.blogspot.com/2014/05/force-application-update-in-clickonce.html' title='Force Application update in ClickOnce deployment'/><author><name>eRiCk</name><uri>http://www.blogger.com/profile/06607831852417429737</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><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7_rFAf1vYJqrk0jj-4PVXuPs62aR1MgGkb46BLxIVMxVIWrSodcwMc4l4TuefNFVRiQrDWGRNJeej10Bq1Aob9ZrX2ulb6I3OQo6TYXSLDgIPhn41IgaBiePmSXSAsMYSzfpL/s72-c/3.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-26554202.post-5063632687153528862</id><published>2014-04-30T08:27:00.000+07:00</published><updated>2014-04-30T08:27:31.854+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="sharing"/><category scheme="http://www.blogger.com/atom/ns#" term="some code"/><title type='text'>WCF: The underlying connection was closed </title><content type='html'>hi,&lt;br /&gt;
&lt;br /&gt;
just got an error for couple of days when try to return a model contain child record using Entity Framework&lt;br /&gt;
and DBContext&lt;br /&gt;
&lt;br /&gt;
i have this Role class that contain list of User within that Role&lt;br /&gt;
so when i try to get specific Role along with the User it give me an error &quot;The underlying connection was closed &quot;&lt;br /&gt;
&lt;br /&gt;
after searching alot i came up with this great solution disabled proxy creation and lazy loading&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSe7XbtkitFvtDKtPFQSJMn6lyzl0NITaonPPEW7CpD-Jv7a26gIvxtM9AwTI1-z8o1Ijxtgs164KSm5DItvcfDON2wOdOk8okFWLkXPt5eKR7j4HuTZ3ZTM4nTO0kvuMWJHJr/s1600/1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSe7XbtkitFvtDKtPFQSJMn6lyzl0NITaonPPEW7CpD-Jv7a26gIvxtM9AwTI1-z8o1Ijxtgs164KSm5DItvcfDON2wOdOk8okFWLkXPt5eKR7j4HuTZ3ZTM4nTO0kvuMWJHJr/s1600/1.png&quot; height=&quot;270&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
or &amp;nbsp;manually in Entity DBContext constructor&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwvOEedNZxf-kbzII-sNchHLrVF0I4vWg3e94axqaWOpKxOeSMM4qmFmTI-3LFnIkAmG3TB5UuIN82yWIILzjHRbNer0cXECvJjfzWFOd51z9eL5zkUcIBTd5yEgeIuF4PjUX5/s1600/1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwvOEedNZxf-kbzII-sNchHLrVF0I4vWg3e94axqaWOpKxOeSMM4qmFmTI-3LFnIkAmG3TB5UuIN82yWIILzjHRbNer0cXECvJjfzWFOd51z9eL5zkUcIBTd5yEgeIuF4PjUX5/s1600/1.png&quot; height=&quot;99&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
it run succesfully and can return UserInRole but if i filled up the table then the error comes, so we need to&amp;nbsp;&lt;a href=&quot;http://blogs.msdn.com/b/sowmy/archive/2006/03/26/561188.aspx&quot; target=&quot;_blank&quot;&gt;Preserving Object Reference in WCF&lt;/a&gt;&amp;nbsp;but i came with this very useful&amp;nbsp;&lt;a href=&quot;http://chabster.blogspot.com/2008/02/wcf-cyclic-references-support.html&quot; target=&quot;_blank&quot;&gt;Andrey Chabster Blog&lt;/a&gt;&amp;nbsp;that using custom attribute that needed for the Service contract and Operation contract&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
until then&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://erickwidya.blogspot.com/feeds/5063632687153528862/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/26554202/5063632687153528862' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/5063632687153528862'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/5063632687153528862'/><link rel='alternate' type='text/html' href='http://erickwidya.blogspot.com/2014/04/wcf-underlying-connection-was-closed.html' title='WCF: The underlying connection was closed '/><author><name>eRiCk</name><uri>http://www.blogger.com/profile/06607831852417429737</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><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSe7XbtkitFvtDKtPFQSJMn6lyzl0NITaonPPEW7CpD-Jv7a26gIvxtM9AwTI1-z8o1Ijxtgs164KSm5DItvcfDON2wOdOk8okFWLkXPt5eKR7j4HuTZ3ZTM4nTO0kvuMWJHJr/s72-c/1.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-26554202.post-3094602374990945531</id><published>2014-04-29T10:27:00.002+07:00</published><updated>2014-05-06T13:31:17.497+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="some code"/><title type='text'>The version of SQL Server in use does not support datatype datetime2</title><content type='html'>&lt;span style=&quot;font-family: Helvetica Neue, Arial, Helvetica, sans-serif;&quot;&gt;hi again,&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Helvetica Neue, Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Helvetica Neue, Arial, Helvetica, sans-serif;&quot;&gt;just came up with this error in Entity Framework&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Helvetica Neue, Arial, Helvetica, sans-serif;&quot;&gt;the reason is because my development using SQL2008 express edition but the preproduction using SQL2005&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Helvetica Neue, Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Helvetica Neue, Arial, Helvetica, sans-serif;&quot;&gt;and the solution is fairly simple&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-family: Helvetica Neue, Arial, Helvetica, sans-serif;&quot;&gt;Open your EDMX in a file editor (or “open with…” in Visual Studio and select XML Editor). At the top you will find the storage model and it has an attribute ProviderManifestToken. This has should have the value 2008. Change that to 2005, recompile and everything works&lt;/span&gt;&lt;/blockquote&gt;
&lt;span style=&quot;background-color: white; font-family: &#39;Helvetica Neue&#39;, Arial, Helvetica, sans-serif; font-size: 14px; line-height: 17.804800033569336px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Helvetica Neue, Arial, Helvetica, sans-serif;&quot;&gt;after trying up for 2 hours :D&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Helvetica Neue, Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Helvetica Neue, Arial, Helvetica, sans-serif;&quot;&gt;until then&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://erickwidya.blogspot.com/feeds/3094602374990945531/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/26554202/3094602374990945531' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/3094602374990945531'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/3094602374990945531'/><link rel='alternate' type='text/html' href='http://erickwidya.blogspot.com/2014/04/the-version-of-sql-server-in-use-does.html' title='The version of SQL Server in use does not support datatype datetime2'/><author><name>eRiCk</name><uri>http://www.blogger.com/profile/06607831852417429737</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-26554202.post-8449940679452987225</id><published>2014-03-03T08:38:00.000+07:00</published><updated>2014-05-06T13:41:09.085+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="some code"/><title type='text'>Renaming SQL Server Default Instance</title><content type='html'>hi all, found another intresting stuff to post&lt;br /&gt;
&lt;br /&gt;
scenario: u change windows computer name and suddenly the query that contains SQL Server link server or anything that currently connect to ur &quot;changed computer&quot; is not working&lt;br /&gt;
&lt;br /&gt;
try using this query in SSMS&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
-– Get the current name of the SQL Server instance for later comparison.&lt;br /&gt;
SELECT @@servername&lt;br /&gt;
–- Remove server from the list of known remote and linked servers on the local instance of SQL Server.&lt;br /&gt;
EXEC master.dbo.sp_dropserver ‘[SERVER NAME]‘&lt;br /&gt;
–- Define the name of the local instance of SQL Server.&lt;br /&gt;
EXEC master.dbo.sp_addserver ‘[NEW SERVER NAME]‘, ‘local’&lt;br /&gt;
–- Get the new name of the SQL Server instance for comparison.&lt;br /&gt;
SELECT @@servername&lt;/blockquote&gt;
&lt;br /&gt;
after try, u must restart sql server services...then check if the query is working now&lt;br /&gt;
&lt;br /&gt;
see u</content><link rel='replies' type='application/atom+xml' href='http://erickwidya.blogspot.com/feeds/8449940679452987225/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/26554202/8449940679452987225' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/8449940679452987225'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/8449940679452987225'/><link rel='alternate' type='text/html' href='http://erickwidya.blogspot.com/2014/03/renamin-sql-server-default-instance.html' title='Renaming SQL Server Default Instance'/><author><name>eRiCk</name><uri>http://www.blogger.com/profile/06607831852417429737</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-26554202.post-194192774611645847</id><published>2013-12-05T15:46:00.001+07:00</published><updated>2013-12-05T15:48:54.222+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="some code"/><title type='text'>Get Child and Parent from hierarchy Table using Common Table Expression (CTE) - SQL 2005 and above</title><content type='html'>hi, just want to post something that might be useful&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
DECLARE @a AS TABLE&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
(&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;autoid INT&amp;nbsp;&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;, name VARCHAR(20)&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;, parentid INT&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
)&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;br /&gt;&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
INSERT INTO @a (autoid, name, parentid)&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;br /&gt;&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
SELECT 1, &#39;1&#39;, 0&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
UNION ALL&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
SELECT 2, &#39;1.1&#39;, 1&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
UNION ALL&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
SELECT 3, &#39;1.2&#39;, 1&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
UNION ALL&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
SELECT 4, &#39;1.2.1&#39;, 3&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
UNION ALL&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
SELECT 5, &#39;2.1&#39;, 2&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
UNION ALL&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
SELECT 6, &#39;3.1&#39;, 3&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
UNION ALL&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
SELECT 7, &#39;3.2&#39;, 3&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;br /&gt;&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
/*&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
1&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;1&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;0&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
2&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;1.1&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;1&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
3&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;1.2&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;1&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
4&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;1.2.1&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;3&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
5&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;2.1&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;2&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
6&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;3.1&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;3&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
7&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;3.2&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;3&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
*/&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;br /&gt;&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
/*&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
Get Parent Records from child &#39;1.2.1&#39;&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
return:&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;1.2 (parent from &#39;1.2.1&#39;)&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;1 (parent from &#39;1.2&#39;)&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
*/&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
;WITH &amp;nbsp; &amp;nbsp;employeeMaster&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; AS ( SELECT &amp;nbsp; p.autoid ,&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; p.parentid ,&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; p.[name]&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;FROM &amp;nbsp; &amp;nbsp; @a p&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;WHERE &amp;nbsp; &amp;nbsp;p.[NAME] = &#39;1.2.1&#39;&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;UNION ALL&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;SELECT &amp;nbsp; c.autoid ,&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; c.parentid ,&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; c.[name]&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;FROM &amp;nbsp; &amp;nbsp; employeeMaster cte&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; INNER JOIN @a c ON c.autoid = cte.parentid&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;)&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;br /&gt;&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
SELECT &amp;nbsp;*&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
FROM &amp;nbsp; &amp;nbsp;employeeMaster m&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
WHERE m.[name] &amp;lt;&amp;gt; &amp;nbsp;&#39;1.2.1&#39;&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
/*&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
Get Child Records from parent &#39;1.2&#39;&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
return:&amp;nbsp;&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;1.2.1&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;3.1&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;3.2&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
*/&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
;WITH &amp;nbsp; &amp;nbsp;employeeMaster&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; AS ( SELECT &amp;nbsp; p.autoid ,&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; p.parentid ,&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; p.[name]&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;FROM &amp;nbsp; &amp;nbsp; @a p&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;WHERE &amp;nbsp; &amp;nbsp;p.[NAME] = &#39;1.2&#39;&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;UNION ALL&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;SELECT &amp;nbsp; c.autoid ,&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; c.parentid ,&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; c.[name]&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;FROM &amp;nbsp; &amp;nbsp; employeeMaster cte&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; INNER JOIN @a c ON c.parentid = cte.autoid&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;)&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;br /&gt;&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
SELECT &amp;nbsp;*&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
FROM &amp;nbsp; &amp;nbsp;employeeMaster m&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
WHERE m.[name] &amp;lt;&amp;gt; &amp;nbsp;&#39;1.2&#39;&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;br /&gt;
see u</content><link rel='replies' type='application/atom+xml' href='http://erickwidya.blogspot.com/feeds/194192774611645847/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/26554202/194192774611645847' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/194192774611645847'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/194192774611645847'/><link rel='alternate' type='text/html' href='http://erickwidya.blogspot.com/2013/12/get-child-and-parent-from-hierarchy.html' title='Get Child and Parent from hierarchy Table using Common Table Expression (CTE) - SQL 2005 and above'/><author><name>eRiCk</name><uri>http://www.blogger.com/profile/06607831852417429737</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-26554202.post-595911752492445704</id><published>2012-12-27T11:09:00.000+07:00</published><updated>2014-04-29T10:29:40.839+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="some code"/><title type='text'>Convert DATETIME to SMALLDATETIME</title><content type='html'>here is the script from my colleague if u want to convert DATETIME data type to SMALLDATETIME because simple CONVERT is not working&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;pre style=&quot;white-space: pre-wrap; word-wrap: break-word;&quot;&gt;SELECT CONVERT (SMALLDATETIME, CONVERT (VARCHAR, GETDATE(), 103), 103)&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;br /&gt;
until then</content><link rel='replies' type='application/atom+xml' href='http://erickwidya.blogspot.com/feeds/595911752492445704/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/26554202/595911752492445704' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/595911752492445704'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/595911752492445704'/><link rel='alternate' type='text/html' href='http://erickwidya.blogspot.com/2012/12/convert-datetime-to-smalldatetime.html' title='Convert DATETIME to SMALLDATETIME'/><author><name>eRiCk</name><uri>http://www.blogger.com/profile/06607831852417429737</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-26554202.post-4351182868114034637</id><published>2012-11-30T14:23:00.002+07:00</published><updated>2014-06-13T10:22:03.380+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="some code"/><title type='text'>Find size of SQL Server tables and other objects with stored procedure</title><content type='html'>my colleague needs a query to seek for all tables in certain Database then use it to display informati on such as: Created Date, Rows in that tables, etc&lt;br /&gt;
&lt;br /&gt;
at first i look over sp_spaceused but it end up wrapping query which is hard because undocumented and it failed :(&lt;br /&gt;
also considerations can be used for SQL 2000&lt;br /&gt;
&lt;br /&gt;
so i google it and found this &lt;a href=&quot;http://searchsqlserver.techtarget.com/tip/Find-size-of-SQL-Server-tables-and-other-objects-with-stored-procedure&quot; target=&quot;_blank&quot;&gt;link&lt;/a&gt;, it works for SQL 2000 and above&lt;br /&gt;
&lt;strike&gt;i tweak a bit to meet my requirement but &lt;/strike&gt;credit goes to&amp;nbsp;&lt;span style=&quot;font-family: Calibri, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 19.200000762939453px;&quot;&gt;&lt;b&gt;Richard Ding&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;b style=&quot;background-color: white; font-family: Calibri, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 19.200000762939453px;&quot;&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
here is the query that i used&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
USE master;&lt;br /&gt;
GO&lt;br /&gt;
&lt;br /&gt;
IF OBJECT_ID(N&#39;dbo.sp_SOS&#39;, N&#39;P&#39;) IS NOT NULL&lt;br /&gt;
&amp;nbsp; DROP PROCEDURE dbo.sp_SOS;&lt;br /&gt;
GO&lt;br /&gt;
&lt;br /&gt;
CREATE PROCEDURE dbo.sp_SOS&lt;br /&gt;
&amp;nbsp; @DbName sysname = NULL, &lt;br /&gt;
&amp;nbsp; @SchemaName sysname = NULL, &lt;br /&gt;
&amp;nbsp; @ObjectName sysname = N&#39;%&#39;, &lt;br /&gt;
&amp;nbsp; @TopClause nvarchar(20) = NULL,&lt;br /&gt;
&amp;nbsp; @ObjectType nvarchar(50) = NULL, &lt;br /&gt;
&amp;nbsp; @ShowInternalTable nvarchar(3) = NULL,&lt;br /&gt;
&amp;nbsp; @OrderBy nvarchar(100) = NULL, &lt;br /&gt;
&amp;nbsp; @UpdateUsage bit = 0&lt;br /&gt;
AS&lt;br /&gt;
&lt;br /&gt;
/*=================================================================================================&lt;br /&gt;
&lt;br /&gt;
Author: &amp;nbsp; &amp;nbsp; Richard Ding&lt;br /&gt;
&lt;br /&gt;
Created: &amp;nbsp; &amp;nbsp;Mar. 03, 2008&lt;br /&gt;
&lt;br /&gt;
Modified: &amp;nbsp; Mar. 17, 2008&lt;br /&gt;
&lt;br /&gt;
Purpose: &amp;nbsp; &amp;nbsp;Manipulate object size calculation and display for SS 2000/2005/2008&lt;br /&gt;
&lt;br /&gt;
Parameters:&lt;br /&gt;
&amp;nbsp; @DbName: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;default is the current database&lt;br /&gt;
&amp;nbsp; @SchemaName: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;default is null showing all schemas&lt;br /&gt;
&amp;nbsp; @ObjectName: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;default is &quot;%&quot; including all objects in &quot;LIKE&quot; clause&lt;br /&gt;
&amp;nbsp; @TopClause: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; default is null showing all objects. Can be &quot;TOP N&quot; or &quot;TOP N PERCENT&quot;&lt;br /&gt;
&amp;nbsp; @ObjectType: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;default is &quot;S&quot;, &quot;U&quot;, &quot;V&quot;, &quot;SQ&quot; and &quot;IT&quot;. All objects that can be sized&lt;br /&gt;
&amp;nbsp; @ShowInternalTable: default is &quot;Yes&quot;, when listing IT, the Parent excludes it in size&lt;br /&gt;
&amp;nbsp; @OrderBy: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; default is by object name, can be any size related column&lt;br /&gt;
&amp;nbsp; @UpdateUsage: &amp;nbsp; &amp;nbsp; &amp;nbsp; default is 0, meaning &quot;do not run DBCC UPDATEUSAGE&quot;&lt;br /&gt;
&lt;br /&gt;
Note: &amp;nbsp; &amp;nbsp; &amp;nbsp; SS 2000/2005/2008 portable using dynamic SQL to bypass validation error;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Use ISNULL to allow prefilled default parameter values;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Use &quot;DBCC UPDATEUSAGE&quot; with caution as it can hold up large databases;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Unicode compatible and case insensitive;&lt;br /&gt;
&lt;br /&gt;
Sample codes:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;EXEC dbo.sp_SOS;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;EXEC dbo.sp_SOS &#39;AdventureWorks&#39;, NULL, &#39;%&#39;, NULL, &#39;U&#39;, &#39;No&#39;, &#39;T&#39;, 1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;sp_SOS &#39;TRACE&#39;, NULL, NULL, Null, &#39; &amp;nbsp;,,, ,;SQ,; &amp;nbsp;u &amp;nbsp;;;;,, &amp;nbsp;v &amp;nbsp;,,;iT &amp;nbsp; &amp;nbsp; , &amp;nbsp;;&#39;, &#39;No&#39;, N&#39;N&#39;, 0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;sp_SOS NULL, NULL, NULL, NULL, &#39;U&#39;, &#39;Yes&#39;, N&#39;U&#39;, 1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;sp_SOS &#39;AdventureWorks&#39;, &#39;Person%&#39;, &#39;Contact%&#39;, NULL, &#39;U&#39;, &#39;no&#39;, &#39;N&#39;, 0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;sp_SOS &#39;AdventureWorks&#39;, NULL, NULL, N&#39;Top 100 Percent&#39;, &#39;S&#39;, &#39;yes&#39;, N&#39;N&#39;, 1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;sp_SOS &#39;AdventureWorks&#39;, NULL, &#39;xml_index_nodes_309576141_32000&#39;, NULL, &#39;IT&#39;, &#39;yes&#39;, &#39;N&#39;, 1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;sp_SOS &#39;TRACE&#39;, NULL, &#39;Vw_DARS_217_overnight_activity_11142007&#39;, &#39; top 10 &#39;, &#39;v&#39;, &#39;yes&#39;, &#39;N&#39;, 0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;sp_SOS &#39;AdventureWorks&#39;, NULL, &#39;xml%&#39;, &#39; top 10 &#39;, null, &#39;yes&#39;, &#39;N&#39;, 1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;sp_SOS &#39;AdventureWorks2008&#39;, NULL, &#39;sales%&#39;, NULL, &#39; &amp;nbsp;,,; &amp;nbsp;u &amp;nbsp;;;;,, &amp;nbsp;v &amp;nbsp;&#39;, &#39;No&#39;, N&#39;N&#39;, 1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;sp_SOS NULL, NULL, NULL, N&#39;Top 100 Percent&#39;, &#39; ;;Q, U;V,&#39;, N&#39;Y&#39;, 1;&lt;br /&gt;
&lt;br /&gt;
=================================================================================================*/&lt;br /&gt;
&lt;br /&gt;
SET NOCOUNT ON;&lt;br /&gt;
&lt;br /&gt;
-- &amp;nbsp;Input parameter validity checking&lt;br /&gt;
DECLARE @SELECT nvarchar(2500),&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; @WHERE_Schema nvarchar(200),&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; @WHERE_Object nvarchar(200),&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; @WHERE_Type nvarchar(200),&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; @WHERE_Final nvarchar(1000),&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; @ID int,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; @Version nchar(2),&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; @String nvarchar(4000),&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; @Count bigint,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; @GroupBy nvarchar(450);&lt;br /&gt;
&lt;br /&gt;
IF ISNULL(@OrderBy, N&#39;N&#39;) NOT IN (N&#39;&#39;, N&#39;N&#39;, N&#39;R&#39;, N&#39;T&#39;, N&#39;U&#39;, N&#39;I&#39;, N&#39;D&#39;, N&#39;F&#39;, N&#39;Y&#39;)&lt;br /&gt;
&amp;nbsp; BEGIN&lt;br /&gt;
&amp;nbsp; &amp;nbsp; RAISERROR (N&#39;Incorrect value for @OrderBy. Valid parameters are:&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;&#39;N&#39;&#39; &amp;nbsp;--&amp;gt; &amp;nbsp;Listing by object name&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;&#39;R&#39;&#39; &amp;nbsp;--&amp;gt; &amp;nbsp;Listing by number of records &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;&#39;T&#39;&#39; &amp;nbsp;--&amp;gt; &amp;nbsp;Listing by total size&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;&#39;U&#39;&#39; &amp;nbsp;--&amp;gt; &amp;nbsp;Listing by used portion (excluding free space)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;&#39;I&#39;&#39; &amp;nbsp;--&amp;gt; &amp;nbsp;Listing by index size&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;&#39;D&#39;&#39; &amp;nbsp;--&amp;gt; &amp;nbsp;Listing by data size&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;&#39;F&#39;&#39; &amp;nbsp;--&amp;gt; &amp;nbsp;Listing by unused (free) space&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;&#39;Y&#39;&#39; &amp;nbsp;--&amp;gt; &amp;nbsp;Listing by object type &#39;, &amp;nbsp;16, 1)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; RETURN (-1)&lt;br /&gt;
&amp;nbsp; END;&lt;br /&gt;
&lt;br /&gt;
-- &amp;nbsp;Object Type Validation and Clean up&lt;br /&gt;
DECLARE @OTV nvarchar(10), @OTC nvarchar(10);&lt;br /&gt;
SELECT @OTV = REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(ISNULL(@ObjectType,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; N&#39;S, U, V, SQ, IT&#39;), N&#39; &#39;, N&#39;&#39;), N&#39;,&#39;, N&#39;&#39;), N&#39;;&#39;, N&#39;&#39;), N&#39;SQ&#39;, N&#39;&#39;), N&#39;U&#39;, N&#39;&#39;),&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; N&#39;V&#39;, N&#39;&#39;), N&#39;IT&#39;, N&#39;&#39;), N&#39;S&#39;, N&#39;&#39;);&lt;br /&gt;
IF LEN(@OTV) &amp;lt;&amp;gt; 0 &amp;nbsp; &amp;nbsp;-- &amp;nbsp;only allow comma, semi colon and space around S,U,V,SQ,IT&lt;br /&gt;
&amp;nbsp; BEGIN&lt;br /&gt;
&amp;nbsp; &amp;nbsp; RAISERROR (N&#39;Parameter error. Choose &#39;&#39;S&#39;&#39;, &#39;&#39;U&#39;&#39;, &#39;&#39;V&#39;&#39;, &#39;&#39;SQ&#39;&#39;, &#39;&#39;IT&#39;&#39; or any combination of them,&lt;br /&gt;
separated by space, comma or semicolon.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; S &amp;nbsp; -&amp;gt; &amp;nbsp; System table;&lt;br /&gt;
&amp;nbsp; U &amp;nbsp; -&amp;gt; &amp;nbsp; User table;&lt;br /&gt;
&amp;nbsp; V &amp;nbsp; -&amp;gt; &amp;nbsp; Indexed view;&lt;br /&gt;
&amp;nbsp; SQ &amp;nbsp;-&amp;gt; &amp;nbsp; Service Queue;&lt;br /&gt;
&amp;nbsp; IT &amp;nbsp;-&amp;gt; &amp;nbsp; Internal Table&#39;, &amp;nbsp;16, 1)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; RETURN (-1)&lt;br /&gt;
&amp;nbsp; END&lt;br /&gt;
ELSE &amp;nbsp; &amp;nbsp;-- &amp;nbsp;passed validation&lt;br /&gt;
&amp;nbsp; BEGIN&lt;br /&gt;
&amp;nbsp; &amp;nbsp; SET @OTC = UPPER(REPLACE(REPLACE(REPLACE(ISNULL(@ObjectType,N&#39;S,U,V,SQ,IT&#39;),N&#39; &#39;,N&#39;&#39;),N&#39;,&#39;,N&#39;&#39;),N&#39;;&#39;,N&#39;&#39;))&lt;br /&gt;
&amp;nbsp; &amp;nbsp; SELECT @ObjectType = REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(ISNULL&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(@ObjectType, N&#39;S,U,V,SQ,IT&#39;),N&#39;,&#39;,N&#39;&#39;),N&#39;;&#39;,N&#39;&#39;),N&#39;SQ&#39;,N&#39;&#39;&#39;QQ&#39;&#39;&#39;),N&#39;IT&#39;,N&#39;&#39;&#39;IT&#39;&#39;&#39;),N&#39;S&#39;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;N&#39;&#39;&#39;S&#39;&#39;&#39;),N&#39;U&#39;,N&#39;&#39;&#39;U&#39;&#39;&#39;),N&#39;V&#39;,N&#39;&#39;&#39;V&#39;&#39;&#39;),N&#39;QQ&#39;,N&#39;SQ&#39;),N&#39; &#39;,N&#39;&#39;),N&#39;&#39;&#39;&#39;&#39;&#39;,N&#39;&#39;&#39;,&#39;&#39;&#39;)&lt;br /&gt;
&amp;nbsp; END&lt;br /&gt;
&lt;br /&gt;
---- &amp;nbsp;common &amp;nbsp;----&lt;br /&gt;
SELECT @DbName = ISNULL(@DbName, DB_NAME()),&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;@Version = SUBSTRING(CONVERT(nchar(20), SERVERPROPERTY (N&#39;ProductVersion&#39;)), 1,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CHARINDEX(N&#39;.&#39;, CONVERT(nchar(20), SERVERPROPERTY (N&#39;ProductVersion&#39;)))-1),&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;@OrderBy = N&#39;ORDER BY [&#39; +&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CASE ISNULL(@OrderBy, N&#39;N&#39;)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WHEN N&#39;N&#39; THEN N&#39;Object Name] ASC &#39;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WHEN N&#39;R&#39; THEN N&#39;Rows] DESC, [Object Name] ASC &#39;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WHEN N&#39;T&#39; THEN N&#39;Total(MB)] DESC, [Object Name] ASC &#39;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WHEN N&#39;U&#39; THEN N&#39;Used(MB)] DESC, [Object Name] ASC &#39;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WHEN N&#39;I&#39; THEN N&#39;Index(MB)] DESC, [Object Name] ASC &#39;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WHEN N&#39;D&#39; THEN N&#39;Data(MB)] DESC, [Object Name] ASC &#39;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WHEN N&#39;F&#39; THEN N&#39;Unused(MB)] DESC, [Object Name] ASC &#39;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WHEN N&#39;Y&#39; THEN N&#39;Type] ASC, [Object Name] ASC &#39;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; END;&lt;br /&gt;
&lt;br /&gt;
---------------------- &amp;nbsp;SS 2000 &amp;nbsp;-----------------------------------&lt;br /&gt;
IF @Version = N&#39;8&#39;&lt;br /&gt;
&amp;nbsp; BEGIN&lt;br /&gt;
&amp;nbsp; &amp;nbsp; SELECT @SELECT = N&#39;USE &#39; + @DbName + N&#39; SELECT &#39; + ISNULL(@TopClause, N&#39; &#39;) + &amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; N&#39;&#39;&#39;&#39;&#39; + USER_NAME(o.uid) + &#39;&#39;.&#39;&#39; + OBJECT_NAME(i.id) + &#39;&#39;&#39;&#39; AS &#39;&#39;Object Name&#39;&#39;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; o.type AS &#39;&#39;Type&#39;&#39;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; MAX(i.[rows]) AS &#39;&#39;Rows&#39;&#39;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; CONVERT(dec(10,3), SUM(i.reserved * 8.000/1024)) AS &#39;&#39;Total(MB)&#39;&#39;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; CONVERT(dec(10,3), SUM((i.reserved - i.used) * 8.000/1024)) AS &#39;&#39;Unused(MB)&#39;&#39;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; CONVERT(dec(10,3), SUM(i.used * 8.000/1024)) AS &#39;&#39;Used(MB)&#39;&#39;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; CONVERT(dec(10,3), SUM((i.used - CASE WHEN indid &amp;lt;&amp;gt; 255 THEN i.dpages ELSE i.used END)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; * 8.000/1024)) AS &#39;&#39;Index(MB)&#39;&#39;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; CONVERT(dec(10,3), SUM(CASE WHEN indid &amp;lt;&amp;gt; 255 THEN i.dpages ELSE i.used END&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; * 8.000/1024)) AS &#39;&#39;Data(MB)&#39;&#39;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; FROM dbo.sysindexes i WITH (NOLOCK)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; JOIN dbo.sysobjects o WITH (NOLOCK)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; ON i.id = o.id&lt;br /&gt;
&amp;nbsp; &amp;nbsp; WHERE i.name NOT LIKE &#39;&#39;_WA_Sys_%&#39;&#39;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; AND i.indid IN (0, 1, 255) AND USER_NAME(o.uid) LIKE &#39;&#39;&#39; + ISNULL(@SchemaName, N&#39;%&#39;) + N&#39;&#39;&#39; &#39;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; -- SS 2000 calculation as below:&lt;br /&gt;
&amp;nbsp; &amp;nbsp; -- &amp;nbsp;&quot;reserved&quot; = total size;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; -- &amp;nbsp;&quot;dpages&quot; = data used;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; -- &amp;nbsp;&quot;used&quot; = used portion (contains data and index);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; -- &amp;nbsp;text or image column: use &quot;used&quot; for data size&lt;br /&gt;
&amp;nbsp; &amp;nbsp; -- &amp;nbsp;Nonclustered index take tiny space, somehow it is not counted (see sp_spaceused).&lt;br /&gt;
&amp;nbsp; &amp;nbsp; @WHERE_Final = N&#39; AND OBJECT_NAME(i.id) LIKE &#39;&#39;&#39; + ISNULL(@ObjectName, N&#39;%&#39;)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;+ N&#39;&#39;&#39; AND o.type IN (&#39; + @ObjectType + N&#39;) &#39;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; @GroupBy = N&#39; GROUP BY &#39;&#39;&#39;&#39; + USER_NAME(o.uid) + &#39;&#39;.&#39;&#39; + OBJECT_NAME(i.id) + &#39;&#39;&#39;&#39;, o.type &#39;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; @String = &amp;nbsp;@SELECT + @WHERE_Final + @GroupBy + @OrderBy&lt;br /&gt;
&amp;nbsp; END&lt;br /&gt;
&lt;br /&gt;
------------------- &amp;nbsp;ss 2k5 ------------------------------------------------------&lt;br /&gt;
IF @Version IN (N&#39;9&#39;, N&#39;10&#39;)&lt;br /&gt;
&amp;nbsp; BEGIN&lt;br /&gt;
&amp;nbsp; &amp;nbsp; SELECT @String = N&#39;&lt;br /&gt;
IF OBJECT_ID (&#39;&#39;tempdb.dbo.##BO&#39;&#39;, &#39;&#39;U&#39;&#39;) IS NOT NULL&lt;br /&gt;
&amp;nbsp; DROP TABLE dbo.##BO&lt;br /&gt;
&lt;br /&gt;
CREATE TABLE dbo.##BO (&lt;br /&gt;
&amp;nbsp; ID int identity,&lt;br /&gt;
&amp;nbsp; DOI bigint null, &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;-- Daughter Object Id&lt;br /&gt;
&amp;nbsp; DON sysname null, &amp;nbsp; &amp;nbsp; &amp;nbsp; -- Daughter Object Name&lt;br /&gt;
&amp;nbsp; DSI int null, &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; -- Daughter Schema Id&lt;br /&gt;
&amp;nbsp; DSN sysname null, &amp;nbsp; &amp;nbsp; &amp;nbsp; -- Daughter Schema Name&lt;br /&gt;
&amp;nbsp; DOT varchar(10) null, &amp;nbsp; -- Daughter Object Type&lt;br /&gt;
&amp;nbsp; DFN sysname null, &amp;nbsp; &amp;nbsp; &amp;nbsp; -- Daughter Full Name&lt;br /&gt;
&amp;nbsp; POI bigint null, &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;-- Parent Object Id&lt;br /&gt;
&amp;nbsp; PON sysname null, &amp;nbsp; &amp;nbsp; &amp;nbsp; -- Parent Object Name&lt;br /&gt;
&amp;nbsp; PSI bigint null, &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;-- Parent Schema Id&lt;br /&gt;
&amp;nbsp; PSN sysname null, &amp;nbsp; &amp;nbsp; &amp;nbsp; -- Parent Schema Name&lt;br /&gt;
&amp;nbsp; POT varchar(10) null, &amp;nbsp; -- Parent Object Type&lt;br /&gt;
&amp;nbsp; PFN sysname null &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;-- Parent Full Name&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
INSERT INTO dbo.##BO (DOI, DSI, DOT, POI)&lt;br /&gt;
&amp;nbsp; SELECT object_id, schema_id, type, Parent_object_id&lt;br /&gt;
FROM &#39; + @DbName + N&#39;.sys.objects o WHERE type IN (&#39;&#39;S&#39;&#39;,&#39;&#39;U&#39;&#39;,&#39;&#39;V&#39;&#39;,&#39;&#39;SQ&#39;&#39;,&#39;&#39;IT&#39;&#39;)&lt;br /&gt;
USE &#39; + @DbName + N&#39;&lt;br /&gt;
UPDATE dbo.##BO SET DON = object_name(DOI), DSN = schema_name(DSI), POI = CASE POI WHEN 0 THEN DOI ELSE POI END&lt;br /&gt;
UPDATE dbo.##BO SET PSI = o.schema_id, POT = o.type FROM sys.objects o JOIN dbo.##BO t ON o.object_id = t.POI&lt;br /&gt;
UPDATE dbo.##BO SET PON = object_name(POI), PSN = schema_name(PSI), DFN = DSN + &#39;&#39;.&#39;&#39; + DON,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; PFN = schema_name(PSI)+ &#39;&#39;.&#39;&#39; + object_name(POI)&lt;br /&gt;
&#39;&lt;br /&gt;
EXEC (@String)&lt;br /&gt;
&lt;br /&gt;
SELECT&lt;br /&gt;
@WHERE_Type = CASE WHEN ISNULL(@ShowInternalTable, N&#39;Yes&#39;) = N&#39;Yes&#39; THEN N&#39;t.DOT &#39; ELSE N&#39;t.POT &#39; END, &lt;br /&gt;
@SELECT = N&#39;USE &#39; + @DbName + N&#39;&lt;br /&gt;
&amp;nbsp; SELECT &#39; + ISNULL(@TopClause, N&#39;TOP 100 PERCENT &#39;) +&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; N&#39; CASE WHEN &#39;&#39;&#39; + isnull(@ShowInternalTable, N&#39;Yes&#39;) + N&#39;&#39;&#39; = &#39;&#39;Yes&#39;&#39; THEN CASE t.DFN WHEN t.PFN THEN t.PFN&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ELSE t.DFN + &#39;&#39; (&#39;&#39;+ t.PFN + &#39;&#39;)&#39;&#39; END ELSE t.PFN END AS &#39;&#39;Object Name&#39;&#39;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&#39; + @WHERE_Type + N&#39; AS &#39;&#39;Type&#39;&#39;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;SUM (CASE WHEN &#39;&#39;&#39; + isnull(@ShowInternalTable, N&#39;Yes&#39;) + N&#39;&#39;&#39; = &#39;&#39;Yes&#39;&#39; THEN&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;CASE WHEN (ps.index_id &amp;lt; 2 ) THEN ps.row_count ELSE 0 END&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ELSE CASE WHEN (ps.index_id &amp;lt; 2 and t.DON = t.PON) THEN ps.row_count ELSE 0 END END) AS &#39;&#39;Rows&#39;&#39;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;SUM (CASE WHEN t.DON NOT LIKE &#39;&#39;fulltext%&#39;&#39; OR t.DON LIKE &#39;&#39;fulltext_index_map%&#39;&#39;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; THEN ps.reserved_page_count ELSE 0 END)* 8.000/1024 AS &#39;&#39;Total(MB)&#39;&#39;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;SUM (CASE WHEN t.DON NOT LIKE &#39;&#39;fulltext%&#39;&#39; OR t.DON LIKE &#39;&#39;fulltext_index_map%&#39;&#39;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; THEN ps.reserved_page_count ELSE 0 END&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - CASE WHEN t.DON NOT LIKE &#39;&#39;fulltext%&#39;&#39; OR t.DON LIKE &#39;&#39;fulltext_index_map%&#39;&#39; THEN&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ps.used_page_count ELSE 0 END)* 8.000/1024 AS &#39;&#39;Unused(MB)&#39;&#39;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt; &amp;nbsp; &amp;nbsp; SUM (CASE WHEN t.DON NOT LIKE &#39;&#39;fulltext%&#39;&#39; OR t.DON LIKE &#39;&#39;fulltext_index_map%&#39;&#39;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; THEN ps.used_page_count ELSE 0 END)* 8.000/1024 AS &#39;&#39;Used(MB)&#39;&#39;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;SUM (CASE WHEN t.DON NOT LIKE &#39;&#39;fulltext%&#39;&#39; OR t.DON LIKE &#39;&#39;fulltext_index_map%&#39;&#39;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; THEN ps.used_page_count ELSE 0 END&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - CASE WHEN t.POT NOT IN (&#39;&#39;SQ&#39;&#39;,&#39;&#39;IT&#39;&#39;) AND t.DOT IN (&#39;&#39;IT&#39;&#39;) and &#39;&#39;&#39; + isnull(@ShowInternalTable, N&#39;Yes&#39;)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; + N&#39;&#39;&#39; = &#39;&#39;No&#39;&#39; THEN 0 ELSE CASE WHEN (ps.index_id&lt;2 nbsp=&quot;&quot; p=&quot;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; THEN (ps.in_row_data_page_count+ps.lob_used_page_count+ps.row_overflow_used_page_count)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;			&lt;/span&gt; &amp;nbsp; &amp;nbsp;ELSE ps.lob_used_page_count + ps.row_overflow_used_page_count END END) * 8.000/1024 AS &#39;&#39;Index(MB)&#39;&#39;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt; &amp;nbsp; &amp;nbsp; SUM (CASE WHEN t.POT NOT IN (&#39;&#39;SQ&#39;&#39;,&#39;&#39;IT&#39;&#39;) AND t.DOT IN (&#39;&#39;IT&#39;&#39;) and &#39;&#39;&#39; + isnull(@ShowInternalTable, N&#39;Yes&#39;)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;+ N&#39;&#39;&#39; = &#39;&#39;No&#39;&#39; THEN 0 ELSE CASE WHEN (ps.index_id&lt;2 nbsp=&quot;&quot; p=&quot;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;THEN (ps.in_row_data_page_count+ps.lob_used_page_count+ps.row_overflow_used_page_count)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;			&lt;/span&gt; &amp;nbsp;ELSE ps.lob_used_page_count + ps.row_overflow_used_page_count END END) * 8.000/1024 AS &#39;&#39;Data(MB)&#39;&#39;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; FROM sys.dm_db_partition_stats ps INNER JOIN dbo.##BO t&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; ON ps.object_id = t.DOI&lt;br /&gt;
&#39;,&lt;br /&gt;
@ObjectType = CASE WHEN ISNULL(@ShowInternalTable, N&#39;Yes&#39;) = N&#39;Yes&#39; THEN N&#39;&#39;&#39;IT&#39;&#39;,&#39; + ISNULL(@ObjectType, N&#39;&#39;&#39;S&#39;&#39;,&#39;&#39;U&#39;&#39;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;&#39;V&#39;&#39;, &#39;&#39;SQ&#39;&#39;, &#39;&#39;IT&#39;&#39;&#39;) ELSE ISNULL(@ObjectType, N&#39;&#39;&#39;S&#39;&#39;, &#39;&#39;U&#39;&#39;, &#39;&#39;V&#39;&#39;, &#39;&#39;SQ&#39;&#39;, &#39;&#39;IT&#39;&#39;&#39;) END,&lt;br /&gt;
@WHERE_Schema = CASE WHEN ISNULL(@ShowInternalTable, N&#39;Yes&#39;) = N&#39;Yes&#39; THEN N&#39; t.DSN &#39; ELSE N&#39; t.PSN &#39; END, -- DSN or PSN&lt;br /&gt;
@WHERE_Object = CASE WHEN ISNULL(@ShowInternalTable, N&#39;Yes&#39;) = N&#39;Yes&#39; THEN N&#39; t.DON LIKE &#39;&#39;&#39; + ISNULL(@ObjectName, N&#39;%&#39;)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; + &#39;&#39;&#39; OR t.PON LIKE &#39;&#39;&#39; + ISNULL(@ObjectName, N&#39;%&#39;) + N&#39;&#39;&#39; &#39;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ELSE N&#39; t.pon LIKE &#39;&#39;&#39; + ISNULL(@ObjectName, N&#39;%&#39;) + N&#39;&#39;&#39; &#39; END, &amp;nbsp; &amp;nbsp; &amp;nbsp;-- DON or PON&lt;br /&gt;
@WHERE_Final = N&#39; WHERE (&#39; + @WHERE_Schema + N&#39; LIKE &#39;&#39;&#39; + ISNULL(@SchemaName, N&#39;%&#39;) + N&#39;&#39;&#39; OR &#39; + @WHERE_Schema +&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;N&#39; = &#39;&#39;sys&#39;&#39;) AND (&#39; + @WHERE_Object + N&#39; ) AND &#39; + @WHERE_Type + N&#39; IN (&#39; + @ObjectType + N&#39;) &#39;,&lt;br /&gt;
@GroupBy = N&#39;GROUP BY CASE WHEN &#39;&#39;&#39; + ISNULL(@ShowInternalTable, N&#39;Yes&#39;) + N&#39;&#39;&#39; = &#39;&#39;Yes&#39;&#39; THEN CASE t.DFN WHEN t.PFN&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; THEN t.PFN ELSE t.DFN + &#39;&#39; (&#39;&#39;+ t.PFN + &#39;&#39;)&#39;&#39; END ELSE t.PFN END, &#39; + @WHERE_Type + N&#39;&#39;&lt;br /&gt;
SELECT @String = &amp;nbsp;@SELECT + @WHERE_Final + @GroupBy + @OrderBy&lt;br /&gt;
&amp;nbsp;-- SELECT @String AS &#39;STRING&#39;&lt;br /&gt;
END&lt;br /&gt;
&lt;br /&gt;
----- &amp;nbsp;common &amp;nbsp;------&lt;br /&gt;
IF OBJECT_ID(N&#39;tempdb.dbo.##FO&#39;, N&#39;U&#39;) IS NOT NULL&lt;br /&gt;
&amp;nbsp; DROP TABLE dbo.##FO;&lt;br /&gt;
&lt;br /&gt;
CREATE TABLE dbo.##FO (&lt;br /&gt;
&amp;nbsp; &amp;nbsp; ID int identity,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; [Object Name] sysname,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; [Type] varchar(2),&lt;br /&gt;
&amp;nbsp; &amp;nbsp; [Rows] bigint,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; [Total(MB)] dec(10,3),&lt;br /&gt;
&amp;nbsp; &amp;nbsp; [-] nchar(1),&lt;br /&gt;
&amp;nbsp; &amp;nbsp; [Unused(MB)] dec(10,3),&lt;br /&gt;
&amp;nbsp; &amp;nbsp; [==] nchar(2),&lt;br /&gt;
&amp;nbsp; &amp;nbsp; [Used(MB)] dec(10,3),&lt;br /&gt;
&amp;nbsp; &amp;nbsp; [=] nchar(1),&lt;br /&gt;
&amp;nbsp; &amp;nbsp; [Index(MB)] dec(10,3),&lt;br /&gt;
&amp;nbsp; &amp;nbsp; [+] nchar(1),&lt;br /&gt;
&amp;nbsp; &amp;nbsp; [Data(MB)] dec(10,3) );&lt;br /&gt;
&lt;br /&gt;
INSERT INTO dbo.##FO ([Object Name], [Type], [Rows], [Total(MB)],[Unused(MB)],[Used(MB)],[Index(MB)],[Data(MB)])&lt;br /&gt;
&amp;nbsp; EXEC (@String);&lt;br /&gt;
&lt;br /&gt;
SELECT @Count = COUNT(*) FROM dbo.##FO;&lt;br /&gt;
&lt;br /&gt;
IF @Count = 0&lt;br /&gt;
&amp;nbsp; BEGIN&lt;br /&gt;
&amp;nbsp; &amp;nbsp; RAISERROR (N&#39;No records were found macthcing your criteria.&#39;, &amp;nbsp;16, 1)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; RETURN (-1)&lt;br /&gt;
&amp;nbsp; END&lt;br /&gt;
ELSE &amp;nbsp; &amp;nbsp;-- There&#39;re at least one records&lt;br /&gt;
&amp;nbsp; BEGIN&lt;br /&gt;
&amp;nbsp; &amp;nbsp; -- &amp;nbsp;Run DBCC UPDATEUSAGE to correct wrong values&lt;br /&gt;
&amp;nbsp; &amp;nbsp; IF ISNULL(@UpdateUsage, 0) = 1&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; BEGIN&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SELECT @ObjectName = N&#39;&#39;, @ID = 0&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WHILE 1 = 1&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;BEGIN&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;SELECT TOP 1 @ObjectName = CASE WHEN [Object Name] LIKE N&#39;%(%&#39; THEN&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;SUBSTRING([Object Name], 1, CHARINDEX(N&#39;(&#39;, [Object Name])-2) ELSE [Object Name] END&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; , @ID = ID FROM dbo.##FO WHERE ID &amp;gt; @ID ORDER BY ID ASC&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;IF @@ROWCOUNT = 0&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;BREAK&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; PRINT N&#39;==&amp;gt; DBCC UPDATEUSAGE (&#39; + @DbName + N&#39;, &#39;&#39;&#39; + @ObjectName + N&#39;&#39;&#39;) WITH COUNT_ROWS&#39;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;			&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;DBCC UPDATEUSAGE (@DbName, @ObjectName) WITH COUNT_ROWS&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; PRINT N&#39;&#39;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;END&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; PRINT N&#39;&#39;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; TRUNCATE TABLE dbo.##FO&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; INSERT INTO dbo.##FO ([Object Name], [Type], [Rows], [Total(MB)],[Unused(MB)],&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [Used(MB)],[Index(MB)],[Data(MB)]) EXEC (@String)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; END&lt;br /&gt;
&amp;nbsp; &amp;nbsp; ELSE&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; PRINT N&#39;(Warning: Run &quot;DBCC UPDATEUSAGE&quot; on suspicious objects. It may incur overhead on big databases.)&#39;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; PRINT N&#39;&#39;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; UPDATE dbo.##FO SET [-] = N&#39;-&#39;, [==] = N&#39;==&#39;, [=] = N&#39;=&#39;, [+] = N&#39;+&#39;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; IF @Count = 1 &amp;nbsp;-- when only 1 row, no need to sum up total&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; SELECT [Object Name], [Type], [Rows], [Total(MB)],[-], [Unused(MB)],[==], [Used(MB)],[=],&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[Index(MB)],[+],[Data(MB)]&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; FROM dbo.##FO ORDER BY ID ASC&lt;br /&gt;
&amp;nbsp; &amp;nbsp; ELSE&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; BEGIN&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SELECT [Object Name], [Type], [Rows], [Total(MB)],[-], [Unused(MB)],[==], [Used(MB)],[=],&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[Index(MB)],[+],[Data(MB)]&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; FROM dbo.##FO ORDER BY ID ASC&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;COMPUTE SUM([Total(MB)]), SUM([Unused(MB)]), SUM([Used(MB)]), SUM([Index(MB)]), SUM([Data(MB)])&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; END&lt;br /&gt;
&amp;nbsp; END&lt;br /&gt;
&lt;br /&gt;
RETURN (0)&lt;br /&gt;
&lt;br /&gt;
GO&lt;/2&gt;&lt;/2&gt;&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
--exec sp_SOS @DbName = &#39;myERP&#39;, @ObjectType =&#39;U&#39;&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;br /&gt;
until then&lt;br /&gt;
&lt;br /&gt;
PS: something went wrong when try to copy it so i revert to the original one&lt;br /&gt;
&lt;!--2--&gt;
</content><link rel='replies' type='application/atom+xml' href='http://erickwidya.blogspot.com/feeds/4351182868114034637/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/26554202/4351182868114034637' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/4351182868114034637'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/4351182868114034637'/><link rel='alternate' type='text/html' href='http://erickwidya.blogspot.com/2012/11/find-size-of-sql-server-tables-and.html' title='Find size of SQL Server tables and other objects with stored procedure'/><author><name>eRiCk</name><uri>http://www.blogger.com/profile/06607831852417429737</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-26554202.post-6672236816856623033</id><published>2012-11-22T11:18:00.000+07:00</published><updated>2014-04-29T10:29:40.842+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="some code"/><title type='text'>Get Computer name from IP</title><content type='html'>i know it&#39;s &quot;old&quot; one but sometimes i need to use it so instead i search over and over again, i&#39;ll write it down here :D&lt;br /&gt;
the magic word are (at command prompt)&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;background-color: #eff2fb; color: #303030; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px;&quot;&gt;nbtstat -a [ip_address_here]&lt;/span&gt;&lt;/blockquote&gt;
until then</content><link rel='replies' type='application/atom+xml' href='http://erickwidya.blogspot.com/feeds/6672236816856623033/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/26554202/6672236816856623033' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/6672236816856623033'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/6672236816856623033'/><link rel='alternate' type='text/html' href='http://erickwidya.blogspot.com/2012/11/get-computer-name-from-ip.html' title='Get Computer name from IP'/><author><name>eRiCk</name><uri>http://www.blogger.com/profile/06607831852417429737</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-26554202.post-8628675040461888658</id><published>2012-10-08T16:43:00.001+07:00</published><updated>2014-04-29T10:29:40.854+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="some code"/><title type='text'>Print Escape Character for printer Barcode in .NET</title><content type='html'>fiuhh, this case is one of the most annoying &#39;simple&#39; approach&lt;br /&gt;
&lt;br /&gt;
requirement is to send &#39;barcode&#39; to printer directly, because often we using Image print (creating image on the fly then send it to barcode printer)..this one althought works but often the image become blur / discarded&lt;br /&gt;
&lt;br /&gt;
so we need to &#39;communicate&#39; to barcode printer using its &#39;language&#39;&lt;br /&gt;
the &#39;language&#39; depends on the printer itself..in my case, we using SATO barcode printer so the &#39;language&#39; is&lt;br /&gt;
&lt;a href=&quot;http://comex.home.pl/pub/pdf/sato/SATO%20Barcode%20Programming%20Language.pdf&quot; target=&quot;_blank&quot;&gt;SBPL&lt;/a&gt;&amp;nbsp;(visit the link for more info)&lt;br /&gt;
&lt;br /&gt;
first we need to design the label&lt;br /&gt;
we can use SBPL and design it &#39;on the fly&#39; make us a little bit crazy&lt;br /&gt;
&lt;br /&gt;
or we can use &lt;a href=&quot;http://www.satoasiapacific.com/products/software/label-gallery/label-gallery-34.aspx&quot; target=&quot;_blank&quot;&gt;SATO LABEL Gallery Free&lt;/a&gt; to do the job and generate SBPL equivalent for us so we can use it in our code&lt;br /&gt;
&lt;br /&gt;
after we design it, we use &quot;Print to file&quot; method for the printer then print it so we can see what its send to the printer&lt;br /&gt;
&lt;br /&gt;
the generated SBPL will contain &#39;unseen&#39; character in visual studio IDE (i&#39;m using VS 2010) so be careful with it, u must open it using 3rd party like Notepad++&lt;br /&gt;
&lt;br /&gt;
just replace the &#39;dynamic&#39; content (ie: productCode, productName, etc) then start printing it&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;caution:&lt;/b&gt;&lt;br /&gt;
1. if u need to add &lt;stx&gt;, &lt;etx&gt; just for readiness of the code then u need to replace it from the SBPL using notepad++ then paste it in code&amp;nbsp;&lt;/etx&gt;&lt;/stx&gt;&lt;br /&gt;
before printing don&#39;t forget to Replace it again to so it can recognized using this method:&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;pre class=&quot;lang-cs prettyprint&quot; style=&quot;border: 0px; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; font-size: 14px; line-height: 18px; margin-bottom: 10px; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto;&quot;&gt;&lt;code style=&quot;border: 0px; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background-color: #444444; color: white;&quot;&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Replace&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&quot;&lt;stx&gt;&quot;&lt;/stx&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;char&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;02&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;ToString&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;());&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Replace&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&quot;&lt;etx&gt;&quot;&lt;/etx&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;char&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;03&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;ToString&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;());&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Replace&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&quot;&lt;esc&gt;&quot;&lt;/esc&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;char&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;27&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;ToString&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;());&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/blockquote&gt;
2. don&#39;t forget to copy it &quot;as is&quot; from generated File in, must include [STX][ETX] thing&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5c-tacIwljeCuS5nLJexU5S55M2mhDBdx9skZr-ODdOMpMIGzDaFGWCB4z68-E5g8Ej1a2uFzdG2CRF7i2TdGx5FHefCAY_MzHvpmcpmD_zeoB9Cm4t2V8rPGoyx76brkRibc/s1600/Screenshot+-+10_8_2012+,+4_39_20+PM.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;11&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5c-tacIwljeCuS5nLJexU5S55M2mhDBdx9skZr-ODdOMpMIGzDaFGWCB4z68-E5g8Ej1a2uFzdG2CRF7i2TdGx5FHefCAY_MzHvpmcpmD_zeoB9Cm4t2V8rPGoyx76brkRibc/s320/Screenshot+-+10_8_2012+,+4_39_20+PM.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
become&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9Q-FwrhTRh5zLXfx3I-65G_AnJtXCJG1dWUbsEhaLgA5MsBuq2VAtrd24D6IUI8O6ABeeLlbZ4s2xZMJKtwttX56xxePdEgfpbfduZZX5BXpe6W6TQG1Od_rAcNC_R-9nTLlv/s1600/Screenshot+-+10_8_2012+,+4_41_43+PM.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;9&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9Q-FwrhTRh5zLXfx3I-65G_AnJtXCJG1dWUbsEhaLgA5MsBuq2VAtrd24D6IUI8O6ABeeLlbZ4s2xZMJKtwttX56xxePdEgfpbfduZZX5BXpe6W6TQG1Od_rAcNC_R-9nTLlv/s320/Screenshot+-+10_8_2012+,+4_41_43+PM.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
and using step 1. to replace it (tooks 2 days to realize it and search for the .NET equivalent way) :(&lt;br /&gt;
&lt;br /&gt;
PS: stilll not sure how to display the Escape Character inside VS IDE ( maybe u&#39;ll see &#39;bad thing inside&#39; :D )&lt;br /&gt;
&lt;br /&gt;
until then&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://erickwidya.blogspot.com/feeds/8628675040461888658/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/26554202/8628675040461888658' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/8628675040461888658'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/8628675040461888658'/><link rel='alternate' type='text/html' href='http://erickwidya.blogspot.com/2012/10/print-escape-character-for-printer.html' title='Print Escape Character for printer Barcode in .NET'/><author><name>eRiCk</name><uri>http://www.blogger.com/profile/06607831852417429737</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><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5c-tacIwljeCuS5nLJexU5S55M2mhDBdx9skZr-ODdOMpMIGzDaFGWCB4z68-E5g8Ej1a2uFzdG2CRF7i2TdGx5FHefCAY_MzHvpmcpmD_zeoB9Cm4t2V8rPGoyx76brkRibc/s72-c/Screenshot+-+10_8_2012+,+4_39_20+PM.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-26554202.post-6754981180602518473</id><published>2012-09-27T08:53:00.000+07:00</published><updated>2012-09-27T08:53:13.254+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="some code"/><title type='text'>Reset Identity Column Value in SQL Server</title><content type='html'>if u have identity column and of course before deployed it to production, u&#39;ll need to test the value

when u done, u probably want to reset it to initial value (0 for example) so u have &#39;fresh&#39; data for production

u&#39;ll be need to use this syntax
&lt;blockquote&gt;DBCC CHECKIDENT (orders, RESEED, 0)&lt;/blockquote&gt;

PS: the next value will be always +1, so in my case next value will be 1

until then</content><link rel='replies' type='application/atom+xml' href='http://erickwidya.blogspot.com/feeds/6754981180602518473/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/26554202/6754981180602518473' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/6754981180602518473'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/6754981180602518473'/><link rel='alternate' type='text/html' href='http://erickwidya.blogspot.com/2012/09/reset-identity-column-value-in-sql.html' title='Reset Identity Column Value in SQL Server'/><author><name>eRiCk</name><uri>http://www.blogger.com/profile/06607831852417429737</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-26554202.post-2272010168788069193</id><published>2012-09-24T16:49:00.000+07:00</published><updated>2014-04-29T10:29:40.827+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="some code"/><title type='text'>Date and Time format in SQL</title><content type='html'>this are some DATE and TIME format to use in SQL that i found when i&#39;m googling a little

&lt;table border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot; class=&quot;bodytext&quot; style=&quot;background-color: #ebffed; color: #4f4f4f; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;YY-MM-DD&lt;/td&gt;&lt;td&gt;&lt;div&gt;
SELECT SUBSTRING(CONVERT(VARCHAR(10), GETDATE(), 120), 3, 8) AS [YY-MM-DD]&lt;/div&gt;
&lt;div&gt;
SELECT REPLACE(CONVERT(VARCHAR(8), GETDATE(), 11), &#39;/&#39;, &#39;-&#39;) AS [YY-MM-DD]&lt;/div&gt;
&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;99-01-24&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;YYYY-MM-DD&lt;/td&gt;&lt;td&gt;&lt;div&gt;
SELECT CONVERT(VARCHAR(10), GETDATE(), 120) AS [YYYY-MM-DD]&lt;/div&gt;
&lt;div&gt;
SELECT REPLACE(CONVERT(VARCHAR(10), GETDATE(), 111), &#39;/&#39;, &#39;-&#39;) AS [YYYY-MM-DD]&lt;/div&gt;
&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;1999-01-24&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;MM/YY&lt;/td&gt;&lt;td&gt;SELECT RIGHT(CONVERT(VARCHAR(8), GETDATE(), 3), 5) AS [MM/YY]&lt;br /&gt;SELECT SUBSTRING(CONVERT(VARCHAR(8), GETDATE(), 3), 4, 5) AS [MM/YY]&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;08/99&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;MM/YYYY&lt;/td&gt;&lt;td&gt;SELECT RIGHT(CONVERT(VARCHAR(10), GETDATE(), 103), 7) AS [MM/YYYY]&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;12/2005&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;YY/MM&lt;/td&gt;&lt;td&gt;SELECT CONVERT(VARCHAR(5), GETDATE(), 11) AS [YY/MM]&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;99/08&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;center&quot; style=&quot;height: 23px;&quot;&gt;YYYY/MM&lt;/td&gt;&lt;td style=&quot;height: 23px;&quot;&gt;SELECT CONVERT(VARCHAR(7), GETDATE(), 111) AS [YYYY/MM]&lt;/td&gt;&lt;td align=&quot;center&quot; style=&quot;height: 23px;&quot;&gt;2005/12&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;Month DD, YYYY&amp;nbsp;&lt;sup style=&quot;color: red;&quot;&gt;1&lt;/sup&gt;&lt;/td&gt;&lt;td&gt;SELECT DATENAME(MM, GETDATE()) + RIGHT(CONVERT(VARCHAR(12), GETDATE(), 107), 9) AS [Month DD, YYYY]&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;July 04, 2006&lt;sup style=&quot;color: red;&quot;&gt;1&lt;/sup&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;Mon YYYY&lt;sup style=&quot;color: red;&quot;&gt;1&lt;/sup&gt;&lt;/td&gt;&lt;td&gt;SELECT SUBSTRING(CONVERT(VARCHAR(11), GETDATE(), 113), 4, 8) AS [Mon YYYY]&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;Apr 2006&amp;nbsp;&lt;sup style=&quot;color: red;&quot;&gt;1&lt;/sup&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;Month YYYY&amp;nbsp;&lt;sup style=&quot;color: red;&quot;&gt;1&lt;/sup&gt;&lt;/td&gt;&lt;td&gt;SELECT DATENAME(MM, GETDATE()) + &#39; &#39; + CAST(YEAR(GETDATE()) AS VARCHAR(4)) AS [Month YYYY]&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;February 2006&amp;nbsp;&lt;sup style=&quot;color: red;&quot;&gt;1&lt;/sup&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;DD Month&lt;sup style=&quot;color: red;&quot;&gt;1&lt;/sup&gt;&lt;/td&gt;&lt;td&gt;SELECT CAST(DAY(GETDATE()) AS VARCHAR(2)) + &#39; &#39; + DATENAME(MM, GETDATE()) AS [DD Month]&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;11 September&amp;nbsp;&lt;sup style=&quot;color: red;&quot;&gt;1&lt;/sup&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;Month DD&lt;sup style=&quot;color: red;&quot;&gt;1&lt;/sup&gt;&lt;/td&gt;&lt;td&gt;SELECT DATENAME(MM, GETDATE()) + &#39; &#39; + CAST(DAY(GETDATE()) AS VARCHAR(2)) AS [Month DD]&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;September 11&amp;nbsp;&lt;sup style=&quot;color: red;&quot;&gt;1&lt;/sup&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;DD Month YY&amp;nbsp;&lt;sup style=&quot;color: red;&quot;&gt;1&lt;/sup&gt;&lt;/td&gt;&lt;td&gt;SELECT CAST(DAY(GETDATE()) AS VARCHAR(2)) + &#39; &#39; + DATENAME(MM, GETDATE()) + &#39; &#39; + RIGHT(CAST(YEAR(GETDATE()) AS VARCHAR(4)), 2) AS [DD Month YY]&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;19 February 72&amp;nbsp;&lt;sup style=&quot;color: red;&quot;&gt;1&lt;/sup&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;DD Month YYYY&amp;nbsp;&lt;sup style=&quot;color: red;&quot;&gt;1&lt;/sup&gt;&lt;/td&gt;&lt;td&gt;SELECT CAST(DAY(GETDATE()) AS VARCHAR(2)) + &#39; &#39; + DATENAME(MM, GETDATE()) + &#39; &#39; + CAST(YEAR(GETDATE()) AS VARCHAR(4)) AS [DD Month YYYY]&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;11 September 2002&amp;nbsp;&lt;sup style=&quot;color: red;&quot;&gt;1&lt;/sup&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;MM-YY&lt;/td&gt;&lt;td&gt;SELECT RIGHT(CONVERT(VARCHAR(8), GETDATE(), 5), 5) AS [MM-YY]&lt;br /&gt;SELECT SUBSTRING(CONVERT(VARCHAR(8), GETDATE(), 5), 4, 5) AS [MM-YY]&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;12/92&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;MM-YYYY&lt;/td&gt;&lt;td&gt;SELECT RIGHT(CONVERT(VARCHAR(10), GETDATE(), 105), 7) AS [MM-YYYY]&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;05-2006&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;YY-MM&lt;/td&gt;&lt;td&gt;SELECT RIGHT(CONVERT(VARCHAR(7), GETDATE(), 120), 5) AS [YY-MM]&lt;br /&gt;SELECT SUBSTRING(CONVERT(VARCHAR(10), GETDATE(), 120), 3, 5) AS [YY-MM]&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;92/12&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;YYYY-MM&lt;/td&gt;&lt;td&gt;SELECT CONVERT(VARCHAR(7), GETDATE(), 120) AS [YYYY-MM]&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;2006-05&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;MMDDYY&lt;/td&gt;&lt;td&gt;SELECT REPLACE(CONVERT(VARCHAR(10), GETDATE(), 1), &#39;/&#39;, &#39;&#39;) AS [MMDDYY]&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;122506&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;MMDDYYYY&lt;/td&gt;&lt;td&gt;SELECT REPLACE(CONVERT(VARCHAR(10), GETDATE(), 101), &#39;/&#39;, &#39;&#39;) AS [MMDDYYYY]&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;12252006&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;DDMMYY&lt;/td&gt;&lt;td&gt;SELECT REPLACE(CONVERT(VARCHAR(10), GETDATE(), 3), &#39;/&#39;, &#39;&#39;) AS [DDMMYY]&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;240702&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;DDMMYYYY&lt;/td&gt;&lt;td&gt;SELECT REPLACE(CONVERT(VARCHAR(10), GETDATE(), 103), &#39;/&#39;, &#39;&#39;) AS [DDMMYYYY]&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;24072002&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;Mon-YY&amp;nbsp;&lt;sup style=&quot;color: red;&quot;&gt;1&lt;/sup&gt;&lt;/td&gt;&lt;td&gt;SELECT REPLACE(RIGHT(CONVERT(VARCHAR(9), GETDATE(), 6), 6), &#39; &#39;, &#39;-&#39;) AS [Mon-YY]&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;Sep-02&amp;nbsp;&lt;sup style=&quot;color: red;&quot;&gt;1&lt;/sup&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;Mon-YYYY&lt;sup style=&quot;color: red;&quot;&gt;1&lt;/sup&gt;&lt;/td&gt;&lt;td&gt;SELECT REPLACE(RIGHT(CONVERT(VARCHAR(11), GETDATE(), 106), 8), &#39; &#39;, &#39;-&#39;) AS [Mon-YYYY]&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;Sep-2002&amp;nbsp;&lt;sup style=&quot;color: red;&quot;&gt;1&lt;/sup&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;DD-Mon-YY&amp;nbsp;&lt;sup style=&quot;color: red;&quot;&gt;1&lt;/sup&gt;&lt;/td&gt;&lt;td&gt;SELECT REPLACE(CONVERT(VARCHAR(9), GETDATE(), 6), &#39; &#39;, &#39;-&#39;) AS [DD-Mon-YY]&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;25-Dec-05&amp;nbsp;&lt;sup style=&quot;color: red;&quot;&gt;1&lt;/sup&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;DD-Mon-YYYY&amp;nbsp;&lt;sup style=&quot;color: red;&quot;&gt;1&lt;/sup&gt;&lt;/td&gt;&lt;td&gt;SELECT REPLACE(CONVERT(VARCHAR(11), GETDATE(), 106), &#39; &#39;, &#39;-&#39;) AS [DD-Mon-YYYY]&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;25-Dec-2005&lt;sup style=&quot;color: red;&quot;&gt;1&lt;/sup&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.sql-server-helper.com/tips/date-formats.aspx&quot; target=&quot;_blank&quot;&gt;source&lt;/a&gt;

until then,</content><link rel='replies' type='application/atom+xml' href='http://erickwidya.blogspot.com/feeds/2272010168788069193/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/26554202/2272010168788069193' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/2272010168788069193'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/2272010168788069193'/><link rel='alternate' type='text/html' href='http://erickwidya.blogspot.com/2012/09/date-and-time-format-in-sql.html' title='Date and Time format in SQL'/><author><name>eRiCk</name><uri>http://www.blogger.com/profile/06607831852417429737</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-26554202.post-7160413306319769479</id><published>2012-08-28T11:20:00.001+07:00</published><updated>2013-08-22T14:31:29.279+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="some code"/><title type='text'>Search specific string inside Stored Procedure, View, Function, Trigger, Table Name, Table Field in SQL Server</title><content type='html'>this query can be used to search specific string inside, no need to right click &amp;nbsp;- modify - and search manually from Query designer / SSMS&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;br /&gt;
&lt;br /&gt;
DECLARE @NextString NVARCHAR(40)&lt;br /&gt;
DECLARE @Pos INT&lt;br /&gt;
DECLARE @NextPos INT&lt;br /&gt;
DECLARE @String NVARCHAR(40)&lt;br /&gt;
DECLARE @Delimiter NVARCHAR(40)&lt;br /&gt;
DECLARE @Query nvarchar(2000)&lt;br /&gt;
DECLARE @WHERE nvarchar(1000)&lt;br /&gt;
&lt;br /&gt;
DECLARE @Query2 nvarchar(2000)&lt;br /&gt;
DECLARE @Where2 nvarchar(1000)&lt;br /&gt;
&lt;br /&gt;
SET @Query =&lt;br /&gt;
&amp;nbsp;&#39;SELECT DISTINCT so.name, &#39; +&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&#39;CASE so.xtype &#39; +&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &#39;WHEN &#39;&#39;P&#39;&#39; THEN &#39;&#39;SPROC&#39;&#39; &#39; +&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &#39;WHEN &#39;&#39;IF&#39;&#39; THEN &#39;&#39;FUNCTION&#39;&#39; &#39; +&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &#39;WHEN &#39;&#39;FN&#39;&#39; THEN &#39;&#39;FUNCTION&#39;&#39; &#39; +&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &#39;WHEN &#39;&#39;V&#39;&#39; THEN &#39;&#39;VIEW&#39;&#39; &#39; +&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &#39;WHEN &#39;&#39;U&#39;&#39; THEN &#39;&#39;TABLE&#39;&#39; &#39; +&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &#39;WHEN &#39;&#39;TR&#39;&#39; THEN &#39;&#39;TRIGGER&#39;&#39; &#39; +&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&#39;END AS [TYPE] &#39; +&lt;br /&gt;
&amp;nbsp;&#39;FROM syscomments sc &#39; +&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&#39;RIGHT JOIN sysobjects so ON sc.id = so.id &#39; +&lt;br /&gt;
&amp;nbsp;&#39;WHERE &#39;&lt;br /&gt;
SET @String = &#39;cab&#39;&lt;br /&gt;
SET @WHERE = &#39;&#39;&lt;br /&gt;
SET @Where2 = &#39;&#39;&lt;br /&gt;
SET @Delimiter = &#39;,&#39;&lt;br /&gt;
SET @String = &#39;cab&#39; + @Delimiter&lt;br /&gt;
SET @Pos = CHARINDEX(@Delimiter,@String)&lt;br /&gt;
&lt;br /&gt;
WHILE (@pos &amp;lt;&amp;gt; 0)&lt;br /&gt;
BEGIN&lt;br /&gt;
&amp;nbsp;SET @NextString = LTRIM(RTRIM(SUBSTRING(@String, 1, @Pos - 1)))&lt;br /&gt;
&amp;nbsp;PRINT &#39;next: &#39; + @NextString&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 LEN(@WHERE) &amp;gt; 0&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;SET @WHERE = @WHERE + &#39; OR sc.[TEXT] LIKE &#39;&#39;%&#39; + @NextString + &#39;%&#39;&#39;&#39; +&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&#39; OR so.[name] LIKE &#39;&#39;%&#39; + @NextString + &#39;%&#39;&#39;&#39;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;print &#39;42: &#39; + @where2&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;SET @Where2 = @where2 + &#39; OR T0.Name LIKE &#39;&#39;%&#39; + @NextString + &#39;%&#39;&#39; &#39;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;print &#39;42: &#39; + @where2&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;BEGIN&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;SET @WHERE = @WHERE + &#39; sc.[TEXT] LIKE &#39;&#39;%&#39; + @NextString + &#39;%&#39;&#39;&#39; +&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&#39; OR so.[name] LIKE &#39;&#39;%&#39; + @NextString + &#39;%&#39;&#39;&#39;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;print &#39;51: &#39; + @where2&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;SET @Where2 = @Where2 + &#39; t0.Name LIKE &#39;&#39;%&#39; + @NextString + &#39;%&#39;&#39; &#39;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;print &#39;51: &#39; + @where2&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;br /&gt;
&amp;nbsp;SET @String = SUBSTRING(@String, @pos + 1, LEN(@String))&lt;br /&gt;
&amp;nbsp;SET @pos = CHARINDEX(@Delimiter, @String)&lt;br /&gt;
END&lt;br /&gt;
&lt;br /&gt;
SET @WHERE = &#39;so.xtype IN (&#39;&#39;P&#39;&#39;, &#39;&#39;IF&#39;&#39;, &#39;&#39;FN&#39;&#39;, &#39;&#39;V&#39;&#39;, &#39;&#39;U&#39;&#39;, &#39;&#39;TR&#39;&#39;) AND (&#39; + @WHERE + &#39;)&#39;&lt;br /&gt;
&lt;br /&gt;
SET @Query2 =&lt;br /&gt;
&amp;nbsp;&#39;UNION ALL &#39; +&lt;br /&gt;
&amp;nbsp;&#39;SELECT t1.NAME, &#39;&#39;TABLE FIELD&#39;&#39; AS [TYPE] &#39; +&lt;br /&gt;
&amp;nbsp;&#39;FROM syscolumns t0 &#39; +&lt;br /&gt;
&amp;nbsp; &#39;INNER JOIN sysobjects t1 ON t0.ID = t1.ID &#39; +&lt;br /&gt;
&amp;nbsp;&#39;WHERE &#39;&lt;br /&gt;
SELECT @Where2 = &#39;t1.xType = &#39;&#39;U&#39;&#39; &#39; +&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;CASE WHEN LEN(@Where2) &amp;gt; 0 THEN &#39; AND (&#39; + @Where2 + &#39;)&#39; ELSE &#39;&#39; END&lt;br /&gt;
&lt;br /&gt;
PRINT @Query + @WHERE + @Query2 + @Where2&lt;br /&gt;
EXEC (@Query + @WHERE + @Query2 + @Where2)&lt;/blockquote&gt;
until then</content><link rel='replies' type='application/atom+xml' href='http://erickwidya.blogspot.com/feeds/7160413306319769479/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/26554202/7160413306319769479' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/7160413306319769479'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/7160413306319769479'/><link rel='alternate' type='text/html' href='http://erickwidya.blogspot.com/2012/08/search-specific-string-inside-stored.html' title='Search specific string inside Stored Procedure, View, Function, Trigger, Table Name, Table Field in SQL Server'/><author><name>eRiCk</name><uri>http://www.blogger.com/profile/06607831852417429737</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-26554202.post-6672658989454862819</id><published>2012-08-14T14:25:00.001+07:00</published><updated>2014-04-29T10:29:40.846+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="some code"/><title type='text'>Cannot obtain the schema rowset &quot;DBSCHEMA_TABLES_INFO&quot; for OLE DB provider &quot;SQLNCLI&quot; for linked server [linked_server_name]</title><content type='html'>just got this error when try to execute query against LinkServer (SQL 2000) from SQL 2005&lt;br /&gt;
&lt;br /&gt;
eventhough the link can create but i can&#39;t do 4 parts query&lt;br /&gt;
select * from LINKED.DB.DBO.TABLE&lt;br /&gt;
&lt;br /&gt;
the problem because SQL 2000 needs to run certain SP that not exists in master so the LINK query can run&lt;br /&gt;
&lt;span style=&quot;background-color: #444444; color: white;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: #444444; color: white;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;background-color: #444444; color: white;&quot;&gt;&lt;span style=&quot;border: 0px; font-family: &#39;Courier New&#39;; font-size: 10pt; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;create&lt;/span&gt;&lt;span style=&quot;border: 0px; font-family: &#39;Courier New&#39;; font-size: 10pt; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;nbsp;&lt;span style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;procedure&lt;/span&gt;&amp;nbsp;sp_tables_info_rowset_64&lt;/span&gt;&lt;span style=&quot;border: 0px; font-family: &#39;Courier New&#39;; font-size: 10pt; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @table_name&amp;nbsp;&lt;span style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;sysname&lt;/span&gt;&lt;span style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;border: 0px; font-family: &#39;Courier New&#39;; font-size: 10pt; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @table_schema&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;sysname&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;null,&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 0px; font-family: &#39;Courier New&#39;; font-size: 10pt; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 0px; font-family: &#39;Courier New&#39;; font-size: 10pt; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;@table_type&amp;nbsp;&lt;span style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;nvarchar&lt;/span&gt;&lt;span style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;255&lt;span style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;null&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;border: 0px; font-family: &#39;Courier New&#39;; font-size: 10pt; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;as&lt;/span&gt;&lt;span style=&quot;border: 0px; font-family: &#39;Courier New&#39;; font-size: 10pt; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;declare @Result int set @Result = 0&lt;/span&gt;&lt;span style=&quot;border: 0px; font-family: &#39;Courier New&#39;; font-size: 10pt; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;exec&lt;/span&gt;&lt;span style=&quot;border: 0px; font-family: &#39;Courier New&#39;; font-size: 10pt; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;nbsp;@Result =&amp;nbsp;&lt;span style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;sp_tables_info_rowset&lt;/span&gt;&amp;nbsp;@table_name&lt;span style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt;@table_schema&lt;span style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt;&amp;nbsp;@table_type&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;
&lt;br /&gt;
this&amp;nbsp;&lt;a href=&quot;http://joelmansford.wordpress.com/2007/08/10/connecting-sql-server-2005-x64-to-sql-server-7-32bit-as-a-linked-server/&quot; target=&quot;_blank&quot;&gt;solution&lt;/a&gt;&amp;nbsp;originally POST&amp;nbsp;&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, &#39;Bitstream Charter&#39;, serif; font-size: 14px; line-height: 23px;&quot;&gt;by&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: white; border: 0px; color: #333333; font-family: Georgia, &#39;Bitstream Charter&#39;, serif; font-size: 14px; line-height: 23px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Marek Adamczuk&lt;/span&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: white; border: 0px; color: #333333; font-family: Georgia, &#39;Bitstream Charter&#39;, serif; font-size: 14px; line-height: 23px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; border: 0px; color: #333333; font-family: Georgia, &#39;Bitstream Charter&#39;, serif; font-size: 14px; line-height: 23px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;until then&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://erickwidya.blogspot.com/feeds/6672658989454862819/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/26554202/6672658989454862819' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/6672658989454862819'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26554202/posts/default/6672658989454862819'/><link rel='alternate' type='text/html' href='http://erickwidya.blogspot.com/2012/08/cannot-obtain-schema-rowset.html' title='Cannot obtain the schema rowset &quot;DBSCHEMA_TABLES_INFO&quot; for OLE DB provider &quot;SQLNCLI&quot; for linked server [linked_server_name]'/><author><name>eRiCk</name><uri>http://www.blogger.com/profile/06607831852417429737</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>