Category: t Sql

  • Khóa học miễn phí T-SQL – Joining Tables nhận dự án làm có lương

    T-SQL – Joining Tables



    The MS SQL Server Joins clause is used to combine records from two or more tables in a database. A JOIN is a means for combining fields from two tables by using values common to each.

    Consider the following two tables, (a) CUSTOMERS table is as follows −

    ID  NAME       AGE       ADDRESS             SALARY
    1   Ramesh     32        Ahmedabad           2000.00
    2   Khilan     25        Delhi               1500.00
    3   kaushik    23        Kota                2000.00
    4   Chaitali   25        Mumbai              6500.00
    5   Hardik     27        Bhopal              8500.00
    6   Komal      22        MP                  4500.00
    7   Muffy      24        Indore              10000.00
    

    (b) Another table is ORDERS as follows −

    OID  DATE                       CUSTOMER_ID        AMOUNT
    100  2009-10-08 00:00:00.000    3                  1500.00
    101  2009-11-20 00:00:00.000    2                  1560.00
    102  2009-10-08 00:00:00.000    3                  3000.00
    103  2008-05-20 00:00:00.000    4                  2060.00
    

    Let us join these two tables in our SELECT statement as follows −

    SELECT ID, NAME, AGE, AMOUNT
       FROM CUSTOMERS, ORDERS
       WHERE  CUSTOMERS.ID = ORDERS.CUSTOMER_ID
    OR
    SELECT A.ID, A.NAME, A.AGE, B.AMOUNT
       FROM CUSTOMERS A inner join  ORDERS B on A.ID = B.Customer_ID
    

    The above command will produce the following output.

    ID   NAME      AGE    AMOUNT
    2    Khilan    25     1560.00
    3    kaushik   23     1500.00
    3    kaushik   23     3000.00
    4    Chaitali  25     2060.00
    

    It is noticeable that the join is performed in the WHERE clause. Several operators can be used to join tables, such as =, <, >, <>, <=, >=, !=, BETWEEN, LIKE, and NOT; they can all be used to join tables. However, the most common operator is the equal symbol.

    MS SQL Server Join Types −

    There are different types of joins available in MS SQL Server −

    • INNER JOIN − Returns rows when there is a match in both tables.

    • LEFT JOIN − Returns all rows from the left table, even if there are no matches in the right table.

    • RIGHT JOIN − Returns all rows from the right table, even if there are no matches in the left table.

    • FULL JOIN − Returns rows when there is a match in one of the tables.

    • SELF JOIN − This is used to join a table to itself as if the table were two tables, temporarily renaming at least one table in the MS SQL Server statement.

    • CARTESIAN JOIN − Returns the Cartesian product of the sets of records from the two or more joined tables.


    Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc

  • Khóa học miễn phí T-SQL – Functions nhận dự án làm có lương

    T-SQL – Functions



    MS SQL Server has many built-in functions to perform processing on string or numeric data. Following is the list of all useful SQL built-in functions −

    • − The SQL Server COUNT aggregate function is used to count the number of rows in a database table.

    • − The SQL Server MAX aggregate function allows to select the highest (maximum) value for a certain column.

    • − The SQL Server MIN aggregate function allows to select the lowest (minimum) value for a certain column.

    • − The SQL Server AVG aggregate function selects the average value for certain table column.

    • − The SQL Server SUM aggregate function allows selecting the total for a numeric column.

    • − This is used to generate a square root of a given number.

    • − This is used to generate a random number using SQL command.

    • − This is used to concatenate multiple parameters to a single parameter.

    • − Complete list of SQL functions required to manipulate numbers in SQL.

    • − Complete list of SQL functions required to manipulate strings in SQL.


    Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc

  • Khóa học miễn phí T-SQL – Transactions nhận dự án làm có lương

    T-SQL – Transactions



    A transaction is a unit of work that is performed against a database. Transactions are units or sequences of work accomplished in a logical order, whether in a manual fashion by a user or automatically by some sort of a database program.

    A transaction is the propagation of one or more changes to the database. For example, if you are creating a record or updating a record or deleting a record from the table, then you are performing a transaction on the table. It is important to control transactions to ensure data integrity and to handle database errors.

    Practically, you will club many SQL queries into a group and you will execute all of them together as a part of a transaction.

    Properties of Transactions

    Transactions have the following four standard properties, usually referred to by the acronym ACID −

    • Atomicity − Ensures that all operations within the work unit are completed successfully; otherwise, the transaction is aborted at the point of failure, and previous operations are rolled back to their former state.

    • Consistency − Ensures that the database properly changes state upon a successfully committed transaction.

    • Isolation − Enables transactions to operate independently of and transparent to each other.

    • Durability − Ensures that the result or effect of a committed transaction persists in case of a system failure.

    Transaction Control

    There are following commands used to control transactions −

    • COMMIT − To save the changes.

    • ROLLBACK − To roll back the changes.

    • SAVEPOINT − Creates points within groups of transactions in which to ROLLBACK.

    • SET TRANSACTION − Places a name on a transaction.

    Transactional control commands are only used with the DML commands INSERT, UPDATE and DELETE only. They cannot be used while creating tables or dropping them because these operations are automatically committed in the database.

    In order to use transactional control commands in MS SQL Server, we have to begin transaction with ‘begin tran’ or begin transaction command otherwise these commands will not work.

    COMMIT Command

    The COMMIT command is the transactional command used to save changes invoked by a transaction to the database. This command saves all transactions to the database since the last COMMIT or ROLLBACK command.

    Syntax

    Following is the syntax for COMMIT command.

    COMMIT;
    

    Example

    Consider the CUSTOMERS table having the following records.

    ID  NAME       AGE       ADDRESS           SALARY
    1   Ramesh     32        Ahmedabad         2000.00
    2   Khilan     25        Delhi             1500.00
    3   kaushik    23        Kota              2000.00
    4   Chaitali   25        Mumbai            6500.00
    5   Hardik     27        Bhopal            8500.00
    6   Komal      22        MP                4500.00
    7   Muffy      24        Indore            10000.00
    

    Following command example will delete records from the table having age = 25 and then COMMIT the changes in the database.

    Begin Tran
    DELETE FROM CUSTOMERS
       WHERE AGE = 25
    COMMIT
    

    As a result, two rows from the table would be deleted and SELECT statement will produce the following output.

    ID  NAME       AGE       ADDRESS           SALARY
    1   Ramesh     32        Ahmedabad         2000.00
    3   kaushik    23        Kota              2000.00
    5   Hardik     27        Bhopal            8500.00
    6   Komal      22        MP                4500.00
    7   Muffy      24        Indore            10000.00
    

    ROLLBACK Command

    The ROLLBACK command is the transactional command used to undo transactions that have not already been saved to the database. This command can only be used to undo transactions since the last COMMIT or ROLLBACK command was issued.

    Syntax

    Following is the syntax for ROLLBACK command.

    ROLLBACK
    

    Example

    Consider the CUSTOMERS table having the following records.

    ID  NAME       AGE       ADDRESS            SALARY
    1   Ramesh     32        Ahmedabad          2000.00
    2   Khilan     25        Delhi              1500.00
    3   kaushik    23        Kota               2000.00
    4   Chaitali   25        Mumbai             6500.00
    5   Hardik     27        Bhopal             8500.00
    6   Komal      22        MP                 4500.00
    7   Muffy      24        Indore             10000.00
    

    Following command example will delete records from the table having age = 25 and then ROLLBACK the changes in the database.

    Begin Tran
    DELETE FROM CUSTOMERS
       WHERE AGE = 25;
    ROLLBACK
    

    As a result, delete operation will not impact the table and SELECT statement will produce the following result.

    ID  NAME       AGE       ADDRESS          SALARY
    1   Ramesh     32        Ahmedabad        2000.00
    2   Khilan     25        Delhi            1500.00
    3   kaushik    23        Kota             2000.00
    4   Chaitali   25        Mumbai           6500.00
    5   Hardik     27        Bhopal           8500.00
    6   Komal      22        MP               4500.00
    7   Muffy      24        Indore           10000.00
    

    SAVEPOINT Command

    SAVEPOINT is a point in a transaction when you can roll the transaction back to a certain point without rolling back the entire transaction.

    Syntax

    Following is the syntax for SAVEPOINT command.

    SAVE TRANSACTION SAVEPOINT_NAME
    

    This command serves only in the creation of a SAVEPOINT among transactional statements. The ROLLBACK command is used to undo a group of transactions.

    Following is the syntax for rolling back to a SAVEPOINT.

    ROLLBACK TO SAVEPOINT_NAME
    

    In the following example, we will delete three different records from the CUSTOMERS table. We will have to create a SAVEPOINT before each delete, so that we can ROLLBACK to any SAVEPOINT at any time to return the appropriate data to its original state.

    Example

    Consider the CUSTOMERS table having the following records −

    ID  NAME       AGE       ADDRESS          SALARY
    1   Ramesh     32        Ahmedabad        2000.00
    2   Khilan     25        Delhi            1500.00
    3   kaushik    23        Kota             2000.00
    4   Chaitali   25        Mumbai           6500.00
    5   Hardik     27        Bhopal           8500.00
    6   Komal      22        MP               4500.00
    7   Muffy      24        Indore           10000.00
    

    Following are the series of operations −

    Begin Tran
    SAVE Transaction SP1
    Savepoint created.
    DELETE FROM CUSTOMERS WHERE ID = 1
    1 row deleted.
    SAVE Transaction SP2
    Savepoint created.
    DELETE FROM CUSTOMERS WHERE ID = 2
    1 row deleted.
    SAVE Transaction SP3
    Savepoint created.
    DELETE FROM CUSTOMERS WHERE ID = 3
    1 row deleted.
    

    The three deletions have taken place, however, we have changed our mind and decide to ROLLBACK to the SAVEPOINT that we identified as SP2. Because SP2 was created after the first deletion, the last two deletions are undone −

    ROLLBACK Transaction SP2
    Rollback complete.
    

    Notice that only the first deletion took place since we rolled back to SP2.

    SELECT * FROM CUSTOMERS
    

    6 rows selected.

    ID  NAME       AGE       ADDRESS          SALARY
    2   Khilan     25        Delhi        1500.00
    3   kaushik    23        Kota             2000.00
    4   Chaitali   25        Mumbai           6500.00
    5   Hardik     27        Bhopal           8500.00
    6   Komal      22        MP               4500.00
    7   Muffy      24        Indore           10000.00
    

    SET TRANSACTION Command

    SET TRANSACTION command can be used to initiate a database transaction. This command is used to specify characteristics for the transaction that follows.

    Syntax

    Following is the syntax for SET TRANSACTION.

    SET TRANSACTION ISOLATION LEVEL <Isolationlevel_name>
    

    Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc

  • Khóa học miễn phí T-SQL – Indexes nhận dự án làm có lương

    T-SQL – Indexes



    Indexes are special lookup tables that the database search engine can use to speed up data retrieval. Simply put, an index is a pointer to data in a table. An index in a database is very similar to an index at the end of a book.

    For example, if you want to reference all the pages in a book that discuss a certain topic, you first refer to the index, which lists all topics alphabetically and are then referred to one or more specific page numbers.

    An index helps speed up SELECT queries and WHERE clauses, but it slows down data input, with UPDATE and INSERT statements. Indexes can be created or dropped with no effect on the data.

    Creating an index involves the CREATE INDEX statement, which allows you to name the index, to specify the table and which column or columns to index, and to indicate whether the index is in ascending or descending order.

    Indexes can also be unique, similar to the UNIQUE constraint, in that the index prevents duplicate entries in the column or combination of columns on which there”s an index.

    CREATE INDEX Command

    Following is the basic syntax of CREATE INDEX.

    Syntax

    CREATE INDEX index_name ON table_name
    

    Single-Column Indexes

    A single-column index is one that is created based on only one table column. Following is the basic syntax.

    Syntax

    CREATE INDEX index_name
    ON table_name (column_name)
    

    Example

    CREATE INDEX singlecolumnindex
    ON customers (ID)
    

    Unique Indexes

    Unique indexes are used not only for performance, but also for data integrity. A unique index does not allow any duplicate values to be inserted into the table. Following is the basic syntax.

    Syntax

    CREATE UNIQUE INDEX index_name
    on table_name (column_name)
    

    Example

    CREATE UNIQUE INDEX uniqueindex
    on customers (NAME)
    

    Composite Indexes

    A composite index is an index on two or more columns of a table. Following is the basic syntax.

    Syntax

    CREATE INDEX index_name on table_name (column1, column2)
    

    Example

    CREATE INDEX compositeindex
    on customers (NAME, ID)
    

    Whether to create a single-column index or a composite index, take into consideration the column(s) that you may use very frequently in a query”s WHERE clause as filter conditions.

    Should there be only one column used, a single-column index should be the choice. Should there be two or more columns that are frequently used in the WHERE clause as filters, the composite index would be the best choice.

    Implicit Indexes

    Implicit indexes are indexes that are automatically created by the database server when an object is created. Indexes are automatically created for primary key constraints and unique constraints.

    DROP INDEX Command

    An index can be dropped using MS SQL SERVER DROP command. Care should be taken when dropping an index because performance may be slowed or improved.

    Syntax

    Following is the basic syntax.

    DROP INDEX tablename.index_name
    

    When to Avoid Indexes?

    Although indexes are intended to enhance the performance of databases, there are times when they should be avoided. The following guidelines indicate when the use of an index should be reconsidered −

    • Indexes should not be used on small tables.

    • Tables that have frequent, large batch update or insert operations should not be indexed.

    • Indexes should not be used on columns that contain a high number of NULL values.

    • Columns that are frequently manipulated should not be indexed.


    Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc

  • Khóa học miễn phí T-SQL – String Functions nhận dự án làm có lương

    T-SQL – String Functions



    MS SQL Server String functions can be applied on string value or will return string value or numeric data.

    Following is the list of String functions with examples.

    ASCII()

    Ascii code value will come as output for a character expression.

    Example

    The following query will give the Ascii code value of a given character.

    Select ASCII (''word'')
    

    CHAR()

    Character will come as output for given Ascii code or integer.

    Example

    The following query will give the character for a given integer.

    Select CHAR(97)
    

    NCHAR()

    Unicode character will come as output for a given integer.

    Example

    The following query will give the Unicode character for a given integer.

    Select NCHAR(300)
    

    CHARINDEX()

    Starting position for given search expression will come as output in a given string expression.

    Example

    The following query will give the starting position of ”G” character for given string expression ”KING”.

    Select CHARINDEX(''G'', ''KING'')
    

    LEFT()

    Left part of the given string till the specified number of characters will come as output for a given string.

    Example

    The following query will give the ”WORL” string as mentioned 4 number of characters for given string ”WORLD”.

    Select LEFT(''WORLD'', 4)
    

    RIGHT()

    Right part of the given string till the specified number of characters will come as output for a given string.

    Example

    The following query will give the ”DIA” string as mentioned 3 number of characters for given string ”INDIA”.

    Select RIGHT(''INDIA'', 3)
    

    SUBSTRING()

    Part of a string based on the start position value and length value will come as output for a given string.

    Example

    The following queries will give the ”WOR”, ”DIA”, ”ING” strings as we mentioned (1,3), (3,3) and (2,3) as start and length values respectively for given strings ”WORLD”, ”INDIA” and ”KING”.

    Select SUBSTRING (''WORLD'', 1,3)
    Select SUBSTRING (''INDIA'', 3,3)
    Select SUBSTRING (''KING'', 2,3)
    

    LEN()

    Number of characters will come as output for a given string expression.

    Example

    The following query will give the 5 for the ”HELLO” string expression.

    Select LEN(''HELLO'')
    

    LOWER()

    Lowercase string will come as output for a given string data.

    Example

    The following query will give the ”sqlserver” for the ”SQLServer” character data.

    Select LOWER(''SQLServer'')
    

    UPPER()

    Uppercase string will come as output for a given string data.

    Example

    The following query will give the ”SQLSERVER” for the ”SqlServer” character data.

    Select UPPER(''SqlServer'')
    

    LTRIM()

    String expression will come as output for a given string data after removing leading blanks.

    Example

    The following query will give the ”WORLD” for the ”   WORLD” character data.

    Select LTRIM(''   WORLD'')
    

    RTRIM()

    String expression will come as output for a given string data after removing trailing blanks.

    Example

    The following query will give the ”INDIA” for the ”INDIA   ” character data.

    Select RTRIM(''INDIA   '')
    

    REPLACE()

    String expression will come as output for a given string data after replacing all occurrences of specified character with specified character.

    Example

    The following query will give the ”KNDKA” string for the ”INDIA” string data.

    Select REPLACE(''INDIA'', ''I'', ''K'')
    

    REPLICATE()

    Repeat string expression will come as output for a given string data with specified number of times.

    Example

    The following query will give the ”WORLDWORLD” string for the ”WORLD” string data.

    Select REPLICATE(''WORLD'', 2)
    

    REVERSE()

    Reverse string expression will come as output for a given string data.

    Example

    The following query will give the ”DLROW” string for the ”WORLD” string data.

    Select REVERSE(''WORLD'')
    

    SOUNDEX()

    Returns four-character (SOUNDEX) code to evaluate the similarity of two given strings.

    Example

    The following query will give the ”S530” for the ”Smith”, ”Smyth” strings.

    Select SOUNDEX(''Smith''), SOUNDEX(''Smyth'')
    

    DIFFERENCE()

    Integer value will come as output of given two expressions.

    Example

    The following query will give the 4 for the ”Smith”, ”Smyth” expressions.

    Select Difference(''Smith'',''Smyth'')
    

    Note − If the output value is 0 it indicates weak or no similarity between give 2 expressions.

    SPACE()

    String will come as output with the specified number of spaces.

    Example

    The following query will give the ”I LOVE INDIA”.

    Select ''I''&plus;space(1)&plus;''LOVE''&plus;space(1)&plus;''INDIA''
    

    STUFF()

    String expression will come as output for a given string data after replacing from starting character till the specified length with specified character.

    Example

    The following query will give the ”AIJKFGH” string for the ”ABCDEFGH” string data as per given starting character and length as 2 and 4 respectively and ”IJK” as specified target string.

    Select STUFF(''ABCDEFGH'', 2,4,''IJK'')
    

    STR()

    Character data will come as output for the given numeric data.

    Example

    The following query will give the 187.37 for the given 187.369 based on specified length as 6 and decimal as 2.

    Select STR(187.369,6,2)
    

    UNICODE()

    Integer value will come as output for the first character of given expression.

    Example

    The following query will give the 82 for the ”RAMA” expression.

    Select UNICODE(''RAMA'')
    

    QUOTENAME()

    Given string will come as output with the specified delimiter.

    Example

    The following query will give the “RAMA” for the given ”RAMA” string as we specified double quote as delimiter.

    Select QUOTENAME(''RAMA'',''"'')
    

    PATINDEX()

    Starting position of the first occurrence from the given expression as we specified ”I” position is required.

    Example

    The following query will give the 1 for the ”INDIA”.

    Select PATINDEX(''I%'',''INDIA'')
    

    FORMAT()

    Given expression will come as output with the specified format.

    Example

    The following query will give the ” Monday, November 16, 2015” for the getdate function as per specified format with ”D” refers weekday name.

    SELECT FORMAT ( getdate(), ''D'')
    

    CONCAT()

    Single string will come as output after concatenating the given parameter values.

    Example

    The following query will give the ”A,B,C” for the given parameters.

    Select CONCAT(''A'','','',''B'','','',''C'')
    

    Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc

  • Khóa học miễn phí T-SQL – Date Functions nhận dự án làm có lương

    T-SQL – Date Functions



    Following is the list of date functions in MS SQL Server.

    GETDATE()

    It will return the current date along with time.

    Syntax

    Syntax for the above function −

    GETDATE()
    

    Example

    The following query will return the current date along with time in MS SQL Server.

    Select getdate() as currentdatetime
    

    DATEPART()

    It will return the part of date or time.

    Syntax

    Syntax for the above function −

    DATEPART(datepart, datecolumnname)
    

    Example

    Example 1 − The following query will return the part of current date in MS SQL Server.

    Select datepart(day, getdate()) as currentdate
    

    Example 2 − The following query will return the part of current month in MS SQL Server.

    Select datepart(month, getdate()) as currentmonth
    

    DATEADD()

    It will display the date and time by add or subtract date and time interval.

    Syntax

    Syntax for the above function −

    DATEADD(datepart, number, datecolumnname)
    

    Example

    The following query will return the after 10 days date and time from the current date and time in MS SQL Server.

    Select dateadd(day, 10, getdate()) as after10daysdatetimefromcurrentdatetime
    

    DATEDIFF()

    It will display the date and time between two dates.

    Syntax

    Syntax for the above function −

    DATEDIFF(datepart, startdate, enddate)
    

    Example

    The following query will return the difference of hours between 2015-11-16 and 2015-11-11 dates in MS SQL Server.

    Select datediff(hour, 2015-11-16, 2015-11-11) as
    differencehoursbetween20151116and20151111
    

    CONVERT()

    It will display the date and time in different formats.

    Syntax

    Syntax for the above function −

    CONVERT(datatype, expression, style)
    

    Example

    The following queries will return the date and time in different format in MS SQL Server.

    SELECT CONVERT(VARCHAR(19),GETDATE())
    SELECT CONVERT(VARCHAR(10),GETDATE(),10)
    SELECT CONVERT(VARCHAR(10),GETDATE(),110)
    

    Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc

  • Khóa học miễn phí T-SQL – Useful Resources nhận dự án làm có lương

    T-SQL – Useful Resources



    The following resources contain additional information on T-SQL. Please use them to get more in-depth knowledge on this.

    Useful Video Courses

    45 Lectures 4.5 hours

    36 Lectures 5 hours

    59 Lectures 3.5 hours

    22 Lectures 1.5 hours

    15 Lectures 1.5 hours

    40 Lectures 3 hours


    Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc

  • Khóa học miễn phí T-SQL – Discussion nhận dự án làm có lương

    Discuss T-SQL



    T-SQL (Transact-SQL) is an extension of SQL language. This tutorial covers the fundamental concepts of T-SQL such as its various functions, procedures, indexes, and transactions related to the topic. Each topic is explained using examples for easy understanding.


    Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc

  • Khóa học miễn phí T-SQL – UPDATE Statement nhận dự án làm có lương

    T-SQL – UPDATE Statement



    The SQL Server UPDATE Query is used to modify the existing records in a table.

    You can use WHERE clause with UPDATE query to update selected rows otherwise all the rows would be affected.

    Syntax

    Following is the basic syntax of UPDATE query with WHERE clause −

    UPDATE table_name
    SET column1 = value1, column2 = value2...., columnN = valueN
    WHERE [condition];
    

    You can combine N number of conditions using AND or OR operators.

    Example

    Consider the CUSTOMERS table having the following records −

    ID  NAME       AGE       ADDRESS             SALARY
    1   Ramesh     32        Ahmedabad           2000.00
    2   Khilan     25        Delhi               1500.00
    3   kaushik    23        Kota                2000.00
    4   Chaitali   25        Mumbai              6500.00
    5   Hardik     27        Bhopal              8500.00
    6   Komal      22        MP                  4500.00
    7   Muffy      24        Indore              10000.00
    

    Following command is an example, which would update ADDRESS for a customer whose ID is 6 −

    UPDATE CUSTOMERS
    SET ADDRESS = ''Pune''
    WHERE ID = 6;
    

    CUSTOMERS table will now have the following records −

    ID  NAME       AGE       ADDRESS             SALARY
    1   Ramesh     32        Ahmedabad           2000.00
    2   Khilan     25        Delhi               1500.00
    3   kaushik    23        Kota                2000.00
    4   Chaitali   25        Mumbai              6500.00
    5   Hardik     27        Bhopal              8500.00
    6   Komal      22        Pune                4500.00
    7   Muffy      24        Indore              10000.00
    

    If you want to modify all ADDRESS and SALARY column values in CUSTOMERS table, you do not need to use WHERE clause. UPDATE query would be as follows −

    UPDATE CUSTOMERS
    SET ADDRESS = ''Pune'', SALARY = 1000.00;
    

    CUSTOMERS table will now have the following records.

    ID  NAME       AGE       ADDRESS          SALARY
    1   Ramesh     32        Pune             1000.00
    2   Khilan     25        Pune             1000.00
    3   kaushik    23        Pune             1000.00
    4   Chaitali   25        Pune             1000.00
    5   Hardik     27        Pune             1000.00
    6   Komal      22        Pune             1000.00
    7   Muffy      24        Pune             1000.00
    

    Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc

  • Khóa học miễn phí T-SQL – Home nhận dự án làm có lương

    T-SQL Tutorial

    T-SQL Tutorial







    T-SQL (Transact-SQL) is an extension of SQL language. This tutorial covers the fundamental concepts of T-SQL such as its various functions, procedures, indexes, and transactions related to the topic. Each topic is explained using examples for easy understanding.

    Audience

    This tutorial is designed for those who want to learn the basics of T-SQL.

    Prerequisites

    To go ahead with this tutorial, familiarity with database concepts is preferred. It is good to have SQL Server installed on your computer, as it might assist you in executing the examples yourself and get to know how it works.

    Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc