Pages

Tuesday, March 4, 2014

TSQL - To visually identify if there is a Carriage Return / New Line character within the VARCHAR column

Scenario:

We have a scenario, where in we need to know if there is any carriage return('\r') or a new line('\n') character is embedded in a VARCHAR/TEXT column. 


Solution: 

This cannot be simply achieved by using SELECT statement. PRINT function enables us to know the presence of such characters. Let us now see how.

Step 1:

 Let me a create simple table for your easy understanding using the following script. 

CREATE TABLE [dbo].[TestDB_Test1](
[COL1] [int] IDENTITY(1,1) NOT NULL,
[COL2] [varchar](150) NULL
) ON [PRIMARY]

GO


Step 2: 

Lets insert two rows for COL2, one  without carriage return/new line  and the other one with the carriage return/new line. 

-- Sample data without carriage return/ new line character

INSERT INTO [dbo].[TestDB_Test1]
           ([COL2])
     VALUES
           ('I am Line1. I am Line2')
GO



-- Sample data with carriage return/new line character

INSERT INTO [dbo].[TestDB_Test1]
            ([COL2])
VALUES
('I am Line1.' + CHAR(10)+ 'I am Line2')

Step 3: 

Run a SELECT query, to see how the data appears. 


SELECT * from dbo.TESTDB_Test1 





The two rows appears to be same after a SELECT query. 

Step 4: 

Create a variable to hold the value of COL2 using a select query. 

DECLARE @var varchar(150) 

SELECT @var = col2 FROM TestDB_Test1 where col1 = 1

PRINT @var





DECLARE @var varchar(150) 

SELECT @var = col2 FROM TestDB_Test1 where col1 = 2

PRINT @var



This clearly shows that the text in row 2 had a new line character in between.  In order to remove such redundant characters, one could always use REPLACE function. 

Wednesday, February 19, 2014

Mickey Mouse Themed Guest Message

A cute way to treasure the message from the guest to the LO on the 1st Birthday. 


Mickey Mouse Oreo Cookies

This item was also part of my LO's first birthday party. The little guests in the party thoroughly enjoyed eating them and loved the taste too.  


Ingredients

Oreo cookies - Regular size - 1 pack

Mini Oreo cookies - 1 pack

Wax paper

Red Chocolate Melts - 1 pack (we got it from Jo-Ann)

Dark Chocolate Melts - 1 pack(Also from Jo-Ann)

White circular sprinklers / White tube (From Michael's)

Procedure

Melt the Chocolate(Red and Dark Chocolate)

  • For the melts, pour some of red chocolate melts into a bowl/cup, put them in the microwave for about 30 seconds. 
  • Mix the melts frequently. 
  • Once the consistency of the chocolate is attained, leave it aside. 
Caution: Do not over heat the chocolate melts, because if you overheat, they may end up becoming powder. 

  •   Repeat the same procedure for Dark chocolate melts as well. 

Make the cookies

  • Dip the regular sized Oreo cookie into chocolate melt until half way. 
  • Place it on a wax sheet spread over a tray, undisturbed. 
  • Repeat this procedure for all the regular sized Oreo cookies that you want. 
  • Put the tray in the refrigerator for few minutes(3 - 5 minutes approx. ), to let the chocolate dry. 
  • Remove the cookies from the refrigerator and mark lines over the top of the cookie to place the mini Oreo cookies over it(resembling ears of the cookie)
  • Dip a small edge of the mini Oreo into the Dark chocolate melt, and place it over the regular one, touching its surface like the one in the picture. 
  • Repeat for the other end too. 
  • Now, repeat the same procedure for the rest of the cookies. 
  • Place them in the refrigerator for it to solidify for about 3- 5 minutes. 
  • Remove the cookies from the refrigerator and place two white circular sprinkles/ white gelatin to represent the buttons over the red melt. 

Picture speaks more than words.... 


Tuesday, February 18, 2014

Mickey Themed First Birthday Photo Gallery

We have made this photo gallery for our LO's first birthday. It looked so cute,  everyone loved to see the pictures and it matched our theme as well. You can make it in your party as well. 

All you need is, 


Black craft sheets - 13 (qty) (we got it from Michael's)

Glue

Yellow/ Red Satin ribbon - 1

Carving Knife / Carving Pen

Pictures of your LO (From NB to 12 month old) - 13 


Steps: 


  • Draw two concentric circles of diameters 4 and 5 cm approx. on the black craft paper that    you have.  
  •  Draw two circles  of 0.5 - 1 cm diameter on top of the outer circle, to represent mickey      ears. 
  • Carve out the inner circle, to see through it using a carving knife/pen.
  • Glue the picture to the back of the outer circle and carve out the excess part of the picture to make it a circular one. 
  • Punch a hole on each of the ear to let the satin ribbon pass through it.
  •  Connect each mickey photo through this ribbon to get your mickey gallery. 






Tuesday, January 21, 2014

Crispy Pepper Corn - A Munching snack

Ingredients: 


American Sweet Corn (golden)- 1 pack

Finely chopped Onions - 1 cup 

Green chilies - 7 to 8 (Slit along the stem)

Curry leaves - 2 sticks

Pepper powder - 2 tbsp

All Purpose flour - 1 cup

Corn flour - 1 cup

Soy sauce

Salt 

Ginger - Garlic Paste (Fresh Preferable)

Oil (Olive or Canola , depends on your usage)

Method:

First Coat for Sweet Corn:

  • Take a mixing bowl .
  • Add 2 tsp of ginger garlic paste, salt according your taste, pepper powder as per your taste (usually 2 tsp is enough, you don't want it to be too peppery! ) and 2 tbsp of all purpose flour to it. 
  • Add some water, and mix it thoroughly(Add only little amount of water, to get the right consistency, you don't want it to be too watery!) to get it to a dosa batter consistency.
  • Now, add the sweet corn to the mixture to get some coating over it. 
  • Keep it soaked in it for few minutes. 

Second Coat for Sweet Corn:

  • Take another mixing bowl.
  • Add 3/4 cup of All purpose flour to 1/4 cup Corn Flour into the bowl.
  • Mix the flours thoroughly.
  • Add the soaked corn to the mixture, and see that you get a right coat. 
Do this just before you transfer the corn for shallow fry. So that coating remains intact until it goes for frying. If you do this way before, the coating is absorbed by the wet corn, thus making it a bad corn for the recipe. 

Shallow Fry the Corn :

  • Heat a skillet filled with oil for a shallow fry. 
  • When the oil is ready , add the corn (after the Second Coat) to it.
  • When you add the corn to the hot oil, there are high chances that the corn splits and pops up onto your face, make sure that you protect yourself from the pops using a lid to cover the skillet partially. 
  • Shallow fry the corn till they turn golden brown.
  • Transfer them to a blotting paper to remove the excess oil.

Gravy:

  • Heat the pan wit a little amount of oil.
  • When the oil is sufficiently heated, add ginger garlic paste to it. 
  • After the paste turns golden color, add the chopped onions, green chilies, curry leaves to it. 
  • Keep mixing the contents until they all are thoroughly fried 
  • Add a little amount of soy sauce, salt to it and let it fry again.
  • Now add the shallow fried corn to it. 
  • Let it be on stove for a while by mixing them. 


Switch of the stove! The crispy pepper corn is now ready to serve! This recipe is a nice munching snack for vegans!

Double Ka Meetha - Hyderabadi delicacy

Ingredients:


Bread (White Preferably, with edges chopped off) - 10 Pieces 

Milk - Half a litre

Chopped Almonds  

Chopped Pistachio 

Raisins 

Cashew Nuts 

Sugar - 1 cup

Water - 1 cup

Ghee - For frying the bread slices and nuts

Cardamom Powder - 2 to 3 tsp


Procedure:

Sugar Syrup 

  • Add 1 cup of sugar to 1 cup of water in a pan and let it boil.
  • Stir the mixture continuously.
  • Add some cardamom powder to it and let it boil for some more time. 
  • Switch off the stove as and when you see the bubbles over the boiling mixture. (The bubbles indicate that the syrup is ready to use) Let it cool down. 

Bread Pieces:

  • Chop of the edges of the bread. 
  • Cut the bread pieces across the diagonal or cut into four pieces. Defrost the bread pieces in microwave for 40 seconds, to remove any moisture from them, you can also put them under sun for the same. This will eliminate the absorption of excess ghee in the next step. 

  • Heat the ghee in a pan and add the bread pieces to deep fry them. 
  • Keep turning them occasionally until they are golden brown.
  • Take the fried bread pieces onto a blotting paper , to remove the excess oil/ghee and let them cool down

Milk : 

  • Take a pan, and pour half a liter milk in it.
  • Let the milk boil till it reduces to half the amount.
  • When the milk reduces to half the amount taken, switch of the stove and let it cool. 

Dry Fruits:

  • Heat little amount of ghee into a small pan to fry the dry fruits taken. 
  • When the ghee is ready , add chopped almonds & pistachios to it. 
  • When the almonds and pistachios have fried half a way, add cashew nuts to it. 
  • When the cashew nuts have turned a little brown, add raisins to it  . 
  • Switch of the stove as and when the raisins blow up.
This is to avoid over burning of raisins and cashews.

Final Step: 

  • Take an aluminium tray, grease it with oil or ghee to avoid sticking to the surface.
  • Arrange the fried bread slices in the tray. 
  • Pour the reduced milk and sugar syrup evenly over the arranged bread slices. 
  • Sprinkle the dry fruits evenly. 
  • Preheat the oven to 175 C
  • Cover the aluminium tray with the foil.
  • Place the try in the oven and bake it for 30 - 40 minutes  depending upon the milk/syrup added.  

After 30 minutes, remove the tray from the oven and let it cool. 

Slurp! Slurp! Yummy double ka meetha is ready to serve. 




Thursday, December 19, 2013

SSIS - How to check if a File exists

Scenario:

We have a scenario, in which we have to check if a file exists in a folder. 

If the file exists , delete it and if the file does not exists, create a new one and append some data to it. 

Solution:

We can achieve this, using a simple script in "Script Task" in the Control Flow. 

Lets say, 
File name: Commands.bat 
File Path: I:\Commands.bat

Moving on to how to achieve this.

Step 1: 

Create the following variables at package level.

v_fileName = "Commands.bat" (Give the name of the file that you are checking for)
v_filePath = "I:\" (Give the folder where the file has to be located at)


Step 2: 

Drag and Drop the Script task from the tool box to the work space(control flow) and click on the bubble for ReadOnlyVariables.






Step 3: 

select the input variables for the Script task as shown below. 


Click on OK and then click on Edit Script



Step 4: 

Copy the code which is shown below



 Step 5: 

Execute the task to see the file created. 
Before Executing task





After Executing ScriptTask