SQL Query | Split Concatenated String into Columns | CharIndex

  Рет қаралды 79,126

Learn at Knowstar

Learn at Knowstar

Күн бұрын

Пікірлер: 55
@vijay00071
@vijay00071 3 жыл бұрын
CHARINDEX is not working on my SQL
@AJITHkumar-lj7gp
@AJITHkumar-lj7gp 2 жыл бұрын
Try instring function
@sukumar44
@sukumar44 3 жыл бұрын
This is what I was looking for so many days. Finally landed to the right place. Thank you. Can you also show the same with the help of Substr() function.
@LearnatKnowstar
@LearnatKnowstar 3 жыл бұрын
Thank you so much. Sure. Will post a video soon.
@tarvinder91
@tarvinder91 2 жыл бұрын
Thank u for explaining that embedded queries. I was able to use that knowledge in other queries.
@LearnatKnowstar
@LearnatKnowstar 2 жыл бұрын
Thank you
@kapach1000
@kapach1000 21 күн бұрын
❤ love this explanation.
@LearnatKnowstar
@LearnatKnowstar 21 күн бұрын
Thank you! Glad you found it helpful.
@suryakota7685
@suryakota7685 Жыл бұрын
Thank you so much , for your explanation, i was asked this question in one of Big MNC
@LearnatKnowstar
@LearnatKnowstar Жыл бұрын
Glad to hear that
@pareshyadnik4108
@pareshyadnik4108 3 жыл бұрын
can we use parse name function to split the string or there is a performance issue
@lia_sahin
@lia_sahin 3 жыл бұрын
how to split a large table consisting of a single column with 15 attributes, there should be 15 columns. in MsSQL server. Thanks 😊!
@LearnatKnowstar
@LearnatKnowstar 3 жыл бұрын
There can be different approaches. One way can be to use string split function. Please see detailed tutorial here - kzbin.info/www/bejne/aqHHf517bp2FabM
@lia_sahin
@lia_sahin 3 жыл бұрын
@@LearnatKnowstar thanks 😊
@Dracometeor562
@Dracometeor562 4 жыл бұрын
is this supported at SQL 2005 ?
@LearnatKnowstar
@LearnatKnowstar 3 жыл бұрын
Yes, it is.
@YouCallThataKnife253
@YouCallThataKnife253 Жыл бұрын
What if I no longer want to see that original concatenated column?
@pickmeisha
@pickmeisha 11 ай бұрын
My field is 'Doe,John A' and I am trying to partition the A...this is not working as it pulls over the entire name when there is no middle initial.
@solomong.gebrhana1204
@solomong.gebrhana1204 Жыл бұрын
what if we have 4 strings to extract? what is the best function to use?
@shubhamgoyal5227
@shubhamgoyal5227 Жыл бұрын
Hello mam if there is middle name then then could you please guide how to derive it e.g ram kumar bansal in this how can we derive kumar using sql query.
@hnaidu.pro21
@hnaidu.pro21 8 ай бұрын
Static Method (Name is Hardcoded): SELECT SUBSTRING('Ram Kumar Bansal', CHARINDEX(' ', 'Ram Kumar Bansal') + 1, CHARINDEX(' ', 'Ram Kumar Bansal', 5) - CHARINDEX(' ', 'Ram Kumar Bansal', 1)) AS MiddleName Dynamic Method (Applies to all names): SELECT SUBSTRING([Name], CHARINDEX(' ', [Name]) + 1, CHARINDEX(' ', [Name], CHARINDEX(' ', [Name]) + 1) - CHARINDEX(' ', [Name], 1)) AS MiddleName FROM TableName;
@lzxp7943
@lzxp7943 3 жыл бұрын
thank you very much for break it down to step by step
@LearnatKnowstar
@LearnatKnowstar 3 жыл бұрын
Thank you so much!
@latapant6371
@latapant6371 4 жыл бұрын
Very useful video 🙏🙏
@LearnatKnowstar
@LearnatKnowstar 4 жыл бұрын
Thank you
@Manish247-R
@Manish247-R 2 жыл бұрын
please tell me for 2 delimiters in between.
@LearnatKnowstar
@LearnatKnowstar 2 жыл бұрын
You can try using the Split String function. Please find below the video tutorial for the same - kzbin.info/www/bejne/aqHHf517bp2FabM
@Faisal1504
@Faisal1504 3 жыл бұрын
What about the space between the , and first name? Don’t we add +1 to charIndex. ?
@LearnatKnowstar
@LearnatKnowstar 3 жыл бұрын
Yes, you can do a +1 or apply trim on the extracted first name.
@abhishekrawat8305
@abhishekrawat8305 11 ай бұрын
please provide DDL and DML commands also
@Hakeem_Abdul
@Hakeem_Abdul 2 жыл бұрын
Can you pls help me with a similar request.?? My need is: if length of input field is more than 40 characters, then it should load data until last space before 40 characters to one column and the remaining should load to another column..
@tanyagupta6319
@tanyagupta6319 2 жыл бұрын
How many possibilities these SQL queries will come in the placement? I mean same as it came ya little bit differ has to be come?
@prashantx19
@prashantx19 3 жыл бұрын
what if there are three commas
@LearnatKnowstar
@LearnatKnowstar 3 жыл бұрын
You can use string split function. See tutorial here kzbin.info/www/bejne/aqHHf517bp2FabM
@prashantx19
@prashantx19 3 жыл бұрын
@@LearnatKnowstar thanks ... it really helpful.
@edgetransit3320
@edgetransit3320 3 жыл бұрын
You saved my life lmfao. Thank you so much !!
@LearnatKnowstar
@LearnatKnowstar 3 жыл бұрын
Glad I could help!
@kitbodeephongkasem909
@kitbodeephongkasem909 2 жыл бұрын
If.​ Colum.​​name.​ some.row.​ Not​ have​ comma?
@Beyondhorizons-i5z
@Beyondhorizons-i5z 4 жыл бұрын
Brilliant stuff!
@LearnatKnowstar
@LearnatKnowstar 4 жыл бұрын
Thank you
@raj-sk4br
@raj-sk4br 3 жыл бұрын
What about middle name?
@LearnatKnowstar
@LearnatKnowstar 3 жыл бұрын
If there is always a middle name, you can use charindex to extract the middle string. If the middle name might or might not exist, then more logic needs to be put in the SQL query.
@LearnatKnowstar
@LearnatKnowstar 3 жыл бұрын
Thanks for presenting this scenario. We will post a solution video soon.
@sanujidananjaya
@sanujidananjaya 4 жыл бұрын
Thank you ! , Very usefull
@LearnatKnowstar
@LearnatKnowstar 4 жыл бұрын
Thank you
@NaveenKumar-fq4sb
@NaveenKumar-fq4sb Жыл бұрын
where is data set ...
@prashantdahiya711
@prashantdahiya711 2 жыл бұрын
Thank you Mam, 👍
@LearnatKnowstar
@LearnatKnowstar 2 жыл бұрын
Glad it was helpful 🙏
@HappyModernW3
@HappyModernW3 3 жыл бұрын
Very helpful!!
@LearnatKnowstar
@LearnatKnowstar 3 жыл бұрын
Thank you
@landchennai8549
@landchennai8549 2 ай бұрын
select * from ( select * from #Emp cross apply string_split(Name,',',1) ) v pivot(max(value) for ordinal in ([1],[2]))v
@avinashkarad7141
@avinashkarad7141 3 жыл бұрын
i am using 11g .. i have data like below in 1 column col_name 1 john 34000 3 david 20000 want output like in 3 different columns like this id name salary 1 john 34000 3 david 20000 pls help me with this @Learn at Knowstar
@TheDistractionStudio
@TheDistractionStudio 3 жыл бұрын
Thank you!!
@LearnatKnowstar
@LearnatKnowstar 3 жыл бұрын
Thank you
@hnaidu.pro21
@hnaidu.pro21 8 ай бұрын
Another Method: Using a Substring SELECT EmployeeID, Name, SUBSTRING([Name], CHARINDEX(' ', [Name], 1) + 1, LEN([Name])) AS FirstName, SUBSTRING([Name], 1, CHARINDEX(',', [Name], 1) - 1) AS LastName FROM [dbo].[tblNames] Method 2: Using Reverse function (along with LEFT, RIGHT) SELECT EmployeeID, Name, RIGHT([Name], CHARINDEX(' ', REVERSE([Name])) - 1) AS FirstName, LEFT([Name], CHARINDEX(',', [Name], 1) - 1) AS LastName FROM [dbo].[tblNames]
SQL | Pivot | Case | Convert data from Rows to Columns
7:14
Learn at Knowstar
Рет қаралды 50 М.
SQL Query | How to dynamically convert rows into columns | Dynamic Pivot
16:18
IL'HAN - Qalqam | Official Music Video
03:17
Ilhan Ihsanov
Рет қаралды 700 М.
Easy360Web: The 360° Solution
0:53
AR Market - A World of Immersive Solutions
Рет қаралды 27
SQL Query | Split concatenated string into columns | STRING_SPLIT function
10:33
SQL Tutorial | Date Functions | Find Age from Birth Date
12:14
Learn at Knowstar
Рет қаралды 79 М.
Forward Fill Null Values  - 2 WAYS TO SOLVE |  Tricky SQL Questions
11:23
SQL Query | How to calculate YTD and MTD totals | Window Functions
16:01
Learn at Knowstar
Рет қаралды 43 М.
SQL query to get the string before or after any specific character (Substring, Charindex)
4:59
Google’s Quantum Chip: Did We Just Tap Into Parallel Universes?
9:34
SQL Query | How to find Maximum of multiple columns | Values
8:00
Learn at Knowstar
Рет қаралды 114 М.