snipt

Ctrl+h for KB shortcuts

SQL

Add a column in a MSSQL table

1
2
3
ALTER TABLE [DBName].[dbo].[TableName]
ADD ColumnName int NOT NULL DEFAULT(DefaultValuefortheColumn)
GO
https://snipt.net/embed/7778fc4ef5c1db45b3c8c428d879c163/
/raw/7778fc4ef5c1db45b3c8c428d879c163/
7778fc4ef5c1db45b3c8c428d879c163
sql
SQL
3
2019-05-21T06:28:09
True
False
False
/api/public/snipt/43198/
add-a-column-in-a-mssql-table
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="k">ALTER</span> <span class="k">TABLE</span> <span class="p">[</span><span class="n">DBName</span><span class="p">].[</span><span class="n">dbo</span><span class="p">].[</span><span class="n">TableName</span><span class="p">]</span> </span><span id="L-2"><a name="L-2"></a><span class="k">ADD</span> <span class="n">ColumnName</span> <span class="nb">int</span> <span class="k">NOT</span> <span class="k">NULL</span> <span class="k">DEFAULT</span><span class="p">(</span><span class="n">DefaultValuefortheColumn</span><span class="p">)</span> </span><span id="L-3"><a name="L-3"></a><span class="k">GO</span> </span></pre></div> </td></tr></table>
mssql

SQL

Rename a column in a MSSQL table

EXEC sp_rename 'dbo.tableName.OldColumnName', 'NewColumnName', 'COLUMN'
https://snipt.net/embed/0250de6067f437f5e11a9cd7ee610426/
/raw/0250de6067f437f5e11a9cd7ee610426/
0250de6067f437f5e11a9cd7ee610426
sql
SQL
1
2019-05-21T06:28:25
True
False
False
/api/public/snipt/43197/
rename-a-column-in-a-mssql-table
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="k">EXEC</span> <span class="n">sp_rename</span> <span class="s1">&#39;dbo.tableName.OldColumnName&#39;</span><span class="p">,</span> <span class="s1">&#39;NewColumnName&#39;</span><span class="p">,</span> <span class="s1">&#39;COLUMN&#39;</span> </span></pre></div> </td></tr></table>
mssql

JavaScript

Replace parts of current URL and go to it

javascript:(function() {var curloc = location.href; curloc = curloc.replace(/www/g,"cp");curloc = curloc.replace(/view/g,"edit"); location.href = curloc; })();
https://snipt.net/embed/a46bb815b13d7481c21ec93c46beae3c/
/raw/a46bb815b13d7481c21ec93c46beae3c/
a46bb815b13d7481c21ec93c46beae3c
js
JavaScript
1
2019-05-12T23:35:13
True
False
False
/api/public/snipt/43196/
replace-parts-of-current-url-and-go-to-it
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="nx">javascript</span><span class="o">:</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span><span class="kd">var</span> <span class="nx">curloc</span> <span class="o">=</span> <span class="nx">location</span><span class="p">.</span><span class="nx">href</span><span class="p">;</span> <span class="nx">curloc</span> <span class="o">=</span> <span class="nx">curloc</span><span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/www/g</span><span class="p">,</span><span class="s2">&quot;cp&quot;</span><span class="p">);</span><span class="nx">curloc</span> <span class="o">=</span> <span class="nx">curloc</span><span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/view/g</span><span class="p">,</span><span class="s2">&quot;edit&quot;</span><span class="p">);</span> <span class="nx">location</span><span class="p">.</span><span class="nx">href</span> <span class="o">=</span> <span class="nx">curloc</span><span class="p">;</span> <span class="p">})();</span> </span></pre></div> </td></tr></table>
bookmarklet, javascript

JavaScript

Show/hide content in multiple elements (JQuery)

1
2
3
4
5
6
7
8
//Show and hide content by clicking a link; link has .toggle-link and any id, content has .toggle-object and #showme-"any id"
$('.toggle-object').hide();
$('.toggle-object:first').show(400);
$('.toggle-link').click(function() { 
	var toggleid = $(this).attr('id');
	//$('.toggle-object').hide();
	$('#showme-'+toggleid).slideToggle(400);
});
https://snipt.net/embed/16476908fb53149ed971a3152483bf6d/
/raw/16476908fb53149ed971a3152483bf6d/
16476908fb53149ed971a3152483bf6d
js
JavaScript
8
2019-05-21T06:26:59
True
False
False
Feb 12, 2013 at 01:27 PM
/api/public/snipt/43193/
showhide-content-in-multiple-elements-jquery
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a> <a href="#L-8">8</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="c1">//Show and hide content by clicking a link; link has .toggle-link and any id, content has .toggle-object and #showme-&quot;any id&quot;</span> </span><span id="L-2"><a name="L-2"></a><span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.toggle-object&#39;</span><span class="p">).</span><span class="nx">hide</span><span class="p">();</span> </span><span id="L-3"><a name="L-3"></a><span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.toggle-object:first&#39;</span><span class="p">).</span><span class="nx">show</span><span class="p">(</span><span class="mi">400</span><span class="p">);</span> </span><span id="L-4"><a name="L-4"></a><span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.toggle-link&#39;</span><span class="p">).</span><span class="nx">click</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span> </span><span id="L-5"><a name="L-5"></a> <span class="kd">var</span> <span class="nx">toggleid</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">attr</span><span class="p">(</span><span class="s1">&#39;id&#39;</span><span class="p">);</span> </span><span id="L-6"><a name="L-6"></a> <span class="c1">//$(&#39;.toggle-object&#39;).hide();</span> </span><span id="L-7"><a name="L-7"></a> <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#showme-&#39;</span><span class="o">+</span><span class="nx">toggleid</span><span class="p">).</span><span class="nx">slideToggle</span><span class="p">(</span><span class="mi">400</span><span class="p">);</span> </span><span id="L-8"><a name="L-8"></a><span class="p">});</span> </span></pre></div> </td></tr></table>
javascript, jquery