Software Testing Frameworks used at InApp

Software testing at InApp is tailored to meet client-specific needs, manage critical testing processes and ensure consistent high quality through repeatable processes. The software testing methods employed here are as follows: Unified Selenium API Automation Framework Robot Framework QTP Modular Framework In-house automation Frameworks Unified Selenium API Automation Framework In Unified Selenium API Automation Framework all objects that will be used to perform actions will be identified and grouped under different nodes, in an XML file. Updating the locator in the XML file will reflect changes in all the areas the locator is referred to. The advantage of this framework is the ease of maintenance. Design API is modeled after human language – If it looks like a button, we call it a button, regardless of implementation Test code does not use locators verbatim – Locators are aliased through the .xml file usAPI exposes locators by UI element type – E.g., button, link, tab, tree node, etc. usAPI transparently handles timing issues, logging, setup/tearDown All tests will be derived from org.usapi.BaseSeleniumTest. This will expose (among others) an object named ‘app’, which is of the type BaseApplication. All interactions with the GUI utilize this ‘app’ object, at no time should there be any need to invoke selenium methods directly. BaseSeleniumTest configures, starts, and stops the selenium client transparently to the test developer. BaseSeleniumTest provides generic methods for use in tests, such as assertTrue, assertFalse, isElementPresent, etc. Note that these methods are application-agnostic. Methods required for a particular application (e.g. to execute SQL queries) do not belong in this class. Robot Framework Robot Framework is a generic test automation framework for acceptance testing and acceptance test-driven development (ATDD). Robot Framework has a modular architecture that can be extended with bundled and self-made test libraries. Test data is defined in files, a file containing test cases creates a test suite, and placing these files into directories creates a nested structure of test suites. When test execution is started, the framework first parses the test data. It then utilizes keywords provided by the test libraries to interact with the system under test. Libraries can communicate with the system either directly or using other test tools as drivers. Test execution is started from the command line or continuous integration tools like Jenkins, Hudson, and the like. As a result, you get the report and log in HTML format as well as an XML output. These provide an extensive look into what your system does. QTP Modular Framework QTP Modular Framework (also known as Functional Decomposition Framework) is the approach where you first identify the reusable code from your test cases. Then you write this reusable code inside different functions and call these functions wherever required. The advantage of this approach is that the reusable code would always stay in one place and thus it would be easy to maintain the code because you would have to make the changes in a single place only. To reuse this piece of code, all you have to do is call the function wherever required. The only challenging part here is to identify the reusable portions in your test case flow. Once that is done, you have to just create functions and use them wherever required. In addition to these popular frameworks, we customize and use frameworks based on client needs such as combining Unified Selenium API Automation Framework with hash maps to use as temporary buffer space and auto email program. Have questions? Contact the software testing experts at InApp to learn more.

Microsoft Azure – A Global Enterprise-Grade Cloud Platform

Microsoft Azure is a cloud computing platform created by Microsoft that is designed to run applications to be scaled out on the internet. Why Microsoft Azure Cloud? Microsoft Azure takes an application-centric view of cloud computing which means that it manages the entire life cycle of the application. From the initial design, development, and testing of the application to deploying it on the cloud, to monitoring and scaling that application when it is running out on the internet. Microsoft offers real-world experience with built apps and services such as outlook.com, Bing, Xbox Live, and Office 365 on cloud technology. All of these technologies are being used to build Azure. What’s with Microsoft Azure? Microsoft Azure is a broad stack of services that runs in all the data centers globally. Think of the different services as building blocks. These services can be categorized into 3 classes. The first is infrastructure services which are low-level building blocks. They are an abstract set of computer resources in the data center running virtual machines. The second is the data storage service that provides storage and data management capabilities to help your application manage all of its data in a reliable and scalable way. The third component is the developer experience where the infrastructure, storage, and all of the APIs are packaged in the cloud and made available to the developers. Some integration with Visual Studio is delivered in the form of an SDK that can be downloaded for a free trial and run locally. This means you can develop and test your application locally before you deploy it to the cloud. Benefits of Microsoft Azure: Applications can be developed and deployed within minutes which means one can get their apps out there in the market as quickly as possible. The speed and agility that this gives also mean that one can reiterate quickly to improve on their apps. It is open and flexible, provides first and best-class experience and support for Microsoft workloads, and embraces other open technologies. In addition to Java and .NET, it supports PHP, Python, and other languages. Excellent support for open frameworks like Hadoop, and web frameworks like Word Press, Joomla, and Drupal. Also provide 1st party SDKs for developing apps using Android, iOS, or Windows phones. It follows a utility model where you pay for only what you need and only when you use it. With this model, you can stop worrying about where your peak (limit) is, you can stop paying for things upfront and you can save a lot of money. Microsoft Azure Infrastructure services allow you to scale up to multiple instances using virtual machines. Developers can use these virtual machines to develop and test any of the applications. Websites can be built using Azure which acts as a powerful self-service platform. It is highly secure with enterprise availability, support for SSL, and active directory authentication. With Windows Azure mobile services one can easily and quickly build cross-platform mobile apps that scale. Finally, Azure helps one to understand the application and analyze it so that one can build a better version and deploy that to the cloud without entering any downtime. It is more economically viable as you need to pay for only what you use. This means that you have great cost savings and can achieve great efficiencies. To start please refer to Microsoft Azure training courses. Have questions? Contact the cloud computing experts at InApp to learn more.

An Overview of Testing Frameworks

What is a Testing Framework? A testing automation framework is an overall system in which the tests will be designed, created, and implemented. It also includes the physical structures used for test creation and implementation and the logical interactions among those components. Need for Testing Framework If a group of testers is working on the same or different project and each tester is applying their own strategy to automate the application under test, then the possibility of duplication is higher. Also, the time taken to understand the whole strategy will be high. So we need an environment that should be independent of the application and has the capability to scale as per the application under test. For this purpose, we use a testing Framework. The Testing framework is responsible for: Designing a centralized and standardized logging facility, resulting in self-documenting test output Creating a mechanism to drive the application under test Creating a mechanism to execute the tests Creating a mechanism to Report results Advantages of testing frameworks: Improved code re-usage Reduced script maintenance Independent of an application under test Easy Reporting Modular-Based Testing Framework Data-Driven Testing Framework Keyword Driven Testing Framework Hybrid Testing Framework Types of Testing Framework Modular-Based Testing Framework Data-Driven Testing Framework Keyword Driven Testing Framework Hybrid Testing Modular-based Testing Framework The module is a small independent script that performs a specific set of tasks. It creates a layer in front of the component and hides the components from non-technical users as well as applications. The small components are added up to build a large test set. Advantages of Modular-based Testing Framework: The fastest way to generate a script Modular division of scripts leads to easier maintenance Data-Driven Testing Framework In a Data-driven framework, test input and output values are read from data pools, DB sources, CSV files, Excel files, DAO objects, ADO objects, etc. Navigation through the program, reading the data files, and logging test status information are all coded in the test script. Advantages of Data-Driven Testing Framework: Datasheets can be designed while application development is still in progress Reduces data redundancy Data input/output and expected results are stored as easily maintainable text records in the database Changes to the test scripts do not affect the test data Test Cases can be executed with multiple sets of data Keyword Driven or Table Driven Testing Framework The keyword-driven framework requires the development of data tables and keywords that are independent of the test automation tool used to execute them and the test script code that “drives” the application under test and the data. Keyword-driven tests look very similar to manual test cases. In a keyword-driven test, the functionality of the application-under-test is documented in a table as well as in step-by-step instructions for each test. There are 2 basic components in Keyword Driven Framework viz. Keyword, Application Map. Keyword or Action The keyword is an Action that can be performed on a GUI Component. Ex. for GUI Component Textbox, some keywords (action) would be InputText, VerifyValue, VerifyProperty, and so on. Application Map or Control An Application Map provides Named References for GUI Components. Application Maps are nothing but ‘Object Repository’. Hybrid Testing Framework The most commonly implemented framework is the best combination of all the techniques. It combines Keyword-driven, modular, and Data-Driven frameworks. The hybrid Testing Framework allows data-driven scripts to take advantage of the powerful libraries and utilities that usually accompany a keyword-driven architecture. The framework utilities can make the data-driven scripts more compact and less prone to failure. Tests are fully scripted in a Hybrid Testing Framework thus increasing the automation effort. Hybrid Testing Framework also implements extensive error and unexpected Windows handling. It is used for the automation of medium to large applications with long shelf life. Advantages of Hybrid Testing Framework: Fastest and less costly way to develop the automation scripts due to higher code re-usability Utilizing a modular design, and using files or records to both input and verify data, reduces redundancy and duplication of effort in creating automated test scripts Have questions? Contact the software testing experts at InApp to learn more.

Bash Scripting with Example

Bash is a popular command-line interpreter for Linux computers including Mac OS X. Bash can execute a vast majority of Bourne shell scripts, mainly benefitting the administration and programming tasks. Many of the features were copied from sh, csh, and ksh. Bash is also like a programming language so you can write programs using bash usually to automate tasks. You can start writing scripts right away, wrap up multiline operations in one file, implement flow control, and interact with users to get input. Here I would like to explain how bash scripting helps in mailing an attached file using SMTP. a) Mailing particular file in a directory #!/bin/bash emailsend=fromemail@gmail.com emailrec=toemail@gmail.com password=password name=toemail@gmail.com /usr/local/bin/sendEmail -v -f “$emailsend” -s smtp.gmail.com -xu “$name” -xp “$password” -t “$emailrec” -o tls=yes -u Message Bash script -m HIII MAIL FROM BASH EXECUTE -a /home/Jinesh/Desktop/sendMailBash.sh Explaining the script 1)sendEmail – Is an SMTP client that should be installed in Linux 2)emailsend – represents the sender’s email id 3)emailrec – represents the receiver’s email id 4)smtp.gmail.com – mail server Options -u : This option helps in providing a subject to mail -m : helps in providing the text body for email -a : helps in attaching a file in your local drive to email (multiple files can be attached) ########################## Required Packages ############################### # yum install perl perl-CPAN perl-Net-SSLeay perl-IO-Socket-SSL (centos) # “sudo apt-get install libio-socket-ssl-perl” and “libnet-ssleay-perl” (ubuntu) ###########################install sendEmail ############################ # wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz # tar -zxvf sendEmail-v1.56.tar.gz # sudo cp -a sendEmail-v1.XX/sendEmail /usr/local/bin # sudo chmod +x /usr/local/bin/sendEmail # sendEmail b) Mailing multiple files in a directory #!/bin/bash for i in /home/Jinesh/Desktop/*.txt; do files+=$i” ” done emailsend=fromemail@gmail.com emailrec=toemail@gmail.com password=password name=toemail@gmail.com /usr/local/bin/sendEmail -v -f “$emailsend” -s smtp.gmail.com -xu “$name” -xp “$password” -t “$emailrec” -o tls=yes -u Message Bash script -m HIII MAIL FROM BASH EXECUTE -a $files Executing from Java These bash scripts can be executed from java : – String[] cmd = new String[]{“/bin/sh”, “path/to/script.sh”}; Process pr = Runtime.getRuntime().exec(cmd); Schedule execution Bash script execution can be scheduled at a particular time command : – at 1748 < /home/Jinesh/Desktop/sample.sh (will execute sample.sh at 17:78). Here we used “at” command to schedule a bash script execution We can also schedule bash script execution using crontab This will periodically execute the script. crontab -u root -e This will open scheduled tasks in vi editor. We can modify or add task here. Example: 10 11,16 18 sep thu /home/Jinesh/Desktop/senMailBash.sh >> /home/Jinesh/Desktop/backup.log 2>&1 10 – 10th Minute (Top of the hour) 11,16 – 11 AM and 4 PM 18 – date sep – month thu – day of the week This will execute and mail an attachment on 18th September at 11:10, 16:10 and the output will be printed to a file say “backup.log” crontab -u root -l List all scheduled tasks using * * – Every Minute * – Every hour * – Every day * – Every month * – Every day of the week tail -500f /var/log/cron : – view logs Implementation 1) If one needs to get a server log every day/week/month/year to a mail address, where the server is placed in another location we can use this. 2) By implementing this, the user can send an email for a particular query result to any mail address (we can periodically schedule this). Have questions? Contact the technology experts at InApp to learn more.

How to Write a Quality Bug Report?

One of the important deliverables in software testing is Bug reports. Writing a good bug report is an important skill for a software tester. In order to document a well-written bug report, the tester requires a combination of testing and communication skill. The bug report is a medium of communication between the tester and the developer when the tester uncovers a defect. The bug report explains the gap between the expected result and the actual result. A bug report should have the following: The Title Steps To Reproduce Test Data Expected and Actual Results Attachments The Title A good title helps reduce duplicate issues and accurately summarize the issue. Include the specific name of the components involved in your bug in the title. A good summary will not be more than 50-60 characters. You can avoid generic problems in the title. For example: ABC is not working properly The issue with the page When we define a title we should specify what makes it “not working”. Bad – “Application crashed” Good – “Canceling from Change Password dialog caused application crash” Bad: Issues with GUI on the navigation bar. Good: The navigation bar is wrapping to a second line. Steps To Reproduce This is the body of the report. This section tells how to reproduce the bug. We should keep the section concise and easy to read. The number of steps should be short and to the point. It is better to write prerequisites to reduce the number of steps. It’s a good exercise to reproduce the bug by following the steps you’ve just outlined. This will help ensure you’ve included everything the developer will need to reproduce it as well. Test Data If the bug is specific to the particular scenario it is better to give the test data, so that developer can recreate the scenarios. Expected and Actual Results When describing expected results, explain what should happen, not what shouldn’t happen. Instead of writing “The app got crashed”, we can write “The user should take to XYZ screen”. When describing actual results, describe what did happen, not what didn’t happen. Instead of writing “The user wasn’t taken to the page”, we can write “The user remained on the ABC page”. Attachments Attachments add the bug value by offering proof. The attachment can be images, videos, or log files. Images Images are an essential part of the bug report. The bug reports should be effective enough to enable the developers to reproduce the problem. Screenshots should be a medium just for verification. If you attach screenshots to your bug reports, ensure that they are not too heavy in terms of size. Use a format like jpg or gif, but definitely not bmp. Attach the image files directly to the report. Don’t put images in a Word document or a zip file. Highlight the areas of bugs in the image. Video The video should be provided if the steps are complex. Actions in the video should match the steps listed in the bug report. Videos should be trimmed to only show the bug. Log Files Make it a point to attach logs from the logs. This will help the developers to analyze and debug the system easily. If the logs are not too large, say about 20-25 lines, you can paste them into the bug report. But if it is large enough, add it to your bug report as an attachment. Avoid proprietary file types (like .docx). Use .txt instead. Have questions? Contact the software testing experts at InApp to learn more.

TestLink – Test Management System

TestLink is a web-based test management system that offers support for test cases, test suites, test plans, test projects, and user management, as well as various reports and statistics. It is developed and maintained by Team Test which facilitates software quality assurance. How to work with TestLink Create a Project Create Test Cases (Test Suites) for this Project Create Test Plan Specify the Build of the Project you are going to test Add Test Cases to the Test Plan Assign Test Cases to Test Engineers Execute Test Cases (Test Engineers) See Reports and Charts Additional facilities Assigning Keywords (we may form a group of Test Cases for Regression tests) Specifying Requirements (we may bind them with Test Cases in the many-to-many relation and see if our Test Cases cover our requirements) Events log (you can see here the history of all the changes) STEP 1. CREATE A PROJECT To create a project, go to the Test Project Management section: STEP 2. CREATE A PROJECT – IMPORTANT FIELDS Name ID (used for forming a unique Test Cases ID) E.g. FT-03 means that the Test Case is created for the Fenestra project and it has ID=3 Project Description (what is the aim of the Project, what is the target group, what is the business logic, what is the Test Environment) Enhanced features: Requirements feature – we may specify requirements and see if they are well-covered by Test Cases Testing priority – we may assign priority to Test Cases (high, medium, low) Test Automation – we may specify whether the test should be performed manually or automatically you can now set this project here, like in Mantis, in the top right corner STEP 3. CREATE TEST CASES Or here: STEP 4. CREATE TEST CASES – CREATE A TEST SUITE Test Case Title Summary Preconditions Execution type (manual or automated) Test importance (High, Medium, or Low) We may also import and export Test Suites and Test Cases (in the .XML/XLS format): We import them from one project And export the file to other STEP 5. SPECIFY TEST PLAN TestLink will not allow you to execute Test Suites if you do not create a Test Plan and specify Test Build. How to do that? Let’s begin with the Plan The current Test Plan will appear in the top right corner STEP 6. SPECIFY BUILD After you’ve added a Test Plan menu, the adding Test Build appears. Add a new build there STEP 7. ADD TEST CASES TO THE PLAN Unfortunately, only Test Cases, not Test Suites or the whole Test Specification can be added to a Test plan. So, until you don’t select one separate TC, the button “Add to Test Plans” will not appear. Then you can choose what Test Plans you want to add the selected TC too. STEP 8. ASSIGN TEST CASE EXECUTION TO TESTERS Before assigning TC to testers you should create a DB of users with appropriate roles here. Add the users you need to fill in the form. Then you can assign TC execution here. You can assign test cases to testers and send them email notifications. STEP 9. EXECUTE TESTS To start executing tests, Test Engineer should go to the test Execution section. Then choose a TC. You may also connect TestLink with our bug-tracking system Mantis, then during execution, you will see as below. After clicking on “Create New Bug”, to create the bug using the mantis user interface and reorganizing the window Test engineer writes the issue ID on Testlink It looks like this after saving Execution history is being saved STEP 10. SEE REPORTS AND CHARTS After the test case execution is finished you may see the results of it using the Test Reports section Or here: You can see the following page Test Plan Report – the document has options to define the content and a document structure. You may choose the info you want to get. Test Plan report (part of it) The document ‘Test Report’ has options to define content and document structure. It includes Test cases together with test results. Test result matrix Charts Charts – results by tester (there are only unassigned test cases in the diagram) Charts – Results for top-level suites: 1. Log in to the application 2. News module Blocked, Failed, and Not Run Test Case Reports These reports show all of the currently blocked, failing, or not run test cases. E.g. General Test Plan Metrics This page shows you only the most current status of a Test plan by the test suite, owner, and keyword. Query metrics – work like filters in Mantis Requirements based report If we have some requirements specified and have connected them with TC we can see the following report: ADDITIONAL FACILITIES – ASSIGNING KEYWORDS Go to the “Assign Keywords” section Select some Test Suite and then you will be able to go to “Keywords Management” Add keywords if there are no KW at all, or if there are no KW you need Now you can add Keywords both to Test Suites & Test Cases, either all the Keywords (>>) or only one KW (>) Then you will be able to see such a useful chart demonstrating the Results by KW You can open the section in this way Or in this: Requirements Specification adding Then we create Requirements Pay attention that there are different types of the Requirements Then assign requirements to Test Cases Select Test Suite or Test Case and assign it to 1 or more requirements (R. can be assigned to TC in relation to many-to-many) 1. We have all the documentation structured and organized. 2. We solve the problem of version control. 3. We can control the testing process (Events log + different kinds of Reports) 4. We can see if all the requirements are covered with Test Cases. 5. We can select Test Cases for Regression Testing. 6. We can see the results of testing in a very clear and easy-to-use form. Have questions? Contact the software

Calling Cross Domain WCF Service using Jquery

There is no guarantee that the WCF services and client application will be hosted under same domain. When you try to call cross domain WCF service hosted in different domain using client script, it behaves differently on different browsers. When you want to perform “POST” or “GET” request on cross domain WCF service or normal service using jquery/javascript or ajax, the browser actually sends an “OPTIONS” verb call to your WCF service that is not mention in your WCF method attribute. We mention there “POST” or “GET” to call a WCF service method and hence get error to call cross domain WCF service.In this case the client request headers method type is “OPTION” not “POST” and the response headers has content-type “text/html; charset=UTF-8” instead of “json;charset=UTF-8”. To change these options we need to do some changes in web.config of hosted WCF service.

Good Cyber Security Practices

1. XSS – Cross-site scripting vulnerability (XSS) Parameter values sent by the client browser to the web application should be inspected enough by the server and an attacker can inject HTML or Javascript code instead of legitimate values. This vulnerability can be exploited by an attacker to carry out Cross-Site Scripting (XSS) in order to execute code in the victim’s browser. This vulnerability is often used to recover session cookies of a legitimate user in order to steal his session or to usurp his identity and his rights. Recommendations: Filter or encode every parameter sent to the application. For example: drop or escape special characters such as <, >, /, ‘, “ … //To Encode scripts public static string Encode(this string Instance) { return System.Web.HttpUtility.HtmlEncode(Instance); } public static string UriEncode(this string Instance) { return System.Uri.EscapeDataString(Instance); } //To Decode scripts public static string Decode(this string Instance) { return System.Web.HttpUtility.HtmlDecode(Instance); } public static string UriDecode(this string Instance) { return System .System.Uri.UnescapeDataString(Instance); } 2. Weakness in the management of rights Ensure that all features or business functions are protected by an effective access control mechanism. A matrix should map user roles with features to avoid any unauthorized access. Do not assume that users will be unaware of special or hidden URLs or APIs. Implement an authentication process in order to protect sensitive resources or features against anonymous access. Recommendations: – Protect passwords by encryption or hash mechanisms. -Ensure only POST calls to the server to avoid logging. -Implement Industry Standard token-based authentication from the server. -Check authorization based on the server token. -Ensure that all parameters are encrypted before use. -Cross-check calculations and selections from the client before saving transactions on the server. 3. Information Leak Parameters can be passed to the dynamic websites via URL (GET method). Explicit and sensitive information may be present in these settings, such as the Active Directory domain(EXAMPLE), the user name (EXAMPLE), the user password, or information on software architecture. This information can be retrieved by observing the clear stream on the network or by observing the proxy server logs possibly located between the client and the server. Recommendations: – Ensure only POST methods to the server -Only use encrypted passwords. -Ensure no credit card information is passed via GET. 4. Cookie contains sensitive data User credentials, such as logins and/or passwords, may be stored in the browser’s cookies. An attacker having access to these cookies may be able to steal the credentials and so spoof users’ identities on the service. Cookies can be retrieved for example on public workstations when a user forgets to log off, or through a cross-site scripting (XSS) attack. Recommendations: Changing to server-based cookies and tokens will eliminate the possibility of sensitive data in the cookies. In order to maintain a user’s session across his browsing, cookies should only contain a randomly generated session identifier, which cannot be predicted. This kind of feature is already implemented in most web development languages and frameworks. HttpCookie _Cookie = newHttpCookie(“CookieName”,”CookieValue”); _Cookie .Expires=DateTime.Now.Add(7); 5. HttpOnly Option -Set HTTPOnly option in cookie A cookie is a small piece of data sent from a website and stored in a user’s web browser while a user is browsing a website. When the user browses the same website in the future, the data stored in the cookie can be retrieved by the website to notify the website of the user’s previous activity. Cookies are typically used to store session identifiers in order to allow the user to browse the website without re-entering his credentials. If the httpOnly optional flag optional is included in the server’s HTTP response header, the cookie cannot be accessed through the client-side script. As a result, even if a cross-site scripting (XSS) flaw exists, and a user accidentally accesses a link that exploits this flaw, the browser will not reveal the cookie to a third party. As the server does not set the httpOnly flag to session cookies, users’ browsers create a traditional, script-accessible cookie. As a result, the session identifier stored in the cookie becomes vulnerable to theft or modification by malicious script. Recommendations: Set the httpOnly flag to session cookies in order to prevent any access from client-side scripts. As far as possible, renew session cookies for every request in order to prevent their exploitation by an attacker. HttpCookie _Cookie = newHttpCookie(“CookieName”,”CookieValue”); _Cookie .Expires=DateTime.Now.Add(7); _Cookie.HttpOnly = true; // Summary: Gets or sets a value that specifies whether a cookie is accessible by client-side script. // Returns:true if the cookie has the HttpOnly attribute and cannot be accessed through a client-side script; otherwise, false. The default is false. _Cookie.Secure = true; // Summary: Gets or sets a value indicating whether to transmit the cookie using Secure Sockets Layer (SSL)–that is, over HTTPS only. // Returns: true to transmit the cookie over an SSL connection (HTTPS); otherwise, false. The default value is false. Have questions? Contact the software testing experts at InApp to learn more.

Server Paging in SQL Server 2012

Apart from the previous versions of SQL Server where the paging of result set is obtained using temp tables, ROW_NUMBER() and TOP, SQL Server 2012 provide simple functions for paging result sets. This comes in the form of OFFSET and FETCH. The given example shows the tricky method used in previous version sql server. SELECT TOP 10 * FROM (SELECT ROW_NUMBER() OVER(ORDER BY trx_id) AS row_num, trx_id,trx_date,item_id,qty,cost FROM trx_history ) trx WHERE trx.row_num > 20 We can achieve the same result using OFFSET and FETCH, but in more efficient way just like the example given below. SELECT trx_id,trx_date,item_id,qty,cost FROM trx_history ORDER BY trx_id ASC OFFSET 20 ROWS FETCH NEXT 10 ROWS ONLY

How to Implement a Hierarchy using SQL Server?

Hierarchy can be implemented using common table expression (CTE). WITH UserHierarchy ([user_id], [manager_id],[Level]) AS ( SELECT [user_id],user_ap_mngd_by as manager,0 FROM [user_profile] usrtmp1 WHERE usrtmp1.[user_id]=1 UNION ALL SELECT usrtmp2.[user_id],user_ap_mngd_by as manager, [Level] + 1 FROM [user_profile] usrtmp2 INNER JOIN UserHierarchy ON usrtmp2.user_ap_mngd_by = UserHierarchy.[user_id] ) SELECT * FROM UserHierarchy

InApp India Office

121 Nila, Technopark Campus
Trivandrum, Kerala 695581
+91 (471) 277 -1800
mktg@inapp.com

InApp USA Office

999 Commercial St. Ste 210 Palo Alto, CA 94303
+1 (650) 283-7833
mktg@inapp.com

InApp Japan Office

6-12 Misuzugaoka, Aoba-ku
Yokohama,225-0016
+81-45-978-0788
mktg@inapp.com
Terms Of Use
© 2000-2026 InApp, All Rights Reserved