set value = T3.data
from #Table1 T1
JOIN #Table2 T2 ON T1.Tid = T2.Tid
JOIN Tables3 T3 ON T3.Tid1 = T2.Tid1
The Data coming from T3.Data will be like in format
From this I need to get displayed on 4
From this I need to get displayed only 41
From this I need to get displayed only 410
Bacically I need to get only data displayed between ^ and |
Abcdefghi^ will be same but length of data after that will differ
Can anyone suggest the query to be written for this please in MS SQL
So how are #Tables joined to the other tables?
One of the most important and advantageous things that you can do with any computer language is to know what all the different intrinsic functions actually can do and how to use most of them. Here's a link to get you started.
Here's an example of your problem and solution as a SELECT. The VALUES part is simulating the "T3" aliased table from your code. You should be able to apply the formula and the CROSS apply to your real UPDATE code fairly easily. And memorize how to use both CROSS APPLY and CHARINDEX because they can be real life savers in a whole lot of problems.
SELECT OriginalString = t3.data
,DesiredString = SUBSTRING(t3.data,pos.StartPos,pos.EndPos-pos.StartPos+1)
CROSS APPLY (SELECT StartPos = CHARINDEX('^',t3.data)+1, EndPos = CHARINDEX('|',t3.data)-1)pos