An Idea can change your life.....

Sunday, November 30, 2008

sql server insert multiple records


CREATE
TABLE #CALCULATE
(
COL1 VARCHAR(20),

COL2 VARCHAR(20))

Using Insert INTO commands for each row

INSERT INTO #CALCULATE
(COL1,
COL2)
VALUES ('one',
1);
INSERT INTO #CALCULATE
(COL1,
COL2)
VALUES ('two',
2);
INSERT INTO #CALCULATE
(COL1,
COL2)
VALUES ('three',
3);
INSERT INTO #CALCULATE
(COL1,
COL2)
VALUES ('four',
4);
INSERT INTO #CALCULATE
(COL1,
COL2)
VALUES ('five',
5);

SELECT
*
FROM #CALCULATE

DELETE FROM #CALCULATE

Using Union All command

INSERT
INTO #CALCULATE
(COL1,
COL2)
SELECT 'one',
1
UNION ALL
SELECT 'two',
2
UNION ALL
SELECT 'three',
3
UNION ALL
SELECT 'four',
4
UNION ALL
SELECT 'five',
5

SELECT
*
FROM #CALCULATE

CREATE TABLE #CALCULATETEMP
(
COL1 VARCHAR(20),

COL2 VARCHAR(20))

Insert from another table

INSERT
INTO #CALCULATETEMP
(COL1,
COL2)

SELECT COL1,
COL2
FROM #CALCULATE

Create table and insert the data from another table

SELECT
*
FROM #CALCULATETEMP

SELECT COL1,
COL2
INTO #CALCULATETEMP1
FROM #CALCULATE

SELECT *
FROM #CALCULATETEMP1

DROP TABLE #CALCULATE

DROP TABLE #CALCULATETEMP

DROP TABLE #CALCULATETEMP1

Reference : www.sqlauthority.com

sql server execute all files in a folder using sqlcmd

Step 1. Create a sql file (proc.sql) and palace it here C:\SqlFiles\01_database\proc.sql

create procedure procName
as
begin
select * from DimProduct
end

Step2. Create a sql file(proc1.sql) and place it here C :\SqlFiles\proc1.sql

create procedure procName1
as
begin
select * from DimProduct
end

step3.Create a BatchCommand file(ExecuteSqlFiles.bat) with following text in it and place it here C:\SqlFiles\ExecuteSqlFiles.bat

for /R %%X in (*.SQL) do SQLCMD -S Server -d Database -U UserID -P Password -I -i "%%X" >> ResultScript.txt

Step4. Run the ExecuteSqlFiles.bat (i.e by clicking on it)

A file (C:\SqlFiles\ResultScript.txt) if not exist is created and the errors encounterd while executing the sql files is written to the file.

Tuesday, October 14, 2008

Software Jokes Telugu version

Dialogues from Soft Simha Reddy
1) Etti kottanante, GOOGLE search lo kooda kanapadakunda potav..

2) Rey Java Reddy, nenu VB chesa, VC chesa, Sun chesaa, nee java chesa....

Nuvvu.. Software vamsam lo ne puttunte.. neeke ganaka ... oka guenine company unte.. laptop , desktop rendu unte... raara.. dammunte naaku interview cheyyara... ee roju .. ee joboo , leka nee companyno telipovala...

3) Keyboard lo button nokkanante.. aa sound ke job istav.. nenu personal ga vacchi interview ivvatam entra...

4)Debugging naaku maa amma uggu paalatho pattindi ra.

5) Program nuvvu ichina sare, nannu raayamanna sare. Logic nuvvu cheppina sare nannu alochinchammana sare, eppudayina ekkadaina nenu program rayagalanu.

6) Cant be displayed" ani vacchinantha maatrana kanipinchananukunnava.vakka sari refresh kotti chooda ra Romaalu nikka boduchukuntai.

7)hacker ali khann!!! thappu naa program lo undhi kaabatti logout avuthunna, adhey error nee code lo unduntey system crash chesi velley vaadini.

8) Ee Softseema lo modhata spam pettindhi maa thaata, Virus puttinchindhi maa thaata , nuvventra peekedhi.

9) Arey thaaai... evari company ki vacchavo telusa.. naa peru chepithe.. BILL GATES kooda java program copy cheyyadam marchipotadu...

10) Kathula tho kadura program tho champestha

#######################################################


Hi good afternoon, this is Martha, I can't print. Every time I try it says 'Can't find printer'. I've even lifted the printer and placed it in front of the monitor, but the computer still says he can't find it...



$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
Customer Care....

Helpdesk: What kind of computer do you have?

Customer: A white one...

--------------------------------------------

Customer: Hi, this is Celine. I can't get my diskette out.

Helpdesk: Have you tried pushing the button?

Customer: Yes, but it's really stuck.

Helpdesk: That doesn't sound good; I'll make a note .

Customer: No ... wait a minute... I hadn't inserted it yet... it's still on my desk... sorry.

--------------------------------------------

Helpdesk: Click on the 'my computer' icon on to the left of the screen.

Customer: Your left or my left?

--------------------------------------------

Helpdesk: Good day. How may I help you?

Male customer: Hello... I can't print.

Helpdesk: Would you click on start for me and ...

Customer: Listen pal; don't start getting technical on me! I'm not Bill Gates!

--------------------------------------------

Hi good afternoon, this is Martha, I can't print. Every time I try it says 'Can't find printer'. I've even lifted the printer and placed it in front of the monitor, but the computer still says he can't find it...

--------------------------------------------

Customer: I have problems printing in red...

Helpdesk: Do you have a colour printer?

Customer: No.

--------------------------------------------

Helpdesk: What's on your monitor now ma'am?

Customer: A teddy bear my boyfriend bought for me in the supermarket.

--------------------------------------------

Helpdesk: And now hit F8.

Customer: It's not working.

Helpdesk: What did you do, exactly?

Customer: I hit the F-key 8-times as you told me, but nothing's happening...

--------------------------------------------

Customer: My keyboard is not working anymore.

Helpdesk: Are you sure it's plugged into the computer?

Customer: No. I can't get behind the computer.

Helpdesk: Pick up your keyboard and walk 10 paces back.

Customer: OK

Helpdesk: Did the keyboard come with you?

Customer: Yes

Helpdesk: That means the keyboard is not plugged in. Is there another
keyboard?

Customer: Yes, there's another one here. Ah...that one does work!

--------------------------------------------

Helpdesk: Your password is the small letter a as in apple, a capital letter V as in Victor, the number 7.

Customer: Is that 7 in capital letters?

--------------------------------------------

A customer couldn't get on the internet...

Helpdesk: Are you sure you used the right password?

Customer: Yes I'm sure. I saw my colleague do it.

Helpdesk: Can you tell me what the password was?

Customer: Five stars.

--------------------------------------------

Helpdesk: What antivirus program do you use?

Customer: Netscape.

Helpdesk: That's not an antivirus program.

Customer: Oh, sorry...Internet Explorer.

--------------------------------------------

Customer: I have a huge problem. A friend has placed a screensaver on my computer, but every time I move the mouse, it disappears!

--------------------------------------------

Helpdesk: Microsoft Tech. Support, may I help you?

Customer: Good afternoon! I have waited over 4 hours for you. Can you please tell me how long it will take before you can help me?

Helpdesk: Uhh..? Pardon, I don't understand your problem?

Customer: I was working in Word and clicked the help button more than 4 hours ago. Can you tell me when you will finally be helping me?

--------------------------------------------

Helpdesk: How may I help you?

Customer: I'm writing my first e-mail.

Helpdesk: OK, and, what seems to be the problem?

Customer: Well, I have the letter a, but how do I get the circle around it?

Sunday, September 28, 2008

Watch online movies tv channels

Great website

Watch online Movies

Listen songs

Live Tv Channels

Telugu,Hindi,Tamil,Kannada,Panjabi,Bengali,Marathi

Bindaasbharat

Tuesday, September 16, 2008

SQL Server programming Group by day,Month ,Year

--group by day

SELECT COUNT(* ),

Dateadd(DAY,Datediff(DAY,0,HireDate),0) 'day'

FROM Employees

GROUP BY Dateadd(DAY,Datediff(DAY,0,HireDate),0)

ORDER BY Dateadd(DAY,Datediff(DAY,0,HireDate),0) DESC



--group by Month

SELECT COUNT(* ),

Dateadd(MONTH,Datediff(MONTH,0,HireDate),0) 'Month'

FROM Employees

GROUP BY Dateadd(MONTH,Datediff(MONTH,0,HireDate),0)

ORDER BY Dateadd(MONTH,Datediff(MONTH,0,HireDate),0) DESC



Friday, September 05, 2008

Wednesday, September 03, 2008

A new web browser from google Chrome


Google Chrome is a browser that combines a minimal design with sophisticated technology to
make the web faster, safer, and easier

One box for everythingType in the address bar and get suggestions for both search and web pages.

Thumbnails of your top sitesAccess your favorite pages instantly with lightning speed from any new tab.

Shortcuts for your appsGet desktop shortcuts to launch your favorite web applications.

Download

Wednesday, August 06, 2008

Internet Explorer 8

Try the new Developer friendly

Internet Explorer

clickhere

Regular Expressions in Dotnet

Quantifiers provide a simple way to specify within a pattern how many times a particular character or set of characters is allowed to repeat itself. There are three non-explicit quantifiers:

  1. *, which describes "0 or more occurrences",
  2. +, which describes "1 or more occurrences", and
  3. ?, which describes "0 or 1 occurrence".

Quantifiers always refer to the pattern immediately preceding (to the left of) the quantifier, which is normally a single character unless parentheses are used to create a pattern group. Below are some sample patterns and inputs they would match.

Pattern

Inputs (Matches)



fo*

foo, foe, food, fooot, "forget it", funny, puffy


fo+

foo, foe, food, foot, "forget it"


fo?

foo, foe, food, foot, "forget it", funny, puffy






In addition to specifying that a given pattern may occur exactly 0 or 1 time, the ? character also forces a pattern or subpattern to match the minimal number of characters when it might match several in an input string.

Explicit quantifiers are positioned following the pattern they apply to, just like regular quantifiers. Explicit quantifiers use curly braces {} and number values for upper and lower occurrence limits within the braces. For example, x{5} would match exactly five x characters (xxxxx). When only one number is specified, it is used as the upper bound unless it is followed by a comma, such as x{5,}, which would match any number of x characters greater than 4. Below are some sample patterns and inputs they would match.

Pattern

Inputs (Matches)

ab{2}c

abbc, aaabbccc

ab{,2}c

ac, abc, abbc, aabbcc

ab{2,3}c

abbc, abbbc, aabbcc, aabbbcc

Metacharacters

The constructs within regular expressions that have special meaning are referred to as metacharacters. You've already learned about several metacharacters, such as the *, ?, +, and { } characters. Several other characters have special meaning within the language of regular expressions. These include the following: $ ^ . [ ( | ) ] and \.

. It matches any single character

^ used to designate the beginning of a string (or line)

$ is used to designate the end of a string

\ is used to "escape" characters from their special meaning

| (pipe) is used for alternation, essentially to specify 'this OR that' within a pattern.

( ) used to group patterns.

Some examples of metacharacter usage are listed below.

Pattern

Inputs (Matches)

.

a, b, c, 1, 2, 3

.*

Abc, 123, any string, even no characters would match

^c:\\

c:\windows, c:\\\\\, c:\foo.txt, c:\ followed by anything else

abc$

abc, 123abc, any string ending with abc

(abc){2,3}

abcabc, abcabcabc

In order to include a literal version of a metacharacter in a regular expression, it must be "escaped" with a backslash.

For instance if you wanted to match strings that begin with "c:\" you might use this: ^c:\\

So something like a|b would match anything with an 'a' or a 'b' in it, and would be very similar to the character class [ab].

Character classes are a mini-language within regular expressions, defined by the enclosing hard braces [ ]. The simplest character class is simply a list of characters within these braces, such as [aeiou].

To specify any numeric digit, the character class [0123456789] could be used. However, since this would quickly get cumbersome, ranges of characters can be defined within the braces by using the hyphen character, -.

Eg: [a-z],[A-Z],[0-9]

If you need a hyphen to be included in your range, specify it as the first character. For example, [-.? ]

You can also match any character except a member of a character class by negating the class using the carat ^ as the first character in the character class. Thus, to match any non-vowel character, you could use a character class of [^aAeEiIoOuU].

Pattern

Inputs (Matches)

^b[aeiou]t$

Bat, bet, bit, bot, but

^[0-9]{5}$

11111, 12345, 99999

^c:\\

c:\windows, c:\\\\\, c:\foo.txt, c:\ followed by anything else

abc$

abc, 123abc, any string ending with abc

(abc){2,3}

abcabc, abcabcabc

^[^-][0-9]$

0, 1, 2, … (will not match -0, -1, -2, etc.)

Metacharacter

Equivalent Character Class

\a

Matches a bell (alarm); \u0007

\b

Matches a word boundary except in a character class, where it matches a backspace character, \u0008

\t

Matches a tab; \u0009

\r

Matches a carriage return; \u000D

\w

Matches a vertical tab; \u000B

\f

Matches a form feed; \u000C

\n

Matches a new line; \u000A

\e

Matches an escape; \u001B

\040

Matches an ASCII character with a three-digit octal. \040 represents a space (Decimal 32).

\x20

Matches an ASCII character using 2-digit hexadecimal. In this case, \x2- represents a space.

\cC

Matches an ASCII control character, in this case ctrl-C.

\u0020

Matches a Unicode character using exactly four hexadecimal digits. In this case \u0020 is a space.

\*

Any character that does not represent a predefined character class is simply treated as that character. Thus \* is the same as \x2A (a literal *, not the * metacharacter).

\p{name}

Matches any character in the named character class 'name'. Supported names are Unicode groups and block ranges. For example Ll, Nd, Z, IsGreek, IsBoxDrawing, and Sc (currency).

\P{name}

Matches text not included in the named character class 'name'.

\w

Matches any word character. For non-Unicode and ECMAScript implementations, this is the same as [a-zA-Z_0-9]. In Unicode categories, this is the same as [\p{Ll}\p{Lu}\p{Lt}\p{Lo}\p{Nd}\p{Pc}].

\W

The negation of \w, this equals the ECMAScript compliant set [^a-zA-Z_0-9] or the Unicode character categories [^\p{Ll}\p{Lu}\p{Lt}\p{Lo}\p{Nd}\p{Pc}].

\s

Matches any white-space character. Equivalent to the Unicode character classes [\f\n\r\t\v\x85\p{Z}]. If ECMAScript-compliant behavior is specified with the ECMAScript option, \s is equivalent to [ \f\n\r\t\v] (note leading space).

\S

Matches any non-white-space character. Equivalent to the Unicode character categories [^\f\n\r\t\v\x85\p{Z}]. If ECMAScript-compliant behavior is specified with the ECMAScript option, \S is equivalent to [^ \f\n\r\t\v] (note space after ^).

\d

Matches any decimal digit. Equivalent to [\p{Nd}] for Unicode and [0-9] for non-Unicode, ECMAScript behavior.

\D

Matches any non-decimal digit. Equivalent to [\P{Nd}] for Unicode and [^0-9] for non-Unicode, ECMAScript behavior.

Sample Expressions

Most people learn best by example, so here are a very few sample expressions.

Pattern

Description

^\d{5}$

5 numeric digits, such as a US ZIP code.

^(\d{5})|(\d{5}-\d{4}$

5 numeric digits, or 5 digits-dash-4 digits. This matches a US ZIP or US ZIP+4 format.

^(\d{5})(-\d{4})?$

Same as previous, but more efficient. Uses ? to make the -4 digits portion of the pattern optional, rather than requiring two separate patterns to be compared individually (via alternation).

^[+-]?\d+(\.\d+)?$

Matches any real number with optional sign.

^[+-]?\d*\.?\d*$

Same as above, but also matches empty string.

^(20|21|22|23|[01]\d)[0-5]\d$

Matches any 24-hour time value.

/\*.*\*/

Matches the contents of a C-style comment /* … */

Regex test;

test = new Regex("testing");

Match m = test.Match("here is a string for testing");

if (m.Success) {

// do whatever you want

}

Wednesday, July 30, 2008

Saturday, July 12, 2008

Web Page/Server Control Life Cycle Methods and Events

Method (Event) / Description
1. OnInit (Init)

Initializes each child control of the current
control.

2.LoadControlState

Loads the ControlState of the control. To use this method, the control must call the Page.RegisterRequiresControlState method in the OnInit method of the control.

3.LoadViewState

Loads the ViewState of the control.

4.LoadPostData

Is defined on interface IPostBackDataHandler. Controls that implement this interface use this method to retrieve the incoming form data and update the control’s properties accordingly.

5.Load (OnLoad)

Allows actions that are common to every request to be placed here. Note that the control
is stable at this time; it has been initialized and its state has been reconstructed.

6.RaisePostDataChangedEvent

Is defined on the interface IPostBackData-Handler. Controls that implement this interface
use this event to raise change events in response to the Postback data changing between the current Postback and the previous
Postback. For example, if a TextBox has a TextChanged event and AutoPostback is turned off, clicking a button causes the Text-Changed event to execute in this stage before handling the click event of the button, which is raised in the next stage.

7.RaisePostbackEvent

Handles the client-side event that caused the Postback to occur.

8.PreRender (OnPreRender)

Allows last-minute changes to the control. This event takes place after all regular Post-back events have taken place. This event takes place before saving ViewState, so any changes made here are saved.

9.SaveControlState

Saves the current control state to ViewState. After this stage, any changes to the control state are lost. To use this method, the control must call the Page.RegisterRequiresControlState method in the OnInit method of the control.

10.SaveViewState

Saves the current data state of the control to ViewState. After this stage, any changes to the control data are lost.

11.Render

Generates the client-side HTML, Dynamic Hypertext Markup Language (DHTML), and script that are necessary to properly display this control at the browser. In this stage, any changes to the control are not persisted into ViewState.

12.Dispose

Accepts cleanup code. Releases any unman-aged resources in this stage. Unmanaged resources are resources that are not handled by the .NET common language runtime, such as file handles and database connections.

13.UnLoad

Accepts cleanup code. Releases any managed resources in this stage. Managed resources are resources that are handled by the runtime, such as instances of classes created by the .NET common language runtime.

Heaven or Hell

Once an old man was sitting in the park reading book "learn Oracle in 21days".

A passer by saw him and asked "U are such an old guy, why do you bother to learn Oracle?

"I have heard that communication language at heaven is Oracle so after my death when I will be in heaven, I don't want to face communication
problem."old man replied.

"But how come u are so sure that U will be in heaven? It could be a hell also." he asked.

"Ya, doesn't matter .... I already know J2EE"

Fate and the Heart

Kindergarten teacher has decided to let her class play a game. The teacher told each child in the class to bring along a plastic bag containing a few potatoes. Each potato will be given a name of a person that the child hates, so the number of potatoes that a child will put in his/her plastic bag will depend on the number of people he/she hates. So when the day came, every child brought some potatoes with the name of the people he/she hated. Some had 2 potatoes; some 3 while some up to 5 potatoes.


The teacher then told the children to carry with them the potatoes in the plastic bag wherever they go for 1 week.

Days after days passed by, and the children started to complain due to the unpleasant smell let out by the rotten potatoes. Besides, those having 5 potatoes also had to carry heavier bags. After 1 week, the children were relieved because the game had finally ended.

The teacher asked: 'How did you feel while carrying the potatoes with you for 1 week?' The children let out their frustrations and started complaining of the trouble that they had to go through having to carry the heavy and smelly potatoes wherever they go. Then the teacher told them the hidden meaning behind the game.


The teacher said: 'This is exactly the situation when you carry your hatred for somebody inside your heart. The stench of hatred will contaminate your heart and you will carry it with you wherever you go. If you cannot tolerate the smell of rotten potatoes for just 1 week, can you imagine what is it like to have the stench of hatred in your heart for your lifetime???'


Moral of the story:


Throw away any hatred for anyone from your heart so that you will not carry sins for a life time.
Forgiving others is the best attitude to take! Life is to be fortified by many friendships. To love & to be loved is the greatest happiness.

Fate determines who comes into our lives. The heart determines who stays.

Friday, June 27, 2008

Convert a comma separed values in to table

CREATE FUNCTION [dbo].[ufn_CSVToTable] ( @StringInput VARCHAR(8000) )
RETURNS @OutputTable TABLE ( [String] VARCHAR(10) )
AS
BEGIN

DECLARE @String VARCHAR(10)

WHILE LEN(@StringInput) > 0
BEGIN
SET @String = LEFT(@StringInput,
ISNULL(NULLIF(CHARINDEX(',', @StringInput) - 1, -1),
LEN(@StringInput)))
SET @StringInput = SUBSTRING(@StringInput,
ISNULL(NULLIF(CHARINDEX(',', @StringInput), 0),
LEN(@StringInput)) + 1, LEN(@StringInput))

INSERT INTO @OutputTable ( [String] )
VALUES ( @String )
END

RETURN
END
GO