Very Good and useful links on TestNG based data-driven Automation. Please check on earlier posts labelled selenium to get started with Selenium and TestNG.
Stupid TestNG Tricks - Reading Input from File
Parallel Testing with TestNG DataProviders
DataProvider for Object as Parameter
Using TestNG to launch your tests (and the Selenium server)
TestNG GTAC Presentation
Setting up a test project with Selenium, TestNG and Maven
Difference between Junit and TestNG
Everytime when you know more about something you already know. It only means you ( I ) have to learn better....
Happy Reading!!
December 10, 2010
December 04, 2010
Web Service Testing
Yes, Learning basics once again. Basics of Web Services, How it Works. Testing has been fairly easy using Web Service Studio Tool.
Web Service - What is it
Performance
Typically there would be multiple consumers who can consume this service, scalability and performance is very important for web service
Web Services Testing
More Tools Read
Happy Learning!!!
- Web Services is all about XML
- Enables this communication by using open protocols and standards XML, SOAP and WSDL
- Structure of the messages is described using XML Schema (XSD)
- Platform-independent - The use of open protocols enables Web services to be platform independent
- Secure - Enable SSL, Certificates
Technology
- WSDL (Web Services Description Language) - WSDL is a document that describes a Web service and also tells you how to access and use its methods.
- UDDI - Universal Description, Discovery and Integration - Organizations register their Web services in a global directory so clients can find them
- SOAP - Simple Object Access Protocol. Messaging protocol. SOAP is a simple XML-based protocol to let applications exchange information over HTTP.
How it works
A very good walkthrough is provided in link. Client sends Serialized SOAP Request. This is Deserialized by the Server. The response is again Serialized and passed to the client in SOAP Response in serialized format. Deserialization happens at Client again.
Performance
Web Services Testing
Fairly Simple. Provide the wsdl URL in Web Service Studio Tool. Methods would be listed. Easy Walkthrough and tool download in link
Web service Studio 2.0 by Sowmy Srinivasan - Link
- Web Services Testing Tools
- Web Services Test Automation Guidance using VS 2010 - Unit Test & Web Test
- Soap UI - Open Source Testing Tool
- Three open source Web service testing tools get high marks
More Reads
- HTTP vs REST vs SOAP
- Learn REST: A Tutorial
- Testing Tool for webservice testing
- Test Web applications with HttpUnit
- Using HTTPUnit 'out of the box'
- HttpUnit: A civilized way to test Web applications in WebSphere Studio
- HttpUnit Test
- Interview Question: Compare two web services type SOAP and RESTful (SOAP Vs RESTful)
- SOAP vs Rest
- In Search of an Internet of Things Service Architecture: REST or WS-*? A Developers’ Perspective - Very Very Good
Happy Learning!!!
Labels:
Web Service Testing
November 27, 2010
How Website testing is different from Database testing
| How Website Testing is different from Database Testing | |
|---|---|
| Website testing | Database testing |
| Event Driven - Actions Depend on Options Choosen by the User | Data Driven, Fixed Set of Steps Executed by a Procedure |
| Website Testing is Black Box Testing, Focus is on end-to-end Functionality | Database Testing is more driven towards white box Testing, Need to verify TSQL Code, Logic, Datatypes, Constraints at Table Level, Refer Database Testing |
| Page Load time is very critical for better user experience | For OLTP Applications Ex-online ticket booking procedures need to be optimal to ensure maximum level of concurrency |
| Performance Points - User Response Time, Response Time with Concurrent Users | Performance Points - Blocking, Locking, Deadlocking during Performance Testing. Detailed notes are provided in blog for each of the listed items |
| Black Box Testing Predominantly | It is possible to trasition from a DB tester to DB Developer Since you work the code, You understand the code/logic |
| Checking SQL Jobs, Database Migrations Ex- SQL 2000 to SQL 2005, SQL 2005 to SQL 2008 | |
| OLTP Vs OLAP Systems. Both are very different and has its own learning. I have mainly worked on OLTP | |
Website would multi-tier app. Client-Business Layer-Database Layer. Database would also be covered at certain point.
Happy Reading!!
Best Practices for Website Testing
For Testing a website below are guidelines I found useful from my learning's till date
1. Functionality Testing - Verify the features/functionality of the site
2. Acceptance Testing - This is event driven, User can interact the site in several different ways. It is very important to cover maximum user scenarios to ensure no defects at integration layer
3. Localization Testing - Check the website if it is available in several languages. Useful tip - Google Chrome suggests translation to english when you open Non-English Locale Sites. You can use this to read/understand by translating the content to English.
4. Layout Testing - Verify the look and feel of the UI. No overlapping sections in the page. Refer the Tool
Layout detection tool, Layout Detection Tool Intro Video
5. Cross Browser Testing - Verify the UI of the website in multiple browsers. Useful Read Top 10 Free Web Apps to Test Cross-Browser Compatibility
6. Cross Platform Testing - Testing across browsers in different platforms Windows/Linux/Mac. Good Read Useful Tools for Testing Cross Browser Compatibility
7. Broken Links - Verifying Links in the page are not broken - Useful Tools. Tool1, Tool2
8. Spell Check the contents of the page. Good Read Top 10 Free Online Spell Checkers
9. Verify the page load time across different browsers. Good Read Top 10 Tools to Test Website Speed
10. Security Testing - Verify Security of the website is not broken or can be compromised with special attacks. Check for XSS. Tools to check both at code level/site level are available. 10+ Free Web Application Security Testing Tools
11. Slow Network Traffic - Check for the Page Load time, Look and Feel in Case of Slow Network Traffic. Useful Tool BrowserMob Proxy - Free Tool to simulate slow network traffic
12. Usability Testing - How much does it Actually meets End User Requirements. Is it user friendly. Usability Testing Guidelines
13. Web Test Automation - For Website Test Automation you can check Open Source Tools Selenium, Webdriver
14. More Reads - Guidelines and Checklist for Website Testing
15. Open Source Test Automation Framework Using Selenium. This underlying framework can be leveraged and developed to support automation for existing website - Tracking Selenium Commands Using C# and SQL Server 2008. Framework Code Available in Selenium Tracking
16. Very Good Ebook on Selenium for Web Test Automation. Link
17. 7 useful tools for web development testing
18. Selenium Online Training
19. Next thing to look is Automating Regression & Functional Test Cases. You can automate functional test cases based on priority. Based on production defects / changing features this can be updated
20. Capture production events of customer acitivty on the website. Top 10 worflows can serve as input to performance test scenarios. Based on distribution of it, performance test scenarios can be developed from it to simulate production work load.
21. Twenty essential firefox addons for testing
22. Traffic Squeezer - Open-Source WAN/Network Optimization and Acceleration Solution
23. Few tips for quality web page testing
24. Cross browser testing – The truth is in the numbers
1. Functionality Testing - Verify the features/functionality of the site
2. Acceptance Testing - This is event driven, User can interact the site in several different ways. It is very important to cover maximum user scenarios to ensure no defects at integration layer
3. Localization Testing - Check the website if it is available in several languages. Useful tip - Google Chrome suggests translation to english when you open Non-English Locale Sites. You can use this to read/understand by translating the content to English.
4. Layout Testing - Verify the look and feel of the UI. No overlapping sections in the page. Refer the Tool
Layout detection tool, Layout Detection Tool Intro Video
5. Cross Browser Testing - Verify the UI of the website in multiple browsers. Useful Read Top 10 Free Web Apps to Test Cross-Browser Compatibility
6. Cross Platform Testing - Testing across browsers in different platforms Windows/Linux/Mac. Good Read Useful Tools for Testing Cross Browser Compatibility
7. Broken Links - Verifying Links in the page are not broken - Useful Tools. Tool1, Tool2
8. Spell Check the contents of the page. Good Read Top 10 Free Online Spell Checkers
9. Verify the page load time across different browsers. Good Read Top 10 Tools to Test Website Speed
10. Security Testing - Verify Security of the website is not broken or can be compromised with special attacks. Check for XSS. Tools to check both at code level/site level are available. 10+ Free Web Application Security Testing Tools
11. Slow Network Traffic - Check for the Page Load time, Look and Feel in Case of Slow Network Traffic. Useful Tool BrowserMob Proxy - Free Tool to simulate slow network traffic
12. Usability Testing - How much does it Actually meets End User Requirements. Is it user friendly. Usability Testing Guidelines
13. Web Test Automation - For Website Test Automation you can check Open Source Tools Selenium, Webdriver
14. More Reads - Guidelines and Checklist for Website Testing
15. Open Source Test Automation Framework Using Selenium. This underlying framework can be leveraged and developed to support automation for existing website - Tracking Selenium Commands Using C# and SQL Server 2008. Framework Code Available in Selenium Tracking
16. Very Good Ebook on Selenium for Web Test Automation. Link
17. 7 useful tools for web development testing
18. Selenium Online Training
19. Next thing to look is Automating Regression & Functional Test Cases. You can automate functional test cases based on priority. Based on production defects / changing features this can be updated
20. Capture production events of customer acitivty on the website. Top 10 worflows can serve as input to performance test scenarios. Based on distribution of it, performance test scenarios can be developed from it to simulate production work load.
21. Twenty essential firefox addons for testing
22. Traffic Squeezer - Open-Source WAN/Network Optimization and Acceleration Solution
23. Few tips for quality web page testing
24. Cross browser testing – The truth is in the numbers
Happy Reading!!
November 17, 2010
Installing Turbo C++ in Win7 64 bit
I spent good amount of time looking for a Free IDE for trying out C/C++ programs. Below link
How to install Turbo C++ on Windows 7 64bit explains setup step by step
Few things I found useful to be added are
1. After mounting to D Drive, You need to run install.exe under dosbox to get all files unzipped
2. I downloaded DOSBox 0.74 version. The config file is located in
{system drive}:\Users\{username}\AppData\Local\DOSBox\dosbox-{version}.conf
3. Added the below content
mount d c:\turboc
d:
cd tc
cd bin
tc
Now on click of DOSBox shortcut C++ IDE is ready!!
Time to learn/code some more Programming Problems.....
Found yet another simple solution. Use http://codepad.org/ :) :)
Happy Coding!!
How to install Turbo C++ on Windows 7 64bit explains setup step by step
Few things I found useful to be added are
1. After mounting to D Drive, You need to run install.exe under dosbox to get all files unzipped
2. I downloaded DOSBox 0.74 version. The config file is located in
{system drive}:\Users\{username}\AppData\Local\DOSBox\dosbox-{version}.conf
3. Added the below content
mount d c:\turboc
d:
cd tc
cd bin
tc
Now on click of DOSBox shortcut C++ IDE is ready!!
Time to learn/code some more Programming Problems.....
Found yet another simple solution. Use http://codepad.org/ :) :)
Happy Coding!!
Labels:
C
November 16, 2010
Software Testing - Learning Articles - Posts - Compiled
Below is summary of Software testing related posts in my blog till date plus interesting testing related article bookmarks
- Guidelines for Web Site Testing
- Database Testing Overview
- Performance Testing Overview
- Web Service Testing
- Test Estimates
- Testing best Practices
- Value Realization of Test Function
- Web Services Testing, Testing Tool for webservice testing
- UI Test Automation using Selenium
- Test Automation - Regression Test Automation Myths, Software Testing Interesting Reads - Sara Ford
- Test Case Management Tools Analysis
- Test Automation patterns
- Test Automation Tools - Good Summary
- Functional Testing Tools List
- Test Heuristics Cheat Sheet
- Tester 2.0 - Definition of an Agile Tester
- Manual Testing Notes
- Testing Mobile Apps
- Google Testing Blog good read - Approach on Categorizing test sizes - Good Read
- Google Testing Blog good read - Web Testing at Google
- Using Mind Maps for Test Planning
- An effective test strategy to grow applications - Good Read
- Testing Mobile Apps
- Test Case “Rules” - Good Compiled List on Rules for Writing / Auditing Test Cases
- Mobile Application Testing - Part I
- Mobile Application Testing - Part II
- Mobile Application Testing - Part III
- [Good Session] - Mobile WebDriver Testing at TheLadders
- Test Mobile applications with COP (who) FLUNG GUN
- The Pragmatic Tester - Mindmap
- Testing In The Automation Age - Mindmap
- The Art of Writing Effective and Transparent Test Cases
- Misconceptions about testing (and what we should do about them)
Happy Reading!!
Labels:
Software Testing Notes
November 15, 2010
Notes for SQL Server Developer
Below post is summary of SQL Server related posts.
Happy Reading!!
- Basics – Isolation Levels
- Triggers, Procedures, Views - SQL Server Views Revisited
- Table Partitioning - Basics, Partition Elimination in SQL Server 2005
- Understand Query Execution process
- Locking, Blocking, Deadlocking - Blocking Vs Deadlocking, Deadlock Troubleshooting
- SSIS, SSRS, CDC
- JOINS - Operators - Revisited, SQL Server Indexes and Join Analysis
- DB Replication - SQL Server 2005 Replication Learning’s, SQL High Availability Links
- SQL Upgrade 2005-2008 - SQL Server 2008 Migration Guidelines
- Query Performance Tuning
- Coding Best Practices - SQL Server Coding Guidelines, TSQL XML Parsing
- Read Subject Matter Expert Blogs (Loads of them bookmarked in SQL Links in the blog)
- Road to become Database Architect
- SQL Server 2008 Notes
- SQL Blog – SQL SME’s Blog
- SQL Tips
- Started a BI blog to practice SSIS, SSRS
Happy Reading!!
November 12, 2010
SQL Server 2008 Basics - Isolation Levels
Couple of years back I was not exactly sure of difference between Isolation levels in SQL Server. I learnt it from Roji & Balmukund. Posting my notes and examples I had to understand it better.
“Pessimistic locking” (where data collisions are assumed and locks taken to prevent conflicting updates) and the four standard isolation levels:
1. Read Uncommitted (also known as “Dirty Read”)
2. Read Committed (the default SQL Server transaction isolation level)
3. Repeatable Read
4. Serializable
STEP 1
USE TestDB
CREATE TABLE Employees(EID int primary key identity,EmpName nvarchar(50),Salary money);
GO
INSERT INTO Employees(EmpName, Salary) VALUES ('Raja', 5500);
INSERT INTO Employees(EmpName, Salary) VALUES ('Raman', 44500);
INSERT INTO Employees(EmpName, Salary) VALUES ('Kanna', 12000);
STEP 2
--Isolation Level - READ UNCOMMITTED
--Dirty reads - Uncommitted/Transaction inprogress would be considered part of transaction
--SESSION 1
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
BEGIN TRAN
SELECT * FROM Employees
WAITFOR DELAY '00:00:10'
SELECT * FROM Employees
ROLLBACK
STEP 3
--SESSION 2
USE TestDB
GO
SET TRANSACTION ISOLATION LEVEL READ COMMITTED
GO
BEGIN TRAN
UPDATE Employees SET Salary = Salary * 1.2
WAITFOR DELAY '00:00:10'
ROLLBACK
STEP 4
--Execute SESSION 2 and then SESSION 1. Below is the output of SESSION 1
Isolation Level - Lost Updates
Nonrepeatable Read: If somebody performed UPDATE or DELETE of any of the rows you read earlier.
Read Committed - When SQL Server executes a statement at the read committed isolation level, it acquires short lived share locks on a row by row basis.
STEP 1
--SESSION 1
SET TRANSACTION ISOLATION LEVEL READ COMMITTED
BEGIN TRAN
SELECT * FROM Employees
WAITFOR DELAY '00:00:10'
SELECT * FROM Employees
ROLLBACK
STEP 2
--SESSION 2
BEGIN TRAN
UPDATE Employees
SET Salary = Salary * 1.2
COMMIT
STEP 3
Execute SESSION 1 and then SESSION 2. Output of SESSION 1
Phantom Reads
Repeatable read - a repeatable read scan retains locks on every row it touches until the end of the transaction.
Phantom: If anybody INSERTed a row within the range you had for an earlier query (i.e., you see new rows).
STEP 1
--SESSION 1
SET TRANSACTION ISOLATION LEVEL REPEATABLE READ
BEGIN TRAN
SELECT * FROM Employees
WAITFOR DELAY '00:00:10'
SELECT * FROM Employees
ROLLBACK
STEP 2
--SESSION 2
BEGIN TRAN
INSERT INTO Employees(EmpName, Salary)
VALUES ('New Employee', 500);
COMMIT
STEP 3
Execute SESSION 1 and then SESSION 2. Output of SESSION 1
SERIALIZABLE Isolation Level
--Locks all data in the Range, They remain locked until transaction is Complete
SERIALIZABLE - instead of the simple shared lock that was there with the REPEATABLE READ level, you now have RANGE shared locks (looks like 'RangeS-S, which means a range shared lock for a range scan). You will only see these type of locks when you are using a serialized transaction...these differ from the REPEATABLE READ level locks in that not only do they protect the exact key values returned from the statement, but they also protect the entire range of values the query scans and won't allow the phantom inserts within the queried range like the REPEATABLE READ level did.
STEP 1
--SESSION 1
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
BEGIN TRAN
SELECT * FROM Employees
WAITFOR DELAY '00:00:10'
SELECT * FROM Employees
ROLLBACK
STEP 2
--SESSION 2
BEGIN TRAN
UPDATE Employees
SET Salary = Salary * 1.2
INSERT INTO Employees(EmpName, Salary)
VALUES ('New Employee Again', 800);
COMMIT
STEP 3
Execute SESSION 1 and then SESSION 2. Output of SESSION 1
STEP 1
ALTER DATABASE TestDB SET ALLOW_SNAPSHOT_ISOLATION ON;
GO
STEP 2
--SESSION 1
SET TRANSACTION ISOLATION LEVEL SNAPSHOT
BEGIN TRAN
SELECT * FROM Employees
WAITFOR DELAY '00:00:10'
SELECT * FROM Employees
COMMIT TRAN
--Results #1 and #2 will be same, Before starting transaction the latest available data copy would be used as Reference
STEP 3
--SESSION 2
BEGIN TRAN
UPDATE Employees
SET Salary = Salary * 1.2
INSERT INTO Employees(EmpName, Salary)
VALUES ('New Employee Again', 800);
COMMIT
STEP 4
--Execute SESSION 1 and then SESSION 2. Output of SESSION 1
Read Committed Snapshot Isolation
STEP 1
ALTER DATABASE TestDB SET READ_COMMITTED_SNAPSHOT ON
GO
STEP 2
--SESSION 1
SET TRANSACTION ISOLATION LEVEL READ COMMITTED
GO
BEGIN TRAN
SELECT * FROM Employees
WAITFOR DELAY '00:00:10'
SELECT * FROM Employees
COMMIT TRAN
STEP 3
--SESSION 2
BEGIN TRAN
UPDATE Employees
SET Salary = Salary * 1.2
INSERT INTO Employees(EmpName, Salary)
VALUES ('New Employee Again', 800);
COMMIT
STEP 4
Execute SESSION 1 and SESSION 2. Output of SESSION 1
STEP 5
Query to check for Database Status
SELECT snapshot_isolation_state,name
FROM sys.databases
SELECT is_read_committed_snapshot_on ,name
FROM sys.databases
More Reads
Concurrency Series: Basics of Transaction Isolation Levels
Visualising Isolation Levels
Happy Reading!!
“Pessimistic locking” (where data collisions are assumed and locks taken to prevent conflicting updates) and the four standard isolation levels:
1. Read Uncommitted (also known as “Dirty Read”)
2. Read Committed (the default SQL Server transaction isolation level)
3. Repeatable Read
4. Serializable
STEP 1
USE TestDB
CREATE TABLE Employees(EID int primary key identity,EmpName nvarchar(50),Salary money);
GO
INSERT INTO Employees(EmpName, Salary) VALUES ('Raja', 5500);
INSERT INTO Employees(EmpName, Salary) VALUES ('Raman', 44500);
INSERT INTO Employees(EmpName, Salary) VALUES ('Kanna', 12000);
STEP 2
--Isolation Level - READ UNCOMMITTED
--Dirty reads - Uncommitted/Transaction inprogress would be considered part of transaction
--SESSION 1
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
BEGIN TRAN
SELECT * FROM Employees
WAITFOR DELAY '00:00:10'
SELECT * FROM Employees
ROLLBACK
STEP 3
--SESSION 2
USE TestDB
GO
SET TRANSACTION ISOLATION LEVEL READ COMMITTED
GO
BEGIN TRAN
UPDATE Employees SET Salary = Salary * 1.2
WAITFOR DELAY '00:00:10'
ROLLBACK
STEP 4
--Execute SESSION 2 and then SESSION 1. Below is the output of SESSION 1
Nonrepeatable Read: If somebody performed UPDATE or DELETE of any of the rows you read earlier.
Read Committed - When SQL Server executes a statement at the read committed isolation level, it acquires short lived share locks on a row by row basis.
STEP 1
--SESSION 1
SET TRANSACTION ISOLATION LEVEL READ COMMITTED
BEGIN TRAN
SELECT * FROM Employees
WAITFOR DELAY '00:00:10'
SELECT * FROM Employees
ROLLBACK
STEP 2
--SESSION 2
BEGIN TRAN
UPDATE Employees
SET Salary = Salary * 1.2
COMMIT
STEP 3
Execute SESSION 1 and then SESSION 2. Output of SESSION 1
Phantom Reads
Repeatable read - a repeatable read scan retains locks on every row it touches until the end of the transaction.
Phantom: If anybody INSERTed a row within the range you had for an earlier query (i.e., you see new rows).
STEP 1
--SESSION 1
SET TRANSACTION ISOLATION LEVEL REPEATABLE READ
BEGIN TRAN
SELECT * FROM Employees
WAITFOR DELAY '00:00:10'
SELECT * FROM Employees
ROLLBACK
STEP 2
--SESSION 2
BEGIN TRAN
INSERT INTO Employees(EmpName, Salary)
VALUES ('New Employee', 500);
COMMIT
STEP 3
Execute SESSION 1 and then SESSION 2. Output of SESSION 1
SERIALIZABLE Isolation Level
--Locks all data in the Range, They remain locked until transaction is Complete
SERIALIZABLE - instead of the simple shared lock that was there with the REPEATABLE READ level, you now have RANGE shared locks (looks like 'RangeS-S, which means a range shared lock for a range scan). You will only see these type of locks when you are using a serialized transaction...these differ from the REPEATABLE READ level locks in that not only do they protect the exact key values returned from the statement, but they also protect the entire range of values the query scans and won't allow the phantom inserts within the queried range like the REPEATABLE READ level did.
STEP 1
--SESSION 1
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
BEGIN TRAN
SELECT * FROM Employees
WAITFOR DELAY '00:00:10'
SELECT * FROM Employees
ROLLBACK
STEP 2
--SESSION 2
BEGIN TRAN
UPDATE Employees
SET Salary = Salary * 1.2
INSERT INTO Employees(EmpName, Salary)
VALUES ('New Employee Again', 800);
COMMIT
STEP 3
Execute SESSION 1 and then SESSION 2. Output of SESSION 1
Snapshot Isolation and Read Committed with Snapshot Isolation (RCSI).
These impacts are:
- Increased I/O to manage row versions
- Increased tempdb usage
- Changes to default behavior affecting applications that rely on pessimistic locking to implement ordered queues.
ALTER DATABASE TestDB SET ALLOW_SNAPSHOT_ISOLATION ON;
GO
STEP 2
--SESSION 1
SET TRANSACTION ISOLATION LEVEL SNAPSHOT
BEGIN TRAN
SELECT * FROM Employees
WAITFOR DELAY '00:00:10'
SELECT * FROM Employees
COMMIT TRAN
--Results #1 and #2 will be same, Before starting transaction the latest available data copy would be used as Reference
STEP 3
--SESSION 2
BEGIN TRAN
UPDATE Employees
SET Salary = Salary * 1.2
INSERT INTO Employees(EmpName, Salary)
VALUES ('New Employee Again', 800);
COMMIT
STEP 4
--Execute SESSION 1 and then SESSION 2. Output of SESSION 1
Read Committed Snapshot Isolation
- Statement Level Row Versioning Results for #1 and #2 will differ
- Before executing each statement it takes a copy
ALTER DATABASE TestDB SET READ_COMMITTED_SNAPSHOT ON
GO
STEP 2
--SESSION 1
SET TRANSACTION ISOLATION LEVEL READ COMMITTED
GO
BEGIN TRAN
SELECT * FROM Employees
WAITFOR DELAY '00:00:10'
SELECT * FROM Employees
COMMIT TRAN
STEP 3
--SESSION 2
BEGIN TRAN
UPDATE Employees
SET Salary = Salary * 1.2
INSERT INTO Employees(EmpName, Salary)
VALUES ('New Employee Again', 800);
COMMIT
STEP 4
Execute SESSION 1 and SESSION 2. Output of SESSION 1
STEP 5
Query to check for Database Status
SELECT snapshot_isolation_state,name
FROM sys.databases
SELECT is_read_committed_snapshot_on ,name
FROM sys.databases
More Reads
Concurrency Series: Basics of Transaction Isolation Levels
Visualising Isolation Levels
Happy Reading!!
Labels:
Isolation Level
TSQL Interesting Questions
Listed below are few TSQL Interesting code snippets and output also provided below the examples. Output I observed in SQL 2008 R2 version.
Example #1
declare @i int
select @i = -5
select +@i
Output: -5
Example #2
declare @i varchar
select @i = 'This is a test'
select @i
Output: T
Example #3
declare @val char(30)
set @val = 'SSc is cool'
select len(@val)
Output: 11
Example #4
declare @val as float, @val1 as float
set @val = 2.0
set @val1 = 1.4
select @val1+@val as sum
Output: 3.4
Example #5. Minimum of each coulmn
create table #i ( i int, j int, k int)
insert #i values(1, 2, 3)
insert #i values(1, 3, 2)
insert #i values(2, 1, 3)
insert #i values(2, 3, 1)
insert #i values(3, 1, 2)
insert #i values(3, 2, 1)
insert #i values(1, 2, 1)
insert #i values(1, 1, 1)
insert #i values(1, 0, 1)
select (case when (i <= j and i <= k) then i when j <= k then j else k end)
from #i
Example #6. Greatest value of 3 columns. Here's an example of what you want using a derived table
declare @t table(id int, val1 int,val2 int,val3 int)
insert into @t(id,val1,val2,val3) values(1,100,200,300)
insert into @t(id,val1,val2,val3) values(2,300,400,500)
insert into @t(id,val1,val2,val3) values(3,600,700,800)
select id,max(vals)
from
(
select id,val1
from @t
union all
select id,val2
from @t
union all
select id,val3
from @t
) X(id,vals)
group by id
Example #7. Maxof All 3 columns
select max(vals)
from
(
select A
from #min
union all
select B
from #min
union all
select C
from #min
) X(vals)
Thanks to authors of this problems. I am not sure where I read this 'C' Programming Style Problems. I found it interesting.
Example #1
declare @i int
select @i = -5
select +@i
Output: -5
Example #2
declare @i varchar
select @i = 'This is a test'
select @i
Output: T
Example #3
declare @val char(30)
set @val = 'SSc is cool'
select len(@val)
Output: 11
Example #4
declare @val as float, @val1 as float
set @val = 2.0
set @val1 = 1.4
select @val1+@val as sum
Output: 3.4
Example #5. Minimum of each coulmn
create table #i ( i int, j int, k int)
insert #i values(1, 2, 3)
insert #i values(1, 3, 2)
insert #i values(2, 1, 3)
insert #i values(2, 3, 1)
insert #i values(3, 1, 2)
insert #i values(3, 2, 1)
insert #i values(1, 2, 1)
insert #i values(1, 1, 1)
insert #i values(1, 0, 1)
select (case when (i <= j and i <= k) then i when j <= k then j else k end)
from #i
Example #6. Greatest value of 3 columns. Here's an example of what you want using a derived table
declare @t table(id int, val1 int,val2 int,val3 int)
insert into @t(id,val1,val2,val3) values(1,100,200,300)
insert into @t(id,val1,val2,val3) values(2,300,400,500)
insert into @t(id,val1,val2,val3) values(3,600,700,800)
select id,max(vals)
from
(
select id,val1
from @t
union all
select id,val2
from @t
union all
select id,val3
from @t
) X(id,vals)
group by id
Example #7. Maxof All 3 columns
select max(vals)
from
(
select A
from #min
union all
select B
from #min
union all
select C
from #min
) X(vals)
Thanks to authors of this problems. I am not sure where I read this 'C' Programming Style Problems. I found it interesting.
Labels:
TSQL
November 05, 2010
SQL Server Views Revisited
It's been a long time I refreshed on my SQL Skills. Below post is on views.
Why view ?
Indexed Views - SQL Server allows creation of index on view. Steps required for creating indexed views provided in link, link1. Best for OLAP systems where data is updated infrequently.
Happy Learning!!!
Why view ?
- Join Several Tables and Fetch Information
- Hide the Query from End-users,Ex-Expose only aggregated results, Read-Only Information presented to users
- Expose only required/relevant information to users
- View with schemabinging - When SCHEMABINDING is specified, the base table or tables cannot be modified in a way that would affect the view definition
- View can update underlying tables if it satisfies below conditions
- View is created based on only one table
- No Aggregate function in view definition (Reference)
- List all view in DB
- select * from sysobjects where xtype = 'v'
- Every time a query references a view, SQL Server substitutes the definition of the view into the query internally until a modified query is formed that only references base tables. Thus, Indexes on underlying tables are critical for performance of views
- When a view is executed for the first time, only its query tree is stored in the procedure cache
- Each time a view is accessed, its execution plan is recompiled.
Indexed Views - SQL Server allows creation of index on view. Steps required for creating indexed views provided in link, link1. Best for OLAP systems where data is updated infrequently.
Views Examples - Creating Indexed Views, Create View, Good Distributed Partitioned Views / Federated Databases Article, An Inside View
Happy Learning!!!
Labels:
View
Subscribe to:
Posts (Atom)







