Wednesday, 9 September 2015

SQL Query to Replace a character with Some other character in a column

We are here to discuss about “how to write a query to replace a character with some other character in a column”

                Note : Some more SQL Queries for SQL server beginners

In our previous article we are discuss about “How to Create Table in Microsoft SQL Server”,  “SQL Query To Get Highest Salary Employee Details In A Employee Table” and some more queries.

                Now we are here to discuss about SQL Query to Replace a character with Some other character in a column.

                This is very basic question asked many interviews (for SQL Server platform students). If you are not given correct answer to SQL Query to Replace a character with Some other character in a column, then you must rejected in the interview, Because this is the very basic technical interview question in SQL server.

SQL Query to Replace a character with Some other character in a column

                This is not a complex SQL query to feel difficult, just you need to remember replace keyword syntax.

Here, we discuss SQL Query to Replace a character with Some other character in a column with one example, then it become is to you to remember.

    We have employee table called ‘employee’ is as following table.

Employee-Table-in-sql-server


In the above table we have column called ename with 6 values (names). So in that all the names we need to replace ‘v’ with ‘b’.

For example in first row we have ename as “vali”, after replacing ‘v’ character with ‘b’ character then output should be as follows. That is input “vali” is changed as “bali” and “venkat” is replaced as “benkat”. The output table is as shown in below table
Output-after-replacing-in-sql-server

                So to get the output as above table, we need to use “replace” keyword in SQL Query.
 SQL Query to Replace a character with Some other character in a column

       Select REPLACE(ename, 'v', 'b') from employee

If you know queries related to this topic or any topic in SQL Server, Then comment here we are  always available to help you.

for Software Developer Jobs registration links click here

Note: Press “Ctrl+D” to bookmark this page

You can also search about this topic in google as:
Replace query in SQL Server, how to write SQL Query to Replace a character with Some other character in a column, How replace query is work in SQL server, SQL Server replace sql query, sql server technical interview questions, SQL  server interview questions on replace keyword

0 comments:

Post a Comment

 
Copyright © . Freshers Junction - Posts · Comments
Theme Template by Freshers Junction · Powered by Blogger