Wednesday, December 26, 2012

Parsing a delimited string in SQL

 Most of the time we required the delimited strings to be added in database. today i come up with some simple solution. which will read the string and specified delimited character and base on that it will divide the string and split it across.

CREATE FUNCTION ParseValues
(@String varchar(8000), @Delimiter varchar(10) )
RETURNS @RESULTS TABLE (ID int identity(1,1), Val varchar(50))
AS
BEGIN
DECLARE @Value varchar(100)
WHILE @String is not null
BEGIN
SELECT @Value=CASE WHEN PATINDEX('%'+@Delimiter+'%',@String) >0 THEN LEFT(@String,PATINDEX('%'+@Delimiter+'%',@String)-1) ELSE @String END, @String=CASE WHEN PATINDEX('%'+@Delimiter+'%',@String) >0 THEN SUBSTRING(@String,PATINDEX('%'+@Delimiter+'%',@String)+LEN(@Delimiter),LEN(@String)) ELSE NULL END
INSERT INTO @RESULTS (Val)
SELECT @Value
END
RETURN
END

You can call this function in your query and it will return the result.(as show in img)

select * from dbo.ParseValues('This;is;a;delimited;string;value',';')


and here is your result..

   
 Hope this will helps you, Please put your comments or dought to help others.
 

Monday, June 18, 2012

Jquery copy to clipboard

Hi, after long time right? yea... 

anyways after long time i am decided to get back again on blogger :) and make this blogger active and helpful to others.

today i come up with some tricks on javascript or on jquery . its a Copy to clipboard.
In IE we have direct window option to make the copy to clipboard code event , but if you try to do same with Firefox or other it wont work 

so i thought let add some trick to make the copy thing easy :).

Find my below code and put it in the head section


 
<script type="text/javascript" src="http://code.jquery.com/jquery-1.3.2.min.js"> </script>

 
<script type="text/javascript" src="js/jquery.zclip.js"> </script>

    <script type="text/javascript">
        $(document).ready(function() {
            $('a#copy-dynamic').zclip({
                path: 'js/ZeroClipboard.swf',
                copy: function() { return $('input#dynamic').val(); }
            });

        });
   
</script>

and insert this section on your body part.

 <div>
       
<br />
        <a href="#" id="copy-dynamic">Click here to copy the value of this input:</a>
        <input style="width: 300px; margin-left: 15px;" type="text" id="dynamic" value="Insert any text here." onfocus="if(this.value=='Insert any text here.'){this.value=''}" onblur="if(this.value==''){this.value='Insert any text here.'}" />
   
</div>

lets download the swf from GitHubs and put it in your js directory accordingly.

now simple run the application , type the text on the textbox and click on copy button it will copy it in your system just like (Ctrl + C).

Put your comments or suggestion to make this thread active and popular.

Tuesday, May 3, 2011

Jquery Auto Hide

Hi Guys today i come up with some cool example of JQuery. its a "Auto hide button or Div after some interval time "

if you seen in Gmail, when you send a mail or move the mail to any folder or if you do any operation you will see the confirm message and after some interval time it will hide automatically.
like this:

yes here is the source on same.


<html><head>
<script language="javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<script language="javascript">
(function($){
$(document).ready(function() {
$("[AutoHide]").each(function() {
if (!isNaN($(this).attr("AutoHide"))) {
eval("setTimeout(function() {jQuery('#" + this.id + "').hide();}, " + parseInt($(this).attr('AutoHide')) * 1000 + ");");
}
});
});
})(jQuery);
</script>
</head>
<body>
<center>
<br><br>
<div id="div1Seconds" AutoHide="10" style="background: #ccc; border: solid 1px #333">
<input type="button" value="This Button will be hidden in 10 second.">
</div>
<br><br>
<div id="div3Seconds" AutoHide="15" style="background: #ccc; border: solid 1px #333">
<input type="button" value="This Button will be hidden in 15 second.">
</div>
</center>
</body>
</html>

Demo : (refresh page to view the demo)










Hope it will likes you.

Wednesday, January 5, 2011

Add/ Remove rows using javascript or Jquery

Jquery is one of the great and coolest feature in the web. you can desing your application any thing as u want with asynchronous call.
here i have created one small application for adding or removing the rows from your tables.

many times we are not sure how much length of user input is for ex. in case of
address field we are not sure how much length of data is so that time this coolest add/remove rows function will use.
just try it .

here is the basic java script.


<html>
<head>
<title> Add/Remove Rows in Table </title>
<script language="javascript">
function addRow(tableID) {

var table = document.getElementById(tableID);

var rowCount = table.rows.length;
var row = table.insertRow(rowCount);

var cell1 = row.insertCell(0);
var element1 = document.createElement("input");
element1.type = "checkbox";
cell1.appendChild(element1);

var cell2 = row.insertCell(1);
cell2.innerHTML = rowCount + 1;

var cell3 = row.insertCell(2);
var element2 = document.createElement("input");
element2.type = "text";
cell3.appendChild(element2);
}

function deleteRow(tableID) {
try {
var table = document.getElementById(tableID);
var rowCount = table.rows.length;

for(var i=0; i<rowCount; i++) {
var row = table.rows[i];
var chkbox = row.cells[0].childNodes[0];
if(null != chkbox && true == chkbox.checked) {
table.deleteRow(i);
rowCount--;
i--;
}

}
}catch(e) {
alert(e);
}
}
function SubmitForm()
{
// your form Validation code goes here ...
}

</SCRIPT>
</head>
<body>
<TABLE id="dataTable" width="350px" border="1">
<TR>
<TH>Select</TH>
<TH>Sr. No.</TH>
<TH>Value</TH>
</TR>
<TR>
<TD><INPUT type="checkbox" name="chk"/></TD>
<TD> 1 </TD>
<TD> <INPUT type="text" /> </TD>
</TR>
</TABLE>
<INPUT type="button" value="Add Row" onclick="addRow('dataTable')" />
<INPUT type="button" value="Delete Row" onclick="deleteRow('dataTable')" />
<INPUT type="button" value="submit" onclick="SubmitForm()" />
</BODY>
</HTML>



hope u like it .,.... just commnet it.. the jquery example i will post it on my next post.

Sunday, July 18, 2010

Jquery on blogspot

Hi,i thing you have implement so many jquery features on your application , but have you try this on your blogger ? nb not yet .. then try this code hope you like it.

click on the below button it will show you the toggle .




And Here is the code , just add this on your blogger and see the magic.

<script src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js" type="text/javascript"> </script>
<script type="text/javascript"> $(function(){$("#BtnToggle").click(function(){$('#divTogg').toggle(1000);});});</script>

<style type="text/css"> #divTogg{width: 200px;height: 100px;border: solid 1px black;background-color:LightGrey;text-align:center; display:none;}</style>

<div id="dvt"> Hi, its working on Blogger too.</div>
<button id="BtnToggle"> Click Me</button>


This is your css part you can design it accordingly.

  • <style type="text/css">

  • #divTogg

  • {

  • width: 200px;

  • height: 100px;

  • border: solid 1px black;

  • background-color:LightGrey;

  • text-align:center;

  • display:none;

  • }

  • </style>



hope you like this ,if you have like this plz comment on it.

Friday, May 7, 2010

New looks on Google

Yesterday i open a Google for searching and i noticed that something get change with the google site, as you can see the look and feel of the search section is bit change , as you can say the font is also get changed , it one kind of visual look getting and also looking for nice as comparing with the previous one.

Wht's get Changed and Wht's New added?
New thing added is contextually relevant, left side Navigation on a Page. It will shows you the most popular and relevant search tools to refine your search query. it contain Google Squarted, Universal Search . that get combine on the left hand side Search Panel.

on Universal Search you can easily find the most relevant search . The top section of left hand side panel that suggest you the most genres result for the search and it will also give you the good way to easily switch to the different types of results . here you can find the opetion " Everythings" which will gives you can result on what exactly your looking for. on Google Squared ( now its on Google Lab) which will help you to compare the entites . it builds on the Google Squared Technology it shows you the related result on your search query. so you can easily explore the result on other related topics also.

As you can see the color palette and logo is also get change which will keep the Goolge page as in modern look you can also see more on how the new design get change on this video.



As talking about Google Logo, you can easily see the Difference on it, new design logo is lighter than previous one and also a simple, the logo design get done on the new icons and hundreds of tiny design, as you can clearly see the previous logo "g" has shadow image and how its clear it get removing the blue color shadowing effect.


One more thing you can see on the Bottom section Search it also get change with the removing of Blue effects also.


there are few more little changes are going on , and its all in process you can see that on Google steps by step.

Friday, April 30, 2010

cache-about-blank

i m using Fx( FireFox) Browser , and i have install google toolbar on it , one day i have just try this, just open a new tab and just for quracity i have click on "Google Pagespeed" icon.it get open a google search page with that topic on " cache-about-blank" and decided to write a topic on it. i know u also come like this way.

now wht is this cache:about:blank and mozilla .

basically if you click on pagerank button it will show you cache version of site but if your not opening any site and still click on that button then it goes to google search option with "about:blank". On mozilla there is many setting are there , if u simply open a browser and type about:config on the url it will shows you the various setting on the browser. there are lot many setting are there on all type connection, browser, server, service , so on
don't change anything without any proper knowledge, other wise it get save and may be some problem get arise later on.

but still if your interested to do so you can refer this mozillatips.com. or want more on how to customize the interface just refer this customize the interface . both are very much interesting to know more on Fx

if your using IE then
if you open this on IE then may be on latest version you will never get such type if page on about:blank ,

just try it , you will enjoy it.

Refer This Post :
- how to configure local-host setting on FireFox
- Firefox Extensions for Twitter and Facebook