Querying the tables using JOIN Keyword

The INNER JOIN keyword selects all rows from both tables as long as there is a match between the columns in both tables The LEFT JOIN keyword returns all rows from the left table (table1), with the matching rows in the right table (table2). The result is NULL in the right side when there is no match. The RIGHT JOIN keyword returns all rows from the right table (table2), with the matching rows in the left table (table1). The…

Read More

Posted in Reference, SQL Tagged Comments Off on Querying the tables using JOIN Keyword
SELECT columns using the LIKE keyword

Using the WHERE clause to return on the records in the Employee table where the employees are a manager of some type. This example uses the % character for any number of characters. Using the LIKE keyword to return records from the Person table where users’ first names end in “ary”. This example uses the _ characters to represent a single character. Using the LIKE keyword to return records from the Person table where users’ first names end in…

Read More

Selecting Domain from Email Address

Recently I came across a quick need where I needed to retrieve domain of the email address. The email address is in the database table. I quickly wrote following script which will extract the domain and will also count how many email addresses are there with the same domain address.

Read More

Microsoft SQL Insert Trigger to Get Current Datetime Value

This script gets the datetime value in this format MM/DD/YYYY:HR:MI:SSPM or AM. I could have used the CAST or CONVERT option but the did not reproduce the result that I wanted.  There are some option in CONVERT option but they converts into a 24hr format. Here is my trigger for insert event. USE dwdata GO /* —————————————————————————– www.myw0.com, Version 1.0, Creation Date: 11/05/2014 Functionality: Generate Datetime values into a text field —————————————————————————– */ if exists (select * from sysobjects…

Read More

Oracle – Create Table – Using Select Statement With Data or No Data

Here is a sample script: WITH data   CREATE TABLE test3 AS SELECT table_name, tablespace_name FROM all_tables;   ———————————   Without data   CREATE TABLE ctas AS SELECT table_name, tablespace_name FROM all_tables WHERE 1=2;     — For example, create a table named EMPLOYEE3 that includes all — of the column definitions from EMPLOYEE where the DEPTNO = D11.   CREATE TABLE EMPLOYEE3 AS (SELECT PROJNO, PROJNAME, DEPTNO FROM EMPLOYEE WHERE DEPTNO = ‘D11’) WITH NO DATA —

Read More

Posted in Oracle Tagged , Comments Off on Oracle – Create Table – Using Select Statement With Data or No Data
Prevent Skype using port 80 and causing IIS to throw a HRESULT: 0x80070020 Exception

If you run NETSTAT -ano in the command prompt you should be able to see the process ids and its port been used. If you trace it back port 80 will be used by Skype Desktop. Option one: Closed completely Skype or  unchecking Tools > Options… > Advanced > Connection > “Use port 80 and 443 as alternatives for incoming connections Option 2: Go into IIS website bindings and change the IIS port to something different. I my case this…

Read More

Who is Active for MSSQL

Who is Active is free SQL tool that you can download and use for personal, educational, and internal corporate purposes. If you work with MSSQL server and notice slowness this is a great tool for monitoring SQL transactions and performance in SQL server.  I personally use this tool for monitoring SQL deadlocks in the database. You can find more information in this page: http://sqlblog.com/blogs/adam_machanic/archive/2012/03/22/released-who-is-active-v11-11.aspx You can download the SQL script from here: http://sqlblog.com/files/folders/beta/entry42453.aspx The installation process is very simple:…

Read More

SQL FORMAT() Function

The FORMAT() Function The FORMAT() function is used to format how a field is to be displayed. SQL FORMAT() Syntax SELECT FORMAT(column_name,format) FROM table_name;   Parameter Description column_name Required. The field to be formatted. format Required. Specifies the format. Example SELECT ProductName, Price, FORMAT(Now(),’YYYY-MM-DD’) AS PerDate FROM Products;  

Read More

Posted in SQL Tagged Comments Off on SQL FORMAT() Function