<?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-6944609836742303576</id><updated>2024-08-30T08:32:05.729-07:00</updated><title type='text'>athinkr</title><subtitle type='html'>Random thoughts on all different types of things.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://athinkr.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6944609836742303576/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://athinkr.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Unknown</name><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>17</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6944609836742303576.post-8308794533125091235</id><published>2015-10-05T08:52:00.000-07:00</published><updated>2015-10-05T08:52:19.084-07:00</updated><title type='text'>Sql Server 2008 Management Studio: Prevent saving changes that require table re-creation</title><content type='html'>There are times when a database developer may want to save changes to a table without dropping and re-creating the table.&lt;br /&gt;
However, sql server 2008 management studio doesn&#39;t always allow this to happen. Luckily, there is something you can do about it.&lt;br /&gt;
&lt;br /&gt;
When inside of SQL Server Management studio:&lt;br /&gt;
1. Go to Tools menu -&gt; Click on Options&lt;br /&gt;
You will see the Options window appear. &lt;br /&gt;
It will look like this:&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/AVvXsEh7l-Yp6zRQuR_vYE9LWsqVXNtNM0zRhqRkdLYPUIS-jvUvc7x6TaOt3N5gtWsM92ENWDIRODzHjw8hjyBY9ahGkPUU95PYWzKNC1bDVog9Trtnr4D-hfwrmRL9qKaaZn0MqnJui5T95jE/s1600/OptionsWindow.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/AVvXsEh7l-Yp6zRQuR_vYE9LWsqVXNtNM0zRhqRkdLYPUIS-jvUvc7x6TaOt3N5gtWsM92ENWDIRODzHjw8hjyBY9ahGkPUU95PYWzKNC1bDVog9Trtnr4D-hfwrmRL9qKaaZn0MqnJui5T95jE/s320/OptionsWindow.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
2. Click on the triangle next to &quot;Designers&quot; and then click on the &quot;Table and Database Designers&quot; section.&lt;br /&gt;
It should then look like this:&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/AVvXsEgymJUASg2C5w4PTFfYLktejfu9-1hFH9cH5RV3Dl7tndZLWDRMPv2dz6KiJK7w_zOK-DyTje3zCdH2329qz5qAJn8GSi0lb4gQPR5iLswyNFs3MkTxRodjzuR59VQO6haK7x7pCpnCLXU/s1600/OptionsWindow2.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/AVvXsEgymJUASg2C5w4PTFfYLktejfu9-1hFH9cH5RV3Dl7tndZLWDRMPv2dz6KiJK7w_zOK-DyTje3zCdH2329qz5qAJn8GSi0lb4gQPR5iLswyNFs3MkTxRodjzuR59VQO6haK7x7pCpnCLXU/s320/OptionsWindow2.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
3. Uncheck the &quot;Prevent saving changes that require table re-creation&quot;.&lt;br /&gt;
4. Click OK&lt;br /&gt;
&lt;br /&gt;
You should now be able to save changes as long as the save doesn&#39;t take too long.&lt;br /&gt;
NOTE: If the table you are trying to save changes too has alot of data in it, you may want to change the &quot;Command Timeout&quot; to not timeout after 30 seconds.&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/AVvXsEj0CTDAyIbzdCliSlz7RBzm6lNZD7xxzrd46KL0Q2e6ZFYiUMSIGQMFleyzHRvQSxCr4Lcjm8cNxyokTg3uNnoKzBmu8CYJykiGwuZiJtE09wG56x58Qegl1-zyg_nSxeq7lap5brHP2ZU/s1600/OptionsWindow3.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/AVvXsEj0CTDAyIbzdCliSlz7RBzm6lNZD7xxzrd46KL0Q2e6ZFYiUMSIGQMFleyzHRvQSxCr4Lcjm8cNxyokTg3uNnoKzBmu8CYJykiGwuZiJtE09wG56x58Qegl1-zyg_nSxeq7lap5brHP2ZU/s320/OptionsWindow3.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://athinkr.blogspot.com/feeds/8308794533125091235/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://athinkr.blogspot.com/2015/10/sql-server-2008-management-studio.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6944609836742303576/posts/default/8308794533125091235'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6944609836742303576/posts/default/8308794533125091235'/><link rel='alternate' type='text/html' href='http://athinkr.blogspot.com/2015/10/sql-server-2008-management-studio.html' title='Sql Server 2008 Management Studio: Prevent saving changes that require table re-creation'/><author><name>Unknown</name><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/AVvXsEh7l-Yp6zRQuR_vYE9LWsqVXNtNM0zRhqRkdLYPUIS-jvUvc7x6TaOt3N5gtWsM92ENWDIRODzHjw8hjyBY9ahGkPUU95PYWzKNC1bDVog9Trtnr4D-hfwrmRL9qKaaZn0MqnJui5T95jE/s72-c/OptionsWindow.PNG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6944609836742303576.post-3414600928016274933</id><published>2015-07-07T07:21:00.002-07:00</published><updated>2015-07-07T07:21:42.621-07:00</updated><title type='text'>Closing stream after error</title><content type='html'>Sometimes there are cases where it is appropriate to create one streamReader to be used with multiple files like the code below. But what if an error were to occur before the stream closed. Uh oh, theres a problem. Our catch would catch the exception, but we would get an error when an attept is made to move the file to the Error directory. What do we do?&lt;br /&gt;
Easy, wrap your stream in a using statement and remove the &quot;stream.Close()&quot; because it&#39;s no longer needed. This will make sure the stream is closed even if there is an exception during the Parsing of the XML.&lt;br /&gt;
The file can be moved successfully and you will not have to worry about memory leaks.&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;StreamReader stream;&lt;br /&gt;
DirectoryInfo ImportDir = new DirectoryInfo(importFileDirectory);&lt;br /&gt;
var Files = Directory.GetFiles(importFileDirectory, &quot;*.dat&quot;).Select(fn =&gt; new FileInfo(fn)).OrderBy(f =&gt; f.Name);&lt;br /&gt;
foreach (FileInfo file in Files)&lt;br /&gt;
{&lt;br /&gt;
   if (checkFileAvailable(file.FullName))&lt;br /&gt;
   {&lt;br /&gt;
       try&lt;br /&gt;
       {&lt;br /&gt;
&lt;b&gt;           BatchID = file.Name.Remove(file.Name.Length - 4);&lt;br /&gt;
           xmldoc.Load(stream);&lt;br /&gt;
           ParseXML(xmldoc);&lt;br /&gt;
           &lt;br /&gt;
           stream.Close();&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
           //move file to archive folder&lt;br /&gt;
           DateTime dt = DateTime.Now;&lt;br /&gt;
           string s = dt.ToString(&quot;yyMMddHHmmss&quot;);&lt;br /&gt;
           System.IO.File.Move(file.FullName, archiveFileDirectory + file.Name.Remove(file.Name.Length - 4) + s + file.Extension);&lt;br /&gt;
           &lt;br /&gt;
       }&lt;br /&gt;
       catch (Exception ex)&lt;br /&gt;
       {&lt;br /&gt;
           //move file to Error folder&lt;br /&gt;
           DateTime dt = DateTime.Now;&lt;br /&gt;
           string s = dt.ToString(&quot;yyMMddHHmmss&quot;);&lt;br /&gt;
           System.IO.File.Move(file.FullName, errorFileDirectory + file.Name.Remove(file.Name.Length - 4) + s + file.Extension);&lt;br /&gt;
&lt;br /&gt;
           LogDescription = string.Format(&quot;Import ERROR!&quot;);&lt;br /&gt;
           Logger.Log_Err(LogDescription, ex);&lt;br /&gt;
           Logger.LogDistributionResult(&quot;0&quot;, &quot;0&quot;, &quot;0&quot;, &quot;C4&quot;, &quot;F&quot;, &quot;IN&quot;, BatchID, &quot;File Failed to Load: Exception: &quot; + ex);&lt;br /&gt;
           continue;&lt;br /&gt;
       }&lt;br /&gt;
   }&lt;br /&gt;
}&lt;/blockquote&gt;&lt;br /&gt;
This is the way the new code will look inside the try.&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;//Use a using to make sure a stream is closed even if there is an exception.&lt;br /&gt;
using (stream = new StreamReader(file.FullName))&lt;br /&gt;
{&lt;br /&gt;
   BatchID = file.Name.Remove(file.Name.Length - 4);&lt;br /&gt;
   xmldoc.Load(stream);&lt;br /&gt;
   ParseXML(xmldoc);&lt;br /&gt;
}&lt;br /&gt;
//move file to archive folder&lt;br /&gt;
DateTime dt = DateTime.Now;&lt;br /&gt;
string s = dt.ToString(&quot;yyMMddHHmmss&quot;);&lt;br /&gt;
System.IO.File.Move(file.FullName, archiveFileDirectory + file.Name.Remove(file.Name.Length - 4) + s + file.Extension);&lt;/blockquote&gt;</content><link rel='replies' type='application/atom+xml' href='http://athinkr.blogspot.com/feeds/3414600928016274933/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://athinkr.blogspot.com/2015/07/closing-stream-after-error.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6944609836742303576/posts/default/3414600928016274933'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6944609836742303576/posts/default/3414600928016274933'/><link rel='alternate' type='text/html' href='http://athinkr.blogspot.com/2015/07/closing-stream-after-error.html' title='Closing stream after error'/><author><name>Unknown</name><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-6944609836742303576.post-1623499785429994309</id><published>2015-06-27T10:49:00.001-07:00</published><updated>2015-06-27T10:59:18.808-07:00</updated><title type='text'>God crushes rebellion</title><content type='html'>&lt;div&gt;&lt;div&gt;Numbers 16:1-5,19,32-33 NLT&lt;/div&gt;&lt;div&gt;[1] One day Korah son of Izhar, a descendant of Kohath son of Levi, conspired with Dathan and Abiram, the sons of Eliab, and On son of Peleth, from the tribe of Reuben. [2] They incited a rebellion against Moses, along with 250 other leaders of the community, all prominent members of the assembly. [3] They united against Moses and Aaron and said, &quot;You have gone too far! The whole community of Israel has been set apart by the LORD, and he is with all of us. What right do you have to act as though you are greater than the rest of the LORD&#39;s people?&quot; [4] When Moses heard what they were saying, he fell face down on the ground. [5] Then he said to Korah and his followers, &quot;Tomorrow morning the LORD will show us who belongs to him and who is holy. The LORD will allow only those whom he selects to enter his own presence. [19] Meanwhile, Korah had stirred up the entire community against Moses and Aaron, and they all gathered at the Tabernacle entrance. Then the glorious presence of the LORD appeared to the whole community, [32] The earth opened its mouth and swallowed the men, along with their households and all their followers who were standing with them, and everything they owned. [33] So they went down alive into the grave, along with all their belongings. The earth closed over them, and they all vanished from among the people of Israel.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgba(0, 0, 0, 0.701961); font-family: UICTFontTextStyleBody; font-size: 14px; -webkit-composition-fill-color: rgba(130, 98, 83, 0.0980392);&quot;&gt;Korah and his follower tried to bring down Moses and Aaron by saying that him and his people were just as Holy as the chosen servants of God (Moses and Aaron). It was rebellion and God dealt with them swiftly. Never underestimate the power and favor God has given a leader in your church because if you go against Gods chosen, you could be dealt with in a way that is not so wanted. Also, recognize that if you are a leader in your church, there will most always be someone that doesn&#39;t like or appreciate you.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://athinkr.blogspot.com/feeds/1623499785429994309/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://athinkr.blogspot.com/2015/06/god-crushes-rebellion.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6944609836742303576/posts/default/1623499785429994309'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6944609836742303576/posts/default/1623499785429994309'/><link rel='alternate' type='text/html' href='http://athinkr.blogspot.com/2015/06/god-crushes-rebellion.html' title='God crushes rebellion'/><author><name>Unknown</name><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-6944609836742303576.post-4076388325245080794</id><published>2015-06-02T07:16:00.002-07:00</published><updated>2015-06-02T07:16:57.695-07:00</updated><title type='text'>Using the table value constructor to specify multiple values in the FROM clause of a SELECT statement</title><content type='html'>SELECT a, b FROM (VALUES (1, 2), (3, 4), (5, 6), (7, 8), (9, 10) ) AS MyTable(a, b);&lt;br /&gt;
When I first saw this syntax, I wasn&#39;t sure if it would work. However, after testing, this worked perfectly. &lt;br /&gt;
This tsql statement could save alot of time for the people that don&#39;t need to create a permanent object in the database, but is looking for a quick fix.&lt;br /&gt;
This statement could be used as a function or it could be used to select multiple values to insert into a table.&lt;br /&gt;
&lt;br /&gt;
Here is a situation where it could be used in the place of a function.&lt;br /&gt;
EX: &lt;br /&gt;
Select @dCollected = (SELECT a, b FROM (VALUES (1, 2), (3, 4), (5, 6), (7, 8), (9, 10) ) AS MyTable(a, b))&lt;br /&gt;
&lt;br /&gt;
Here is a situation where it could be used in the place filling a temporary table and selecting from it.&lt;br /&gt;
EX: &lt;br /&gt;
SELECT a, b FROM (VALUES (1, 2), (3, 4), (5, 6), (7, 8), (9, 10) ) AS MyTable(a, b)&lt;br /&gt;
Union&lt;br /&gt;
Select a, b From PermanentOrTempTable&lt;br /&gt;
&lt;br /&gt;
This is a good use of this syntax.&lt;br /&gt;
However, I would not recommend using this often as it could lead to spagetti code and cannot be reused unless pasted over and over again which is bad development.&lt;br /&gt;
&lt;br /&gt;
Reference: &lt;a href=&quot;https://msdn.microsoft.com/en-us/library/dd776382.aspx&quot;&gt;https://msdn.microsoft.com/en-us/library/dd776382.aspx&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://athinkr.blogspot.com/feeds/4076388325245080794/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://athinkr.blogspot.com/2015/06/using-table-value-constructor-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6944609836742303576/posts/default/4076388325245080794'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6944609836742303576/posts/default/4076388325245080794'/><link rel='alternate' type='text/html' href='http://athinkr.blogspot.com/2015/06/using-table-value-constructor-to.html' title='Using the table value constructor to specify multiple values in the FROM clause of a SELECT statement'/><author><name>Unknown</name><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-6944609836742303576.post-2712637889659201783</id><published>2015-05-22T06:15:00.002-07:00</published><updated>2015-05-22T06:15:50.653-07:00</updated><title type='text'>SSRS Dynamic Grouping</title><content type='html'>At some point, you will want your users to be able to choose what to group their reports by. This article written by Chris Hays shows perfectly how to create a dynamic grouping:&lt;br /&gt;
&lt;br /&gt;
http://blogs.msdn.com/b/chrishays/archive/2004/07/15/dynamicgrouping.aspx?Redirected=true&lt;br /&gt;
&lt;br /&gt;
This is definately worth checking out.</content><link rel='replies' type='application/atom+xml' href='http://athinkr.blogspot.com/feeds/2712637889659201783/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://athinkr.blogspot.com/2015/05/ssrs-dynamic-grouping.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6944609836742303576/posts/default/2712637889659201783'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6944609836742303576/posts/default/2712637889659201783'/><link rel='alternate' type='text/html' href='http://athinkr.blogspot.com/2015/05/ssrs-dynamic-grouping.html' title='SSRS Dynamic Grouping'/><author><name>Unknown</name><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-6944609836742303576.post-2633397889353884042</id><published>2015-05-22T06:14:00.004-07:00</published><updated>2015-05-22T06:14:45.464-07:00</updated><title type='text'>FoxPro shorthand syntax for searching a string</title><content type='html'>The dollar sign in between two strings is a search for symbol like the following:&lt;br /&gt;
cSearchFor $ cSearchIn</content><link rel='replies' type='application/atom+xml' href='http://athinkr.blogspot.com/feeds/2633397889353884042/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://athinkr.blogspot.com/2015/05/foxpro-shorthand-syntax-for-searching.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6944609836742303576/posts/default/2633397889353884042'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6944609836742303576/posts/default/2633397889353884042'/><link rel='alternate' type='text/html' href='http://athinkr.blogspot.com/2015/05/foxpro-shorthand-syntax-for-searching.html' title='FoxPro shorthand syntax for searching a string'/><author><name>Unknown</name><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-6944609836742303576.post-7259276726183323403</id><published>2015-05-22T06:13:00.004-07:00</published><updated>2015-05-22T06:13:59.295-07:00</updated><title type='text'>How to perform a database backup with tsql</title><content type='html'>Most people (that have used sql server) know how to backup and restore a database as a new name from Sql Server Management Studio, but it‘s not always quite so apparent how to backup and restore a database as a different name in tsql. Here is just a reminder as to how to backup and restore into a different name. This can also be used for seperating “Development” and “Test”.&lt;br /&gt;
&lt;br /&gt;
— Perform database backups&lt;br /&gt;
&lt;br /&gt;
print ‘Backup Development database’&lt;br /&gt;
&lt;br /&gt;
BACKUP DATABASE [Development] &lt;br /&gt;
&lt;br /&gt;
TO  DISK = N’G:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Backup\Development\Development_full_backup.bak’&lt;br /&gt;
&lt;br /&gt;
            WITH NOFORMAT, INIT,  NAME = N’Development-Full Database Backup’, SKIP, NOREWIND, NOUNLOAD,  STATS = 10&lt;br /&gt;
&lt;br /&gt;
GO&lt;br /&gt;
&lt;br /&gt;
print ‘Backup Test database’&lt;br /&gt;
&lt;br /&gt;
BACKUP DATABASE [Test]&lt;br /&gt;
&lt;br /&gt;
            TO  DISK = N’G:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Backup\Test\Test_full_backup.bak’&lt;br /&gt;
&lt;br /&gt;
            WITH NOFORMAT, INIT,  NAME = N’Test-Full Database Backup’, SKIP, NOREWIND, NOUNLOAD,  STATS = 10&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
— Perform database restores from SeconddaryDev&lt;br /&gt;
&lt;br /&gt;
use master&lt;br /&gt;
&lt;br /&gt;
go&lt;br /&gt;
&lt;br /&gt;
Alter Database [Test] set Auto_Update_Statistics_Async OFF&lt;br /&gt;
&lt;br /&gt;
go&lt;br /&gt;
&lt;br /&gt;
Alter Database [Test] set Single_User With Rollback Immediate &lt;br /&gt;
&lt;br /&gt;
go&lt;br /&gt;
&lt;br /&gt;
print ‘Restore Development to Test’&lt;br /&gt;
&lt;br /&gt;
RESTORE DATABASE [Test]&lt;br /&gt;
&lt;br /&gt;
            FROM  DISK = N’G:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Backup\Development\Development_full_backup.bak’&lt;br /&gt;
&lt;br /&gt;
            WITH  FILE = 1,  NOUNLOAD,  REPLACE,  STATS = 10&lt;br /&gt;
&lt;br /&gt;
GO&lt;br /&gt;
&lt;br /&gt;
Alter Database [Test] set Multi_User&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
go</content><link rel='replies' type='application/atom+xml' href='http://athinkr.blogspot.com/feeds/7259276726183323403/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://athinkr.blogspot.com/2015/05/how-to-perform-database-backup-with-tsql.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6944609836742303576/posts/default/7259276726183323403'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6944609836742303576/posts/default/7259276726183323403'/><link rel='alternate' type='text/html' href='http://athinkr.blogspot.com/2015/05/how-to-perform-database-backup-with-tsql.html' title='How to perform a database backup with tsql'/><author><name>Unknown</name><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-6944609836742303576.post-8545516325515915652</id><published>2013-12-05T08:48:00.000-08:00</published><updated>2013-12-05T08:48:31.544-08:00</updated><title type='text'>Windows service....not extremely intuitive</title><content type='html'>&lt;p&gt;I decided to try to create a windows service (that looks for rows every minute in a particular table in a database and does something when it finds a row in that table) today and when I first dove into the Visual Studio project I realized something. I didn&#39;t know where to put the things I wanted to happen while the service was running.&lt;/p&gt;&lt;p&gt;Yes, this is a very newbie thing for windows services, but it just didn&#39;t seem very easily understandable like other projects have been in the past.&lt;/p&gt;&lt;p&gt;This is what I seen when I first created the project after selecting the &quot;View Code&quot; part of the designer:&lt;/p&gt;&lt;p&gt;&lt;img src=&quot;http://lh3.ggpht.com/-EX0baojlalc/UqCl8UKhQyI/AAAAAAAAFL4/AMedHxeljXE/%25255BUNSET%25255D.png&quot; alt=&quot;&quot; width=&quot;365&quot; height=&quot;123&quot; /&gt;&lt;/p&gt;&lt;p&gt;I guess this is typical. At least I know where to put the code when I&#39;m starting and stopping the service.&lt;/p&gt;&lt;p&gt;Well, here I am. Lost. Where do I put my code to check the database.&lt;/p&gt;&lt;p&gt;Thank God for google. I did a little searching and found a great post at:&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://tutorials.csharp-online.net/Creating_a_.NET_Windows_Service%E2%80%94Alternative_1:_Use_a_Separate_Thread&quot;&gt;http://tutorials.csharp-online.net/Creating_a_.NET_Windows_Service%E2%80%94Alternative_1:_Use_a_Separate_Thread&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Best part was this:&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;&lt;span style=&quot;background-color: #ffffff; color: #000000;&quot;&gt;&quot;&lt;span style=&quot;font-family: sans-serif; font-size: 13px; line-height: 19.046875px;&quot;&gt;When you start the service, Windows won&#39;t get feedback that the service has started, since the service blocks in the OnStart call. Windows will promptly report an appropriate error. Another catch is that you can&#39;t tell the service to stop, because it never leaves the OnStart event!&quot;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;&lt;span style=&quot;background-color: #ffffff; color: #000000;&quot;&gt;&lt;span style=&quot;font-family: sans-serif; font-size: 13px; line-height: 19.046875px;&quot;&gt;I tried putting everything in the OnStart method in the past and could never figure out why my service wasn&#39;t working right.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;This tutorial saved my life. Not really, but it did help me to figure out why my windows service would never start if I put everything in the OnStart method.&lt;/p&gt;&lt;p&gt;My answer was this: I need to put my &quot;Working code&quot; into it&#39;s own thread. After I got this revelation, things started flowing a little easier.&lt;/p&gt;&lt;p&gt; &lt;/p&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6944609836742303576/posts/default/8545516325515915652'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6944609836742303576/posts/default/8545516325515915652'/><link rel='alternate' type='text/html' href='http://athinkr.blogspot.com/2013/11/windows-servicenot-extremely-intuitive.html' title='Windows service....not extremely intuitive'/><author><name>Unknown</name><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="http://lh3.ggpht.com/-EX0baojlalc/UqCl8UKhQyI/AAAAAAAAFL4/AMedHxeljXE/s72-c/%25255BUNSET%25255D.png" height="72" width="72"/></entry><entry><id>tag:blogger.com,1999:blog-6944609836742303576.post-2111382343825922054</id><published>2013-12-05T08:46:00.000-08:00</published><updated>2013-12-05T08:47:32.312-08:00</updated><title type='text'>How to reseed a table via TSQL in SQL Server</title><content type='html'>Sometimes it&#39;s useful to restart the identity of a table back to a certain number.  DBCC CHECKIDENT ([TableName],reseed,0)</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6944609836742303576/posts/default/2111382343825922054'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6944609836742303576/posts/default/2111382343825922054'/><link rel='alternate' type='text/html' href='http://athinkr.blogspot.com/2013/11/how-to-reseed-table-via-tsql-in-sql.html' title='How to reseed a table via TSQL in SQL Server'/><author><name>Unknown</name><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></entry><entry><id>tag:blogger.com,1999:blog-6944609836742303576.post-9216211239191523757</id><published>2013-12-05T08:45:00.000-08:00</published><updated>2013-12-05T08:47:13.200-08:00</updated><title type='text'>How to get the identity of a row that was last inserted into a specific table in a SQL Server database.</title><content type='html'>Use the &lt;blockquote&gt;&lt;b&gt;IDENT_CURRENT&lt;/b&gt;&lt;/blockquote&gt;key word.&lt;br /&gt;
Here is the syntax: &lt;b&gt;IDENT_CURRENT(&#39;stringTableName&#39;)&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
It could be used like this: &lt;br /&gt;
&lt;br /&gt;
Declare @TestId int&lt;br /&gt;
set @TestId = IDENT_CURRENT(&#39;TestTable&#39;)&lt;br /&gt;
&lt;br /&gt;
or it can be simply selected:&lt;br /&gt;
Select IDENT_CURRENT(&#39;TestTable&#39;)&lt;br /&gt;
&lt;br /&gt;
Here is a link to Microsofts definition: &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ms175098.aspx&quot;&gt;IDENT_CURRENT&lt;/a&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6944609836742303576/posts/default/9216211239191523757'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6944609836742303576/posts/default/9216211239191523757'/><link rel='alternate' type='text/html' href='http://athinkr.blogspot.com/2013/11/how-to-get-identity-of-row-that-was.html' title='How to get the identity of a row that was last inserted into a specific table in a SQL Server database.'/><author><name>Unknown</name><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></entry><entry><id>tag:blogger.com,1999:blog-6944609836742303576.post-5643986786049601677</id><published>2013-11-04T08:38:00.000-08:00</published><updated>2014-01-30T06:04:46.866-08:00</updated><title type='text'>Setting up SSIS package to run automated.</title><content type='html'>&lt;p&gt;There may be a time when a load of data from another server of updating may need to be done automated via SQL server. If an SSIS package is needed for this type of a situation. A job on SQL server can be created and inside one of the steps of that job is where the SSIS would be put as shown below.&lt;/p&gt;&lt;p&gt;&lt;img src=&quot;http://lh3.ggpht.com/-Zt92SlurwNw/UupbX47Fd_I/AAAAAAAAFtk/7rSptH8gTfs/%25255BUNSET%25255D.png&quot; alt=&quot;&quot; width=&quot;505&quot; height=&quot;467&quot; /&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://athinkr.blogspot.com/feeds/5643986786049601677/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://athinkr.blogspot.com/2013/11/how-to-perform-database-backup-with-tsql.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6944609836742303576/posts/default/5643986786049601677'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6944609836742303576/posts/default/5643986786049601677'/><link rel='alternate' type='text/html' href='http://athinkr.blogspot.com/2013/11/how-to-perform-database-backup-with-tsql.html' title='Setting up SSIS package to run automated.'/><author><name>Unknown</name><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="http://lh3.ggpht.com/-Zt92SlurwNw/UupbX47Fd_I/AAAAAAAAFtk/7rSptH8gTfs/s72-c/%25255BUNSET%25255D.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6944609836742303576.post-6763924242790385586</id><published>2013-09-26T07:56:00.002-07:00</published><updated>2013-11-12T13:56:22.179-08:00</updated><title type='text'></title><content type='html'>&lt;div border: 0px; clear: both; font-family: Arial, &#39;Liberation Sans&#39;, &#39;DejaVu Sans&#39;, sans-serif; font-size: 14px; line-height: 18px; margin-bottom: 1em; padding: 0px; vertical-align: baseline; word-wrap: break-word;&quot;&gt;
Just found out how to generate insert statements in SQL Server Management Studio 2008. I had done it before, but this will be as a reminder.&lt;/div&gt;
&lt;ol style=&quot; border: 0px; font-family: Arial, &#39;Liberation Sans&#39;, &#39;DejaVu Sans&#39;, sans-serif; font-size: 14px; line-height: 18px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 1em 30px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;li style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline; word-wrap: break-word;&quot;&gt;Right click on the database and go to&amp;nbsp;&lt;strong style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Tasks -&amp;gt; Generate Scripts&lt;/strong&gt;&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline; word-wrap: break-word;&quot;&gt;Select the tables (or object) that you want to generate the script against.&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline; word-wrap: break-word;&quot;&gt;Go to&amp;nbsp;&lt;strong style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Set scripting options&lt;/strong&gt;&amp;nbsp;and click on the&amp;nbsp;&lt;strong style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Advanced&lt;/strong&gt;&amp;nbsp;button.&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline; word-wrap: break-word;&quot;&gt;In the&amp;nbsp;&lt;strong style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;General&lt;/strong&gt;&amp;nbsp;category, go to&amp;nbsp;&lt;strong style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Type of data to script&lt;/strong&gt;&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline; word-wrap: break-word;&quot;&gt;There are 3 options:&amp;nbsp;&lt;strong style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Schema Only&lt;/strong&gt;,&amp;nbsp;&lt;strong style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Data Only&lt;/strong&gt;, and&amp;nbsp;&lt;strong style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Schema and Data&lt;/strong&gt;. Select the appropriate option and click on&amp;nbsp;&lt;strong style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;OK&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;
</content><link rel='replies' type='application/atom+xml' href='http://athinkr.blogspot.com/feeds/6763924242790385586/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://athinkr.blogspot.com/2013/09/just-found-out-how-to-generate-insert.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6944609836742303576/posts/default/6763924242790385586'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6944609836742303576/posts/default/6763924242790385586'/><link rel='alternate' type='text/html' href='http://athinkr.blogspot.com/2013/09/just-found-out-how-to-generate-insert.html' title=''/><author><name>Unknown</name><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-6944609836742303576.post-170252243623364556</id><published>2013-07-26T13:15:00.000-07:00</published><updated>2013-07-26T13:15:02.179-07:00</updated><title type='text'>Multiple columns into a pivot. </title><content type='html'>Putting multiple columns into a pivot.&lt;br /&gt;
Took some time to figure out, but I got it to work.&lt;br /&gt;
&lt;br /&gt;
1. Make data types of all columns the same.&lt;br /&gt;
Description: The idea is to make all columns of the same data type (Base query)&lt;br /&gt;
&lt;br /&gt;
2. Unpivot the columns so they have a key, column name, and column value.&lt;br /&gt;
Description: Put all columns into one column with the &quot;Column name and value&quot; into a &quot;ColName&quot; field AND put the columns value into another field called &quot;ColValue&quot; (unpvt).&lt;br /&gt;
&lt;br /&gt;
3. Finally, Pivot the values out by the &quot;ColName&quot; column&lt;br /&gt;
Description: The key and the values that were pivoted is what you want to select on this last step.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
,Base AS (&lt;br /&gt;
&amp;nbsp; &amp;nbsp; SELECT theKey, Field3, Cast(Field1 as varchar) as Field1, Cast(Field2 as varchar) as Field2, cast(Field3 as varchar) as Field32&lt;br /&gt;
&amp;nbsp; &amp;nbsp; FROM theData&lt;br /&gt;
)&lt;br /&gt;
,unpvt AS (&lt;br /&gt;
SELECT theKey, ColName + CONVERT(varchar,&amp;nbsp;Field3) AS ColName, ColValue&lt;br /&gt;
FROM Base&lt;br /&gt;
UNPIVOT (ColValue FOR ColName IN (Field1,&amp;nbsp;Field2, Field32)) AS pvt&lt;br /&gt;
)&lt;br /&gt;
,repvt as (&lt;br /&gt;
SELECT theKey, Field1P, Field2P, Field32P, Field1R, Field2R, Field32R, Field1S, Field2S, Field32S, Field1C,&amp;nbsp;Field2C, Field32C&lt;br /&gt;
FROM unpvt&lt;br /&gt;
PIVOT (MIN(ColValue) FOR ColName IN (Field1P, Field2P, Field32P, Field1R, Field2R, Field32R,&amp;nbsp;Field1S, ModIdS, Field32S, Field1C, Field2C, Field32C)) AS pvt&lt;br /&gt;
)</content><link rel='replies' type='application/atom+xml' href='http://athinkr.blogspot.com/feeds/170252243623364556/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://athinkr.blogspot.com/2013/07/multiple-columns-into-pivot.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6944609836742303576/posts/default/170252243623364556'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6944609836742303576/posts/default/170252243623364556'/><link rel='alternate' type='text/html' href='http://athinkr.blogspot.com/2013/07/multiple-columns-into-pivot.html' title='Multiple columns into a pivot. '/><author><name>Unknown</name><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-6944609836742303576.post-5353433139151025599</id><published>2013-07-12T07:56:00.000-07:00</published><updated>2013-07-12T07:56:09.135-07:00</updated><title type='text'>Opening Remote SQL Server through VPN</title><content type='html'>I wanted to be able to open sql server on my own machine and use the vpn as the connection. I had to create a shortcut on my desktop to login through the VPN.&lt;br /&gt;
1.Create shortcut on desktop and add the following extension:&lt;br /&gt;
C:\Windows\System32\runas.exe /netonly /user:remotedomain\remoteusername &quot;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\Ssms.exe&quot;&lt;br /&gt;
&lt;br /&gt;
2. Connect to VPN&lt;br /&gt;
3. Double click on ShortCut to open Sql Server.&lt;br /&gt;
NOTE: You will need to login with the remote password when you double click on the shortcut.&lt;br /&gt;
FYI: Also, I had to have the ip address on the box that sql server was being hosted on to make it work.&lt;br /&gt;
Hope this helps someone.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://athinkr.blogspot.com/feeds/5353433139151025599/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://athinkr.blogspot.com/2013/07/opening-remote-sql-server-through-vpn.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6944609836742303576/posts/default/5353433139151025599'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6944609836742303576/posts/default/5353433139151025599'/><link rel='alternate' type='text/html' href='http://athinkr.blogspot.com/2013/07/opening-remote-sql-server-through-vpn.html' title='Opening Remote SQL Server through VPN'/><author><name>Unknown</name><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-6944609836742303576.post-5836126628835720820</id><published>2013-07-05T13:08:00.003-07:00</published><updated>2013-07-05T13:08:57.801-07:00</updated><title type='text'>Here is a script that generates a script to check each column in a particular table whether they are completely NULL.</title><content type='html'>&amp;nbsp;A person would only need to take the UNION ALL off of the ending to run it with no problems.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Declare @NULL_COLUMNS TABLE(&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;table_name varchar(100),&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;[schema_name] varchar(130),&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;column_name varchar(150),&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;SelectStatement varchar(max)&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
Declare @Table_Name varchar(30)&lt;br /&gt;
&lt;br /&gt;
set @Table_Name = &#39;TableName&#39;&lt;br /&gt;
&lt;br /&gt;
Insert Into @NULL_COLUMNS&lt;br /&gt;
Select&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;t.name AS table_name,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;SCHEMA_NAME(schema_id) AS schema_name,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;c.name AS column_name,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&#39;Select &#39;&#39;&#39; + SCHEMA_NAME(schema_id) + &#39;.&#39; + t.name + &#39;.&#39; + c.name + &#39; - &#39;&#39; + Cast(isnull(AN.AmountNULL,0) as varchar(20)) + &#39;&#39;/&#39;&#39; + &amp;nbsp;Cast(count(1) as varchar(20)) + &#39;&#39; is NULL &#39;&#39; as [Column], isnull(AN.AmountNULL,0) as AmountNULL, count(1) as Total from &#39;+ SCHEMA_NAME(schema_id) + &#39;.&#39; &amp;nbsp;+ t.name + &#39; ai left join (Select &#39;&#39;&#39; + c.name + &#39;&#39;&#39; as ColumnName, count(1) as AmountNULL from &#39;+ SCHEMA_NAME(schema_id) + &#39;.&#39; + t.name + &#39; where &#39; + c.name + &#39; is null ) AN on AN.ColumnName = &#39;&#39;&#39; + c.name + &#39;&#39;&#39; group by isnull(AN.AmountNULL,0) UNION ALL &#39; &amp;nbsp;as SelectStatement&lt;br /&gt;
FROM sys.tables AS t&lt;br /&gt;
INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID&lt;br /&gt;
WHERE c.name not in &amp;nbsp;(&#39;CreatedBy&#39;,&#39;CreatedDate&#39;,&#39;LastModified&#39;,&#39;LastModifiedBy&#39;)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;and c.is_identity &amp;lt;&amp;gt; 1&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;and t.name = @Table_Name&lt;br /&gt;
ORDER BY schema_name, table_name;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Select * from @NULL_COLUMNS&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://athinkr.blogspot.com/feeds/5836126628835720820/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://athinkr.blogspot.com/2013/07/here-is-script-that-generates-script-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6944609836742303576/posts/default/5836126628835720820'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6944609836742303576/posts/default/5836126628835720820'/><link rel='alternate' type='text/html' href='http://athinkr.blogspot.com/2013/07/here-is-script-that-generates-script-to.html' title='Here is a script that generates a script to check each column in a particular table whether they are completely NULL.'/><author><name>Unknown</name><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-6944609836742303576.post-8183714501192372226</id><published>2013-06-17T14:18:00.000-07:00</published><updated>2013-06-17T14:18:05.723-07:00</updated><title type='text'></title><content type='html'>Reseeding (reseting) the identity of a table is really simple in SQL Server.&lt;br /&gt;
&lt;br /&gt;
Check it out:&lt;br /&gt;
&lt;br /&gt;
DBCC CHECKIDENT (TableName, reseed, 0)&lt;br /&gt;
&lt;br /&gt;
This will reset the identity to 0 and any row inserted from this point on will start with 1. You can set the third parameter to any integer value.</content><link rel='replies' type='application/atom+xml' href='http://athinkr.blogspot.com/feeds/8183714501192372226/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://athinkr.blogspot.com/2013/06/reseeding-reseting-identity-of-table-is.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6944609836742303576/posts/default/8183714501192372226'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6944609836742303576/posts/default/8183714501192372226'/><link rel='alternate' type='text/html' href='http://athinkr.blogspot.com/2013/06/reseeding-reseting-identity-of-table-is.html' title=''/><author><name>Unknown</name><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-6944609836742303576.post-8465693894069242684</id><published>2013-06-13T07:38:00.000-07:00</published><updated>2013-06-13T07:38:54.167-07:00</updated><title type='text'>Time span intersection check in SQL Server.</title><content type='html'>While working in SQL server, a co-worker and I were trying to figure out how to tell if two time spans intersect in any way. We thought that the best way to do this would be to check for the opposite since there would be alot less check in those instances. Check it out!&lt;br /&gt;
&lt;br /&gt;
if (@Beg1D &amp;lt;= @End1D and @Beg2D &amp;lt;= @End2D)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;if (@Beg2D &amp;gt; @End1D or @Beg1D &amp;gt; @End2D)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;Set @TimeSpansDoIntersect = 0&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;Set @TimeSpansDoIntersect = 1&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;Set @TimeSpansDoIntersect = null</content><link rel='replies' type='application/atom+xml' href='http://athinkr.blogspot.com/feeds/8465693894069242684/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://athinkr.blogspot.com/2013/06/time-span-intersection-check-in-sql.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6944609836742303576/posts/default/8465693894069242684'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6944609836742303576/posts/default/8465693894069242684'/><link rel='alternate' type='text/html' href='http://athinkr.blogspot.com/2013/06/time-span-intersection-check-in-sql.html' title='Time span intersection check in SQL Server.'/><author><name>Unknown</name><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>