Thursday, 23 June 2016

// // 1 comment

T-SQL Script for Shrink Log file in SQL Server

Here is the useful T-SQL Script for shrink database log file.

USE [DatabaseName];
-- Truncate the log by changing the database recovery model to SIMPLE.
-- Shrink the truncated log file to 1 MB.
DBCC SHRINKFILE (DatabaseName_log, 1);
-- Reset the database recovery model.

Read More

Monday, 13 June 2016

// // Leave a Comment

What is the backup strategy in your organization? SQL Server Interview Question

This is common SQL Server interview questions, Interviewer want to know standard  by this questions. (this question was asked during TCS interview Gurgaon)
So be prepare for this question, for answer you can tell the backup strategy of your organization.
Here we are sharing sample answer.
Answer: In our org. we have created a backup tool that can interact with the servers and storage system without human intervention. All we have to do is the initial configuration and mae sure the power is up at all times
Read More

Monday, 6 June 2016

// // Leave a Comment

SQL Server Stored Procedure Example, with Try-Catch, Function, TempTable,@@Error

Some time interviewer asked to write down a procedure with below functionality, This stored procedure Example will show you how use

  • Try catch block
  • Use of Transaction
  • Use of Temp table
  • Use of user defined Function
  • @@Error

in a Stored procedure

-- =============================================
-- Author: <Author,Vikas Ahlawat>
-- Create date: <Create 8th June 2012>
-- Description: <Description, It will return temp Room rates table according rooms>
-- =============================================
CREATE PROCEDURE [dbo].[usp_GetTempRoomsRateTable]
@GuestID INT,@ArrayRoomList nvarchar(500), @DateFrom DATETIME,
@DateTo DATETIME,@Adult INT,@Child INT,@iHotelID INT,
@Discount DECIMAL,@TravalAgentID INT,@WantToSave BIT
SELECT * FROM fn_ReturnRateTable(@GuestID,@ArrayRoomList,@DateFrom,@DateTo,@Adult,@Child,@iHotelID,@Discount,@TravalAgentID)
IF(@WantToSave = 1 AND @GuestID >0)
IF EXISTS (SELECT * FROM sys.tables WHERE name='#TempAppliedRate')
     DROP TABLE #TempAppliedRate
     SELECT * INTO #TempAppliedRate FROM fn_ReturnRateTable(@GuestID,@ArrayRoomList,@DateFrom,@DateTo,@Adult,@Child,@iHotelID,@Discount,@TravalAgentID)
     DELETE FROM dbo.AppliedRateInfo WHERE iGuestID = @GuestID
     INSERT INTO dbo.AppliedRateInfo(iGuestID, RoomID,RoomNumber,PostingDate,RoomAmtWithoutDiscountAndTax,RoomAmtWithDiscount,Adults,Children,RoomType,DiscountPercent,Total,TravelAgentID ,TravelAgentCommissionPercent,TravelAgentCommission)
     SELECT @GuestID,RoomID,RoomNumber,PostingDate,RoomAmtWithoutDiscountAndTax,RoomAmtWithDiscount,Adults,Children,RoomType,DiscountPercent,Total,TravelAgentID ,TravelAgentCommissionPercent,TravelAgentCommission FROM #TempAppliedRate
   IF(@@ERROR <> 0)

Read More
// // 1 comment

How to convert from decimal to binary in SQL Server? Write the Script/Query, Interview Question 2016

Write a function to convert decimal number to binary number in SQL Server? (asked during Genpact interview Jun 2016)


CREATE FUNCTION fn_ConvertFromDecimal2Binary
( @Num int )
DECLARE @quot int
DECLARE @Rem int
DECLARE @Res varchar(30) = ''
Set @quot= @Num

SET @Rem = @quot%2
SET @quot = @quot/2
SET @Res= CONVERT(varchar(30),@Rem)+ @Res
SET @Res = (CONVERT(varchar(30),@quot) + @Res)

Read More
// // Leave a Comment

Genpact SQL PL/SQL Interview Question Answers 2016

Today I want to share my interview experience with you, Genpact was looking for 4+ years SQL Server Experienced Developers, I attend this interview(25/05/2016) to know the latest SQL Server question asked in marked currently.
Before the I was attended TCS interview for same position.
Below are the set of query which are asked during my Genpact interview question answers session(tech round), Which was held in Gurgaon Genpact office.

1). Write down the query to print the first date of current month using Getdate() function?

2). Can you explain SQL Server 2016 New Feature for Drop Object if Exist.(DROP IF EXISTS).
Ans: Click here for answer

3). What is the use of @@Error in SQL Server, please explain.
Ans: Click here for answer

4). Is view store data physically apart from table or not?
Ans: A view is just a macro, it has no persistent storage.The underlying table data is stored in the MDF file

5). Table Tbl1 has 100 rows, Table Tbl2 has 0 rows so number of rows returned by the below query?
SELECT Tbl1.* from Tbl1, Tbl2;
Ans : No row will be retun by this query

6). Write a query to print 1 to 100 in sql server without using loops?
Ans: Click here for answer

7). What is the difference between SQL, PL-SQL and TSQL
Ans: Click here for answer

8). When would you use stored procedure or functions ? 
Ans: Functions are computed values and cannot perform permanent environmental changes to SQL Server (i.e. no INSERT or UPDATE statements allowed).
A Function can be used inline in SQL Statements if it returns a scalar value or can be joined upon if it returns a result set.
for more see the difference between them, and use according to that.

9). What is function in SQL Server, Write a function to convert Decimal number to Binary number?
Ans: Click here for answer

10). Can you edit Sql Profiler existing/default templates? 
Ans: Click here for answer

11). How you will execute the stored procedure as a different user in SQL Server?
Ans: I will use EXECUTE AS
EXECUTE AS user = 'special_user'
EXECUTE YourProcerdure
Read More

Thursday, 2 June 2016


Top 30 Appcelerator Titanium Interview Questions and Answers

Here we come up with most growing technology for Mobile world known as Appcelerator.
Appcelerator is enabling developers to build mobile apps with one common language and distribute apps to many different platforms. The idea itself is already a good one. Especially if they're using a scripting language that is so widely known and used as javascript.
There are challenges of-course, but so far they're doing quite well. There is new major version of Titanium SDK coming out that's supposed to be even faster. The community is rather strong. Their approach to open source ideology is spot on. Many large tech companies have apps in stores built on top of Titanium.
I believe Appcelerator is going to be best mobile app development platform soon, I had great future.

Here are the Appcelerator Titanium Interview Questions and Answers

What do you understand by cross-platform mobile development?
Cross-platform mobile development refers to the development of mobile apps that can be used on multiple mobile platforms. In todays business world there are multiple platefor to run app, so Cross-platform development have very good demand.

Explain what is Appcelerator Titanium?
Appcelerator Titanium is an open-source framework that allows the creation of mobile apps on platforms including iOS, Android and Windows Phone from a single JavaScript codebase, developed by Appcelerator.

What are some different mobile platform supported by Appcelerator Titanium?
iOS, Android, BlackBerry, Windows

What are the advantages of Appcelerator Titanium platform?
Cross-platform mobile development support:Titanium offers optimum solution to develop cross-platform apps on different platform and devices. It is a cross-platform JavaScript run-time as well as API framework used to carry out mobile development on Android as well as iOS. This platform is especially designed keeping in mind mobile web with possible future support for Blackberry and Windows.

Developed using a JavaScript-based platform with an integrated Eclipse-based IDE:
Titanium framework uses code written in JavaScript, combines this code with the Titanium API (which is in written in the targeted device’s native language) further evaluates code at runtime using JavaScript interpreter which runs on the device’s operating systems.
Faster than other Mobile application framework:TITANIUM helps in developing mobile applications 70 times faster than other mobile
application framework available in the market. This framework helps in developing mobileapps in much less time as compared to others.

Flexibility:TITANIUM is an important tool to develop different web based applications including e-books, mobile applications and other business applications

Great Look and feel:The look and feel of a Titanium application, using common UI widgets of the platform is an added advantage.
Titanium offers several user-friendly features across multiple platforms which should be used by the developers. Titanium is an attempt to achieve code reuse using a unified JavaScript API, with platform-specific features and native performance.

Easy to learn & deploy:Developers can easily learn about this framework as it comprises HTML5, CSS3, jQuery, Ajax and JavaScript. So, it will be extremely easy for expert to learn every nitty-gritty aspect of Titanium and make use it to empower in the design work.

What are the Disadvantage\Limitations of using the Titanium mobile application development?
Extending to other platforms:The Titanium platform is only available for the iOS, Android platforms and the web. To implement the Titanium API on new platforms like the upcoming Windows 8 is an immense undertaking.

Non-native user experience:The performance and feel of UI widget sets that Titanium provides need more work. They do not feel similar to the native controls offered by their SDKs.

Sub-optimal API implementation:As the layer of abstraction offered by Titanium is large, sub-optimal API implementation remains in its internal framework. Optimizing the core user interface components remains the major engineering task for its developers.

Huge learning curve:A comprehensive knowledge of Titanium's architecture and the environment is required to effectively integrate an innovative native control or API. High level guides for module developers were improved to a great extent but still need to be worked upon.

How you will previewing a mobile web project in an emulator?
To preview your app in an emulator, open the project in the App Explorer, or Project Explorer, click on the launch button, and select "Mobile Web Preview in Emulator".

Explain some best feature of Appcelerator Titanium Framework?

  • Supports Multiple Platforms
  • JavaScript API
  • Native Code
  • Requires Trending Web technology
  • Advanced Quality
Explain the architecture of Appcelerator Titanium?
The core features of Appcelerator Titanium include:
A cross-platform API for accessing native UI components such as navigation bars, menus, and dialog boxes and native device functionality including the file system, network, geolocation, accelerometer, and maps.
Transparent access to native functionality not already covered by the API.
All application source code gets deployed to the mobile device where it is interpreted using a JavaScript engine; Mozilla's Rhino is used on Android and BlackBerry, and Apple's Javascriptcore is used on iOS. In 2011 it was announced that a port to Google's V8 JavaScript engine is in development which, when complete, will significantly improve performance. Program loading takes longer than it does for programs developed with the native SDKs, as the interpreter and all required libraries must be loaded before interpreting the source code on the device can begin.

What is an Appcelerator Analytics data point?
An Analytics data point is an event that occurs in your app that is reported back to the Appcelerator Analytics service. This allows developers to track what users are doing in their apps. Examples of events that can be tracked include logins, navigation events, purchases, or any other actions that the developer chooses to instrument.

How you will optimize a Titanium app?
You mostly have to care about memory leaks. You have a VERY important webcast on the subject. In short; be very careful to :

  • Avoid big global objects : they have references to the world, so these references won't be cleared
  • Eliminate any circular dependances : the garbage collector is NOT a garbage collector ! It just count references and kill objects when there is 0 refs. With circular objects, there is always 1 ref.
  • Avoid events on Ti.App : ouch that sucks ! But the object that ask addEventListener is for ever in the Ti.App listener bus. The bus keeps a reference to send the event to that object, so it will be there forever, so will be its references.
  • Be careful with other events.
  • Be also careful with animations : they have callbacks that have references to the application. These callbacks are function (so variables) that may stay in memory, so do its references.
  • Write myDownObject=null when you go up in the tree. Use HEAVILY Instruments on your mac, with a 'Proxy' filter. All titanium objects are UIProxy.
What do you understand by ArrowDB?
Appcelerator ArrowDB provides a set of REST APIs for creating, managing, and accessing different types of data in your cloud datasoucrce, such as Users, Places, and Photos over HTTP or HTTPS. You can integrate ArrowDB into your application using the Titanium, iOS, Android or Node.js SDKs, or by calling the REST APIs directly.

Explain ArrowDB admin access?
ArrowDB admin access allows application admin users to execute some batch operations and make ArrowDB API calls on behalf of another user.

How you will create an Hellp, World Titanium app. Write the code?
In the Project Explorer view, open index.xml located in the app/views folder. As below

How to query the child views of a parent view using Titanium?
if (view.children) {
        for (var c = view.children.length - 1; c >= 0; c--) {

How you will apply MVC Architecture in Titanium mobile apps?
Click here for answer

Read More

Wednesday, 1 June 2016

// // Leave a Comment Quiz\Puzzle Answer (Splitting Strings Puzzle)

Puzzle Questions : Read here

SELECT SplitMyString,Count(*) Counts FROM ( SELECT
LTRIM(RTRIM(m.n.value('.[1]','varchar(8000)'))) AS SplitMyString
(SELECT CAST('<XMLRoot><R>' + REPLACE(cols,';','</R><R>') + '</R></XMLRoot>' AS XML) AS x FROM   SplitWithCount

)t CROSS APPLY x.nodes('/XMLRoot/R')m(n) ) M GROUP BY SplitMyString


Answer2(Best Ans):(by Hermann Cardenas)

declare @sql varchar(max) = ''
select @sql = @sql + 'as nm union all select ''' + replace(cols, ';', ''' as nm union all select ''') + '''' from splitwithcount
set @sql = 'select nm, count(*) cnt from (' + SUBSTRING(@sql, 17, len(@sql)) + ') a group by nm'

Read More
// // Leave a Comment

Shivprasad Koirala .NET Interview Questions 7th Book Free of Cost : Share and Get Quiz

Now you have double chance to win Shivprasad Koirala's most famous .Net Interview Question 7th edition book. Yes!! Now say no to PDF, Ebook. You will get hard-copy.

Now there are three quiz for same book
1. 7th edition Sponsored by InterviewQuestionspdf.Com
2. 7th edition Sponsored by
3. 6th edition Sponsored by InterviewQuestionspdf.Com
Read More