in Technology by
What is the difference between SUBSTR and CHARINDEX in the SQL Server?

1 Answer

0 votes
by

What is the difference between SUBSTR and CHARINDEX in the SQL Server?

The SUBSTR function is used to return specific portion of string in a given string. But, CHARINDEX function gives character position in a given specified string.

SUBSTRING('Smiley',1,3)

Gives result as Smi

CHARINDEX('i', 'Smiley',1)

Gives 3 as result as I appears in 3rd position of the string

Related questions

0 votes
    The SQL statement SELECT SUBSTR( 123456789', INSTR( abcabcabc','b'), 4) FROM EMP; prints (a) 6789 ... Answers, Database Interview Questions and Answers for Freshers and Experience...
asked Oct 11, 2021 in Education by JackTerrance
0 votes
    In SQL Server 2005, we can create temp tables one of two ways: declare @tmp table (Col1 int, Col2 ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 27, 2022 in Education by JackTerrance
0 votes
    I am paginating users and in my view I have: I want to limit li.profile to 200 characters ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 11, 2022 in Education by JackTerrance
0 votes
    What is the difference between SQL and MySQL?...
asked Dec 8, 2020 in Technology by JackTerrance
0 votes
    Difference between Server-Side AJAX framework and Client-side AJAX framework?...
asked Dec 31, 2020 in Technology by JackTerrance
0 votes
    What is the difference between the EXISTS and IN clause in SQL? When should we use EXISTS, and when should we use IN? Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    What is the difference between the EXISTS and IN clause in SQL? When should we use EXISTS, and when should we use IN? Select the correct answer from above options...
asked Feb 5, 2022 in Education by JackTerrance
0 votes
    What is the difference between Server.Transfer and Response.redirect?...
asked Apr 7, 2021 in Education by JackTerrance
0 votes
    Where are SQL Server user names and passwords stored in SQL Server?...
asked Nov 9, 2020 in Technology by Editorial Staff
0 votes
    What is a View in SQL Server?...
asked Dec 9, 2020 in Technology by JackTerrance
0 votes
    What are the new features added to Query Processing in SQL Server 2019?...
asked Nov 30, 2020 in Technology by JackTerrance
0 votes
    How to delete duplicate rows in SQL Server?...
asked Nov 9, 2020 in Technology by Editorial Staff
0 votes
    What are Magic Tables in SQL Server?...
asked Nov 9, 2020 in Technology by Editorial Staff
0 votes
    Which SQL server table is used to hold the stored procedure scripts?...
asked Nov 9, 2020 in Technology by Editorial Staff
0 votes
    What is the command used to get the version of SQL Server?...
asked Nov 9, 2020 in Technology by Editorial Staff
...