Search code examples
visual-studioreporting-servicesreportsql-server-data-tools

How to fix my code to get the characters before specified symbol like @ in SSDT?


I am using visual studio ssdt (reporting services) . I want to retrieve substring from string. For example: In my database, I have 7720@449943AJFDJ,7777@9r49r49 or 8888888844@dj939393 I want to retrieve substring from first symbol to @. I use this code = CInt(Split(Fields!PRESENTATION_NAME.Value.ToString, "@")(0)) .I didn't have any errors,but my code shows me 38505 - this's not true.I don't have string started with 38505.I was expecting from my code to show 7720 , 7777 or 8888888844. Do you know how to fix that? I upload file to see what I mean. Thank you


Solution

  • It looks like you're trying to get the text that comes before first the @? If so, the InStr function finds the position of the first occurrence of the specified text. This can then be used as the second parameter of the Left function, with 1 subtracted from it to omit the @ from the final result.

    Left(Fields!PRESENTATION_NAME.Value, InStr(Fields!PRESENTATION_NAME.Value, "@") - 1)