x

SQL basics, queries and installation of SQL server

Prev     Next

In this chapter, we are going to learn how to setup SQL development environment using Microsoft SQL server 2012 express in your local machine and how to create database, tables and SQL queries by your own.


Note:

  • In this SQL tutorial, we take SQL server 2012 express for example and show you how to install the same and how to perform different operations using SQL queries in a database. Users can take any SQL server version and any servers such as Oracle, DB2, SQL server 2016, MYSQL, Microsoft Access, etc.
  • The main reason for taking SQL server 2012 express as reference is, it is a free open source and mostly enough for your learing purpose.

Steps to install SQL server 2012 express:

1. Go to https://www.microsoft.com/en-us/download/details.aspx?id=29062

2. Select your language and Download the “ENU\x64\SQLEXPRADV_x64_ENU.exe” file which is advanced SQL server 2012 express. If you want to download any other versions, you can choose accordingly and download the files.

3. Once download is completed, double click on exe file. Shortcut may be available in your desktop.

4. Click on “All Package”, and then choose the C compiler as shown below. Please choose all the GNU C Compiler listed in below window. Then, Click on Installation ->Apply Changes.

  • The below step is for C++ Compiler installation. If you want to install C++ compiler, you can follow this step. Else, you can move to step5.

5. Once installation is completed, go to your desktop and right click on My Computer -> properties -> advanced system settings -> advanced tab. Then, click on “Environment Variables” button and then “New”. You will get a popup window as shown below.

Change the System variable as given below.

Variable name: PATH
Variable value: C:\MinGW\bin;

6. Restart you machine.

7. Open command prompt (Type “cmd” in search box).

8. Type “gcc –version” in command prompt to check whether C compiler is installed in your machine. Type “g++ –version” in command prompt to check whether C++ compiler is installed in your machine. But, we are good if C compiler is installed successfully in our machine as of now.


9. Open notepad or text document and type any simple program and save this file as test.c (You can put any name for file. But, make sure that it is saved with .c extension).

Some basic commands you need to know before compiling and executing C program using command prompt:

  • To go to particular directory, use this command – cd {full_path} (for example : cd c:\MinGW\bin)
  • To list all the files in a directory, use this command – dir { full_path_of_directory} (for example : dir c:\MinGW\bin)
  • To rename a file, use this command – ren {old_file_name} {new_file_name} (for example : ren test.c.txt test.c)
  • To compile a C program, use “gcc file_name.c” (for example : gcc test.c)
  • To execute C program, use “a.exe” in command prompt
  • To clear the sceen, use “cls” command

10. Go to the respective direcory in command prompt where you have saved your C program file and compile your C program using “gcc file_name.c” command.

Note:

  • Sometimes, when you type C program in notepad or text editor and save the file as “file_name.c”, it would be saved as “file_name.c.txt”.
  • This file can’t be compiled by compiler.
  • When you see this file in windows folder, which will look good as file_name.c.
  • But, when you list all available files in the directory where you have placed your program file using “dir { full_path_of_directory}” command in command prompt, you can able to see file name will be as “file_name.c.txt”
  • So, you have to rename this file in command prompt using “ren {old_file_name} {new_file_name}” command, and then compile the program.

11. Run your C program using “a.exe” command in command prompt. You can see the output as below.

Prev     Next



Like it? Please Spread the word!