Thursday, July 25, 2013

Find all Stored Procedures depending on a Table in Database

We can use sp_depends, sp_depends displays information about database object dependencies, such as the views and procedures that depend on a table or view, and the tables and views that are depended on by the view or procedure

But some times sp_depends does not always return accurate results.

Here is how you can get accurate results by using this query’s below

SELECT DISTINCT o.name, o.xtype
FROM syscomments c
INNER JOIN sysobjects o ON c.id=o.id
WHERE c.TEXT LIKE '%TableName%'


Save results with headers in SQL Server Management Studio

I am working a lot with excel and CSVs for my SSIS packages these days. so I need to some input files as CSV files from SQL Server. Here is what I did in SQL Server Management Studio to get CSV files with Headers
  1. Go to Tools in SQL Server Management Studio and click options.
  2. Now click on Query Results and select SQL Server.
  3. Now go to Results to Grid.
  4. Select “Include column headers when copying or saving the results. (shown in below image)
  5. Click OK
  6. Restart SQL Server Management Studio and you are good to go now.
 image Now open your query window and write you query and execute. On the results window right click and select  "save results as" and then save to CSV file which I can open in excel. 


Getting all Triggers in a Database

Some times you might want to know what are the triggers available across your database. Here is how you can know by using the below query.

-- Displays all Triggers in a Database 
SELECT
[Table] = OBJECT_NAME(o.parent_obj),
[Trigger] = o.[name],
[Type] = CASE WHEN
(
SELECT cmptlevel
FROM master.dbo.sysdatabases
WHERE [name] = DB_NAME()
) = 80 THEN
CASE WHEN
OBJECTPROPERTY(o.[id],
'ExecIsInsteadOfTrigger') = 1 THEN
'Instead Of'
ELSE
'After'
END
ELSE
'After'
END,
[Insert] = CASE WHEN
OBJECTPROPERTY(o.[id],
'ExecIsInsertTrigger') = 1 THEN
'Yes'
ELSE
'No'
END,
[Update] = CASE WHEN
OBJECTPROPERTY(o.[id],
'ExecIsUpdateTrigger') = 1 THEN
'Yes'
ELSE
'No'
END,
[Delete] = CASE WHEN
OBJECTPROPERTY(o.[id],
'ExecIsDeleteTrigger') = 1 THEN
'Yes'
ELSE
'No'
END,
[Enabled?] = CASE WHEN
OBJECTPROPERTY(o.[id],
'ExecIsTriggerDisabled') = 0 THEN
'Enabled'
ELSE
'Disabled'
END
FROM sysobjects o
WHERE OBJECTPROPERTY(o.[id], 'IsTrigger') = 1
-- Comment out the following clause if you need to
-- include system triggers, e.g. those in MSDB
AND OBJECTPROPERTY(o.[id], 'IsMSShipped') = 0
ORDER BY 1,2

Thursday, July 18, 2013

64 అర్ట్స్– (aravai naalugu kaLalu)

It is believed that lord Krishna possesses 64 kinds of arts called "Chausath Kalas".  Kala means performing an art.  Here are the list of 64 అర్ట్స్

61436_499527616745167_1132042074_n

IRCTC Launches SMS/USSD based Mobile Bookings

Railway e-ticket now on mobile
  • IRCTC introduces for the first time a non-internet based ticketing system that will empower masses even in remote areas to use the omnipresent mobile device to make reservations.
  • Millions of rail travellers can now use their mobile phones to book tickets in a simple, convenient and secured manner.
  • It uses simple SMS or menu-based USSD technology which works on all mobile phones and involves no internet and costs very little.
  • The services can be currently availed by IRCTC registered users only.
Advantages of booking IRCTC tickets via mobile
  • No need to stand in long queues or log onto the internet.
  • Simple, reliable and secured.
  • Accessible to any mobile user.
  • Very little charges for accessing the service.
  • Works on all handsets.
  • Simple user guided menu - book tickets, search for stations, trains, availability.

1. USSD based booking through Airtel*

Registration
  • Register for Airtel money by dialing USSD (Unstructured Supplementary Services Data) number *400#.
  • Load cash on this or recharge from any Airtel money outlet.
Booking Flow
  • Dial *400# and select book tickets option.
  • Select Reservation.
  • Enter your IRCTC User ID.
  • Enter the details of ticket (station, train no. date of journey, class etc.).
  • Enter mPIN for authorizing payment through Airtel money.
  • Booking confirmation SMS is sent by IRCTC and same can be used during journey along with valid ID proof..
  • Fare & service charges are debited from your Airtel money account.
  • PG Charges: Currently NIL
  • Agent Service Charges: Currently NIL
  • Helpline No.: 121
  • Helpline Email : 121@airtelmoney.in

2. SMS based booking through 139*

Registration
  • Register your mobile number with IRCTC as well as with your bank.
  • Bank provides MMID (Mobile Money Identifier) & OTP (One Time Password) through IMPS (Immediate Payment Service) option.
  • More than 25 banks are providing IMPS facility. For generating MMID & OTP, visit website: http://www.npci.org.in/impsmerpay10.aspx.)
Booking Flow
  • Generate OTP through your Bank for authorization of payment.
  • Send SMS, in the following syntax, to 139 BOOK <TrainNo><FromStn.Code><ToStn.Code> <TravelDate (DDMM)><Class><Passenger-Name><Age><M/F>
  • You will receive Transaction ID alongwith other details.
  • Make payment through sending an SMS, in the following syntax, to 139 PAY <Transaction ID as received><IMPS><Your MMID as received from the bank><OTP, your one time password as received from the bank for this transaction><IRCTCUserID> and your ticket is booked; confirmation SMS is received on your mobile and same can be used during journey along with valid ID proof.
  • Service is available to all mobile subscribers.
  • SMSes @ Rs 3/- per SMS (2 SMSes are required for each booking).
  • PG charges Rs 5/- for ticket amount < Rs 5000/ and Rs 10/- for ticket amount >= Rs 5000/- (as applicable by bank).
  • Agent Service Charges: NIL
  • Helpline No.: 139
  • Helpline Email : smsticket139@bharatbpo.in

3. SMS based booking through 5676714*

Registration
  • Register your mobile number with IRCTC as well as with m-wallet (http://www.zipcash.in/user/nlogin.aspx)
  • Send SMS, to 5676714, in the following syntax START < irctc user Id > for user authentication (first time only)
Booking Flow
  • Send an SMS to 5676714 to book a ticket in the following syntax: BOOK <From stn.code>,<to stn.code>, <DDMMYY>, <Trainno>,<Class>,<passenger name>,<age>,<M/F>
  • 1. "PAY , MPAY, < m-PIN >" for authorizing payment through MPAY OR
  • 2. "Send <mobileno>,<mmid>,<amount>, <transaction Id>,<OTP>" to your Bank IMPS number.
  • After payment is made booking confirmation is sent to your mobile.
  • SMSes @ Rs 3/- per SMS (2 SMSes are required for each booking).
  • PG Charges: Currently NIL
  • Agent Service Charges: As applicable.
  • Helpline No. : 8882001001
  • Helpline Email : support@saarthii.com

4. SMS based booking through BSNL*

User should have the following:
  • 1. BSNL SIM card installed.
  • 2. Java enabled mobile phone.
  • 3. Andhra Bank Prepaid card.
  • This is a menu driven application where user has to enter the details asked for in simple step-by-step process to get the ticket.
Registration
  • Install the application.
  • Select the Register option to get the mPIN.
Booking
  • Click the icon BSNL Prepaid Card
  • Select Ticketing > Train (IRCTC)
  • Fill up the journey details such as From stn, To Stn, Train No, DOJ, Class, Quota, passenger details.
  • Enter the mPIN to get the ticket information.
  • SMSes: without charges.
  • PG Charges: Currently NIL
  • Agent Service Charges: As applicable.
  • Helpline No. : 040-39849644
  • Helpline Email : bsnl.support@pyrogroup.com

Disclaimer : The above details are sent on behalf of IRCTC to their customers. I have coped the same email in this blog to make it available for all the public whom it might be useful for quick reference.

How to get username from email address c#

Here is sample code snippet that I have used to get username from the email address. You can use MailAddress Class to get few built in properties for our use.

   1: string FromEmail = ConfigurationManager.AppSettings["NotifyEmail"].ToString();
   2: MailAddress FromAddress = new MailAddress(FromEmail);
   3: objEmail.From = FromAddress;
   4:  
   5: NetworkCredential NetworkCredential = new NetworkCredential(FromAddress.Address, "XXXXXXX");
   6: smtpclient.Credentials = NetworkCredential;
   7:  
   8: // Alternately you want you can try few different properties from MailAddress class.
   9:  
  10: Debug.WriteLine("DisplayName:  " +  FromAddress.DisplayName);
  11: Debug.WriteLine("Host:  " + FromAddress.Host);

This worked for my scenario. Happy coding.

Monday, July 15, 2013

Telugu Alphabets

Many of us tend to forget our own mother tongue with growing globalization or with the dominance of English being more used as communication medium. Here is what I thought should be useful for at least people like me to remember our own alphabets during the course of time.

I have captured from one of Facebook page where I thought sharing would help few of us Smile

Here are the Telugu alphabets

telugu alphabets

PS: I have copied this for the sake of my own repository. No offence or what so ever.

Download Microsoft SQL Server 2014 CTP

Microsoft has announced its most awaited version of SQL SERVER 2014 for Community Preview. The availability of the first public Community Technology Preview (CTP) of SQL Server 2014.

Here are key features of SQL Server 2014:

    • Mission critical performance across all database workloads with in-memory for online transaction processing (OLTP), data warehousing and business intelligence built-in as well as greater scale and availability
    • Hybrid cloud platform enabling organizations to more easily build, deploy and manage database solutions that span on-premises and cloud
    • Faster insights from any data with a complete BI solution using familiar tools like Excel

You can find more information from Microsoft blog here.

SQL SERVER 2012 Express version

Are you working on SQL Server 2005 or 2008 servers. Here is SQL Server 2012 Express version for download

Microsoft® SQL Server® 2012 Express is a powerful and reliable free data management system that delivers a rich and reliable data store for lightweight Web Sites and desktop applications.