DCSIMG
T-SQL Israeli CardID Checker / ת.ז. ישראלית - Adlai Maschiach

Adlai Maschiach

" You have to show in order to be seen "

News

Favorite Links

news

CardSpace

Books

Other InfoCards Proj

Virtual Earth

WSS / Sharepoint

SOA , Biztalk & ESB

CLR / .NET

T-SQL Israeli CardID Checker / ת.ז. ישראלית

T-SQL Israeli CardID Checker / ת.ז. ישראלית

Once in a while I come across code that I didn’t fins in the internet … mainly because it’s for local use ;)
This is one of these times :)

This code is the T-SQL version of the algorithm  that checks the given Israeli CardID , and adds a leading Zero , if need one ( like in my personal case ) , and calculates the “Check Number” ( SIFRAT BIKORET ) , if it’s missing.

I needed this for an SSIS Package that loaded monthly information needed for my SharePoint Content ;)

BTW , there might be a better way to code this , but i’m no T-SQL expert :)

/*
Algorithm From
http://halemo.net/info/idcard/index.html
*/

ALTER FUNCTION [dbo].[fn_FixUpCardID]
    (
    @CardID VARCHAR(50)
    )
RETURNS VARCHAR(50)
AS
    BEGIN
    DECLARE @CardID_1 INT
    DECLARE @CardID_2 INT   
    DECLARE @CardID_3 INT
    DECLARE @CardID_4 INT
    DECLARE @CardID_5 INT
    DECLARE @CardID_6 INT
    DECLARE @CardID_7 INT
    DECLARE @CardID_8 INT
    DECLARE @CardID_9 INT
    DECLARE @CardID_1_CalcVal INT
    DECLARE @CardID_2_CalcVal INT   
    DECLARE @CardID_3_CalcVal INT
    DECLARE @CardID_4_CalcVal INT
    DECLARE @CardID_5_CalcVal INT
    DECLARE @CardID_6_CalcVal INT
    DECLARE @CardID_7_CalcVal INT
    DECLARE @CardID_8_CalcVal INT
    DECLARE @CardID_9_CalcVal INT
    DECLARE @CardID_TotalValue INT
    DECLARE @CardID_Decimal INT
    IF (LEN(@CardID) = 7)
    BEGIN
       SET @CardID = '0' + @CardID;
    END
    SET @CardID_1 = CAST(SUBSTRING(@CardID,1,1) AS INT)
    SET @CardID_2 = CAST(SUBSTRING(@CardID,2,1) AS INT)
    SET @CardID_3 = CAST(SUBSTRING(@CardID,3,1) AS INT)
    SET @CardID_4 = CAST(SUBSTRING(@CardID,4,1) AS INT)
    SET @CardID_5 = CAST(SUBSTRING(@CardID,5,1) AS INT)
    SET @CardID_6 = CAST(SUBSTRING(@CardID,6,1) AS INT)
    SET @CardID_7 = CAST(SUBSTRING(@CardID,7,1) AS INT)
    SET @CardID_8 = CAST(SUBSTRING(@CardID,8,1) AS INT)
    if (LEN(@CardID) = 9)
    BEGIN
        SET @CardID_9 = CAST(SUBSTRING(@CardID,9,1) AS INT)
    END
    ELSE
    BEGIN
        SET @CardID_9 = -1
    END
    SET @CardID_1_CalcVal = (@CardID_1 * 1) / 10 + (@CardID_1 * 1) % 10
    SET @CardID_2_CalcVal =    (@CardID_2 * 2) / 10 + (@CardID_2 * 2) % 10
    SET @CardID_3_CalcVal = (@CardID_3 * 1) / 10 + (@CardID_3 * 1) % 10
    SET @CardID_4_CalcVal = (@CardID_4 * 2) / 10 + (@CardID_4 * 2) % 10
    SET @CardID_5_CalcVal = (@CardID_5 * 1) / 10 + (@CardID_5 * 1) % 10
    SET @CardID_6_CalcVal = (@CardID_6 * 2) / 10 + (@CardID_6 * 2) % 10
    SET @CardID_7_CalcVal = (@CardID_7 * 1) / 10 + (@CardID_7 * 1) % 10
    SET @CardID_8_CalcVal = (@CardID_8 * 2) / 10 + (@CardID_8 * 2) % 10
    SET @CardID_TotalValue = @CardID_1_CalcVal + @CardID_2_CalcVal +
                             @CardID_3_CalcVal + @CardID_4_CalcVal +
                             @CardID_5_CalcVal + @CardID_6_CalcVal +
                             @CardID_7_CalcVal + @CardID_8_CalcVal
    IF (@CardID_9 > -1)
    BEGIN
        SET @CardID_9_CalcVal = (@CardID_9 * 1) / 10 + (@CardID_9 * 1) % 10
         IF (((@CardID_TotalValue + @CardID_9_CalcVal) % 10) != 0)
                 SET @CardID = ''
    END
    ELSE
    BEGIN
        if ((@CardID_TotalValue % 10) = 0)
        BEGIN
            SET @CardID = @CardID + '0'
        END
        ELSE
        BEGIN
            SET @CardID_9 = (((@CardID_TotalValue / 10) + 1) * 10) - @CardID_TotalValue
             SET @CardID = @CardID + CAST(@CardID_9 AS CHAR)
        END
       -- SET @CardID = cast((((@CardID_TotalValue % 10) + 1) * 10) as varchar)
    END
    RETURN @CardID 
    END

Comments

Azoqk said:

So you have a class called Node with two inastnce variables called next and data. They are called inastnce variables because they belong to the inastnces of this class rather than to the class itself. That is, your class is basically a template (or blueprint) for objects that each willhave their own data value and next value.In order to create an inastnce of the Node class you need to call the constructor and pass the necessary parameters. In your case the constructor is;  public Node(int d) {       data = d;  }To call this constructor you use the new keyword (in Java I assume) like this;   Node x = new Node(10);And notice that you must supply an integer value to the constructor. In the body of the constructor (between the {}) you see that the variable data is assigned to the value in d which is the value that you pass to the constructor, in this example the value 10. You now have an object of type Node with the value 10 as it's data and a null next Node.On that object you can now call the method appendToTail(). Lets say we do this:   x.appendToTail(20);Lets trace what happens.    Node end = new Node(d);A new node named end is created and we set the value 20 to data (remember that d has the value 20 for now because that is the value we passed when we were calling the method). This is a completely independednt node from x with its own unique value for data.    Node n = this;this is a self reference to the current object. Since we called this method on x then this is the same object as x.    while (n.next != null) {        n = n.next;    }This while loop is going to start looking for the end of the list by going from the current node to the next node until the next node is null. Since the only node we created so far is x then n.next is actually null so the while loop does not execute this time.    n.next = end;Now we are setting the next value of n (which is x) to the node end that was created. You now have a list like this:  10 -> 20 -> nullSuppose you were to make the following call:  x.appendToTail(30);Then a similar thing happens except when you get to the while loop the value n.next is not null so you go into the body of the loop and assign n to point to n.next which in our example is the node with 20. The next iteration of the loop would yield the null so the loop will quit and the new node with data 30 will be set to the next value of the last node in the list. So you will have :  10 -> 20 -> 30 -> nullTo answer your questions:Q:  since we set  next' to be null when we first declare it, when does it get changed to not null? When you have only one item in the list, the  next' value of that Node will be set to NULL.Q:  and also what does   Node n = this;   mean? This statement means that the reference variable  n' takes the reference of the current object, which is specified by  this'.Q:  Whenever we declare a new inastnce of the object Node, does it make a copy of its own separate fields from the class? Instance variables will be created for each individual class that you make an inastnce of. This means that every Node will have  next' and  data'.Thus, in your creation process, you will probably have something like this:Also, the while loop iterates to the end of the list and appends the item after the last node in the list.Hope it helps (: If you have any questions, do post back (:

# May 17, 2012 3:43 AM

Mccaskill said:

I agree completely with what you said. Great Stuff. Keep it going.

.

# December 15, 2012 3:47 PM

Bender said:

Quality articles or reviews is the key to interest the visitors to pay a quick visit the site, that's what this website is providing.

# January 9, 2013 5:17 PM

Putnam said:

It's very easy to find out any matter on web as compared to textbooks, as I found this post at this site.

# January 24, 2013 2:06 AM

Luttrell said:

I don't know whether it's just me or if everybody else encountering issues with your blog.

It appears like some of the text on your content are running off the screen.

Can somebody else please provide feedback and let me know

if this is happening to them too? This may be a

issue with my browser because I've had this happen before. Cheers

# January 27, 2013 2:29 AM

Ault said:

Wow, this article is good, my sister is analyzing such things, thus I

am going to tell her.

# February 6, 2013 11:26 PM

Walls said:

Very energetic blog, I enjoyed that bit. Will there be a part 2?

# February 10, 2013 7:52 PM

Charles said:

This paragraph will help the internet people for creating new website or even

a blog from start to end.

# February 11, 2013 4:29 AM

Pyle said:

Excellent article. I am dealing with many of these issues as well.

.

# February 12, 2013 12:43 PM

Sellers said:

Wow! At last I got a website from where I can in fact take valuable data concerning my study and knowledge.

# February 13, 2013 3:02 PM

Escobar said:

Very good article. I'm dealing with some of these issues as well..

# February 16, 2013 10:34 AM

Tackett said:

What's up, I would like to subscribe for this website to obtain latest updates, so where can i do it please assist.

# February 17, 2013 7:28 PM

Titus said:

This information is worth everyone's attention. Where can I find out more?

# February 17, 2013 7:47 PM

Odell said:

I visit daily a few blogs and websites to read articles or reviews, but this web site provides

feature based posts.

hardwood flooring

# February 18, 2013 6:43 AM

Fanning said:

always i used to read smaller content which also clear their motive, and

that is also happening with this piece of writing which I am reading at this place.

# February 18, 2013 11:46 AM

Woodson said:

Hi, the whole thing is going fine here and ofcourse every one is sharing data, that's really good, keep up writing.

# February 18, 2013 9:57 PM

Phillips said:

It's truly very difficult in this active life to listen news on TV, so I simply use world wide web for that purpose, and obtain the most up-to-date information.

# February 21, 2013 10:53 AM

Smyth said:

Thanks for sharing your thoughts. I really appreciate your efforts and I am

waiting for your further post thank you once again.

# February 22, 2013 7:16 AM

Phifer said:

What's up friends, how is everything, and what you want to say about this post, in my view its really awesome in favor of me.

# February 23, 2013 5:48 AM

Clarkson said:

I really like reading an article that will make people think.

Also, thanks for allowing for me to comment!

# February 23, 2013 5:22 PM

Comstock said:

Hi there everyone, it's my first pay a quick visit at this web site, and paragraph is truly fruitful in favor of me, keep up posting these types of articles.

# March 1, 2013 12:27 PM

Coats said:

Superb, what a blog it is! This web site presents valuable facts to us,

keep it up.

# March 2, 2013 8:22 AM

Rocha said:

What's up colleagues, how is everything, and what you would like to say about this paragraph, in my view its in fact remarkable in favor of me.

# March 2, 2013 7:18 PM

Harlow said:

I would like to thank you for the efforts you have put in writing this website.

I am hoping to see the same high-grade blog posts from you in the

future as well. In fact, your creative writing abilities has motivated me to

get my very own blog now ;)

# March 6, 2013 4:36 AM

Soliz said:

This website certainly has all of the information and facts I wanted concerning this subject and didn't know who to ask.

# March 6, 2013 9:09 PM

Clegg said:

Do you have any video of that? I'd want to find out some additional information.

# March 7, 2013 3:07 AM

Hair said:

Hello there! Would you mind if I share your blog with my twitter

group? There's a lot of folks that I think would really appreciate your content. Please let me know. Many thanks

# March 7, 2013 11:35 PM

Jamieson said:

This blog was... how do I say it? Relevant!

! Finally I have found something which helped me. Thanks!

# March 12, 2013 1:44 PM

Arrington said:

Hey there! I've been following your website for a long time now and finally got the courage to go ahead and give you a shout out from Dallas Texas! Just wanted to say keep up the excellent job!

# March 16, 2013 11:21 PM

Michaels said:

This is my first time visit at here and i am

really impressed to read all at one place.

# March 17, 2013 2:41 PM

Stclair said:

I'm not sure why but this site is loading extremely slow for me. Is anyone else having this problem or is it a problem on my end? I'll check back later and see if the problem still exists.

# March 19, 2013 10:31 PM

Darden said:

So, start learning minibus-driving skills in a suitable place.

This could save you a small fortune in minor damage

claims. Many a times, what happens is that there are many people who keep visiting Essex more often.

# March 20, 2013 2:30 PM

Keys said:

Over Coronado Bridge, you will be taken to see

Mount Soledad and the Cabrillo Monument. Are HST and driver gratuity included.

That is a very effective way to introduce the story and the character.

# March 24, 2013 2:27 AM

Pritchett said:

I was able to find good information from your content.

# March 25, 2013 5:39 PM

Nickerson said:

If you are on a business trip, it is of utmost importance that you reach your client.

Cruises starting or ending in Honolulu offer passengers opportunities

to visit Waikiki Beach, the North Shore, Pearl Harbor

and much more. With many restaurants, cafes and bars

this place has become a popular meeting joint.

# April 3, 2013 2:39 PM

Barrientos said:

Would you describe for someone who isn't yet familiar with your site what Zen Habits is and why you decided to start it. Sadly for those adrenaline junkies that come here to take the challenge will soon be disappointed when the path is to be reconstructed to allow visitors to enter the gorge easily. Rarely need additional insurance: The rental car agencies often need to spend additional money per day on lifting and collision damage insurance coverage.

# April 4, 2013 3:33 AM

Klier said:

My coder is trying to persuade me to move to .

net from PHP. I have always disliked the idea because of the

costs. But he's tryiong none the less. I've been using Movable-type on several websites for about a year

and am worried about switching to another platform. I have heard excellent things about blogengine.

net. Is there a way I can import all my wordpress content into it?

Any help would be greatly appreciated!

# April 13, 2013 12:34 PM

Andre said:

I think the admin of this site is really working hard in support of his web

page, for the reason that here every data is quality based stuff.

# April 20, 2013 3:29 PM

Perrin said:

Hi there to every single one, it's really a good for me to go to see this web page, it contains valuable Information.

# April 20, 2013 3:30 PM

Hair said:

Heya just wanted to give you a quick heads up and let you know a few

of the images aren't loading correctly. I'm

not sure why but I think its a linking issue. I've tried it in two different browsers and both show the same results.

# April 20, 2013 9:13 PM

Royer said:

Howdy are using Wordpress for your blog platform? I'm new to the blog world but I'm

trying to get started and set up my own. Do you require any html coding knowledge to make your own blog?

Any help would be really appreciated!

# April 21, 2013 12:20 AM

Low said:

Keep on working, great job!

# April 21, 2013 4:38 AM

Puckett said:

I'm gone to convey my little brother, that he should also go to see this website on regular basis to obtain updated from latest news update.

# April 21, 2013 8:22 AM

Buckner said:

Does your site have a contact page? I'm having problems locating it but, I'd like to shoot you an email.

I've got some suggestions for your blog you might be interested in hearing. Either way, great blog and I look forward to seeing it improve over time.

# April 21, 2013 3:24 PM

Deboer said:

I hardly write responses, but i did a few searching and wound up here T-SQL Israeli CardID Checker

/ ת.ז. ישראלית - Adlai Maschiach.

And I do have some questions for you if you do not mind.

Could it be only me or does it give the impression like some of these comments look like they

are coming from brain dead folks? :-P And, if you

are posting on other online sites, I would like to keep

up with anything fresh you have to post. Could you make a list of all of your shared sites like your twitter feed, Facebook page or linkedin profile?

# April 21, 2013 4:57 PM

Major said:

What's up, of course this post is in fact fastidious and I have learned lot of things from it regarding blogging. thanks.

# April 21, 2013 6:16 PM

Vitale said:

I don't know whether it's just me or if perhaps everyone else encountering issues with your blog.

It appears as if some of the written text within your posts

are running off the screen. Can somebody else please comment and let me know if

this is happening to them too? This could be a issue with my web browser because I've had this happen before. Many thanks

# April 21, 2013 6:22 PM

Rowan said:

I don't even know the way I ended up here, but I thought this submit used to be great. I don't recognise who you might be but certainly you

are going to a well-known blogger if you happen to are not already.

Cheers!

# April 21, 2013 6:22 PM

Bone said:

When I initially commented I clicked the "Notify me when new comments are added" checkbox and now each time a comment is added I get

several e-mails with the same comment. Is there any way you can remove me from that

service? Thank you!

# April 21, 2013 10:56 PM

Branch said:

Greetings from Colorado! I'm bored at work so I decided to check out your blog on my iphone during lunch break. I really like the information you present here and can't

wait to take a look when I get home. I'm amazed at how fast your blog loaded on my mobile .. I'm not

even using WIFI, just 3G .. Anyhow, amazing site!

# April 21, 2013 11:34 PM

Mccauley said:

Greetings! This is my first comment here so I just wanted to give a quick shout out and tell you I

genuinely enjoy reading through your blog posts. Can you recommend any other

blogs/websites/forums that cover the same subjects? Thanks!

# April 22, 2013 10:46 AM

Mcgregor said:

Wonderful goods from you, man. I've understand your stuff previous to and you are just extremely wonderful. I actually like what you have acquired here, certainly like what you're saying and the way

in which you say it. You make it entertaining and you still

care for to keep it wise. I can not wait to read

far more from you. This is really a tremendous site.

# May 2, 2013 12:27 PM

Fiore said:

Good day I am so happy I found your site, I really found you by accident,

while I was looking on Google for something else, Regardless I am here

now and would just like to say thanks for a remarkable post and a all round enjoyable blog

(I also love the theme/design), I don't have time to browse it all at the moment but I have bookmarked it and also included your RSS feeds, so when I have time I will be back to read a great deal more, Please do keep up the excellent work.

# May 2, 2013 12:28 PM

Coyne said:

With havin so much content do you ever run into any

problems of plagorism or copyright infringement?

My site has a lot of unique content I've either authored myself or outsourced but it looks like a lot of it is popping it up all over the web without my authorization. Do you know any techniques to help stop content from being stolen? I'd really appreciate

it.

# May 2, 2013 4:08 PM

Mueller said:

You can gain a lot of information regarding the best company that can

provide a rent a car service for you. This will give an amazing view of the beautiful

Mar Menor lagoon and the Mediterranean coast. Furthermore rental car services

focus on travelers; they also cater to those people whose cars

are temporarily out of service, damaged or destroyed, and also to those

who might be waiting for an insurance renewal.

# May 2, 2013 11:33 PM

Mccormick said:

If you desire to increase your know-how only keep visiting this site and

be updated with the newest news update posted here.

# May 3, 2013 2:04 AM

Victor said:

WOW just what I was looking for. Came here by searching for

security alarm

# May 4, 2013 6:33 PM

Nielsen said:

Saved as a favorite, I love your site!

# May 5, 2013 7:18 AM

Dorris said:

What a data of un-ambiguity and preserveness of valuable familiarity

about unpredicted emotions.

# May 5, 2013 5:16 PM

Ma said:

You can definitely see your expertise in the article you write.

The arena hopes for more passionate writers such as you who are not afraid to

say how they believe. At all times follow your

heart.

# May 7, 2013 2:20 AM

Tompkins said:

Hmm is anyone else experiencing problems

with the pictures on this blog loading? I'm trying to find out if its a problem on my end or if it's the blog.

Any feedback would be greatly appreciated.

# May 8, 2013 8:04 PM

Stanton said:

This post is truly a fastidious one it assists new internet people, who are wishing in favor of

blogging. Drive more moreattract Targeted visitors by means of twitter

followers buy on your Report successful way.

If you wish to buy followers on twitter make sure

you maintain the twitter accounts updated.

If you need to buy twitter followers to your twitter consideration, there are numerous quite effective ways.

# May 8, 2013 9:39 PM

Kirkwood said:

My family members every time say that I am wasting my time here at net, except I know I am getting knowledge all the time by reading thes

pleasant content. buy followers on twitter

twitter for business can appreciably improve ad�quation as well as believability.

more followers on twitter Inexpensive along with Protected for twitter

account.

# May 9, 2013 4:03 AM

Reeder said:

Hi mates, its wonderful article regarding educationand entirely defined,

keep it up all the time.

# May 15, 2013 6:40 PM

Minnick said:

It's nearly impossible to find educated people in this particular subject, however, you sound like you know what you're

talking about! Thanks

# May 15, 2013 8:49 PM

Life2Organic.com said:

Whatever the reason, renting a car can be a great solution for cross-country travel. Consider the idea of purchasing fruit, snacks, peanut butter and jelly (or another non-perishable sandwich making item), and bread at a grocery store. I needed to rent

# May 19, 2013 4:48 AM

Wentworth said:

What's up, after reading this remarkable post i am too glad to share my know-how here with friends.

# June 18, 2013 3:10 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 


Enter the numbers above: