Link to home
Start Free TrialLog in
Avatar of Wayne Barron
Wayne BarronFlag for United States of America

asked on

TSQL Get Data between [ brackets ]

Hello all,

In SSMS, when you
Right Click "Edit All Rows"

When you click on a column, it will jump to the end of the text in that column.
Is there a way, to make it jump to the beginning of the column, instead of the end?
Avatar of Shaun Vermaak
Shaun Vermaak
Flag of Australia image

Probably not. SSMS is not meant as a tool to enter data, that should happen in the front-end application.

You can try Heidi
https://www.heidisql.com/download.php
Avatar of Wayne Barron

ASKER

Explanation of why I was asking.
I have several hundred records that I need to go through.
I am looking for the tag in each and every row.
[proimge=image.jpg]

Open in new window

I am then going to take that value, and place it in a new column for the image.

So, I was going to just go through each record and update it manually.
I think a better way would be to run a query for everything between the brackets.
Return all rows, and then copy the data over to the new column.

Any ideas on this would be great.
Yes, an update query would be best. Please explain your steps in a bit more detail with screenshots
I just found this and modified it, and it returns all records.
however, it cuts off some of the content.

select EVID, evTitle, SUBSTRING(evFullContent,CHARINDEX('[proimg=',evFullContent)+1,CHARINDEX(']',evFullContent) - CHARINDEX('[',evFullContent)-1) from evContent

Open in new window


Using the code above, the following happens.
This record
[proimg=carrzkiss/carrzkiss_02-58-55-Jul-14-2012_carrzkiss_02-34-52-Jun-11-2011_EnterView_.png]EnterView - Connecting Entertainment and the views of the world together![/proimg]

Open in new window

Will return this value
proimg=carrzkiss/carrzkiss_02-58-

Open in new window


This record
[proimg=carrzkiss/carrzkiss_02-57-25-Jul-14-2012_carrzkiss_01-09-41-Mar-01-2011_logo.jpg]Carrz-Fox-Fire Promotions[/proimg]

Open in new window

Will return this value
proimg=carr

Open in new window


However, this record.
[proimg=carrzkiss/carrzkiss_02-57-26-Jul-14-2012_carrzkiss_07-04-59-Mar-23-2011_Logo.png]Dark Effects Productions[/proimg]

Open in new window

Will return this value (The correct value)
proimg=carrzkiss/carrzkiss_02-57-26-Jul-14-2012_carrzkiss_07-04-59-Mar-23-2011_Logo.png

Open in new window


So, it seems the code works, but does not give the correctly expected results.

NOW, keeping in mind.
The code has a LOT of BRACKETS in it.
ASKER CERTIFIED SOLUTION
Avatar of _agx_
_agx_
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Worked great.
Thank you very much.