Book a Demo

Author Topic: Find substring in element notes using SQL query  (Read 7896 times)

Fuglesteg

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Find substring in element notes using SQL query
« on: January 26, 2017, 08:21:22 pm »
Hello,

I am trying to create a model view listing all requirements in my model that has the word TBD in t_object.Note. TBD is part of a requirement statement. I have tried the following code with various wildcard combinations:

SELECT t_object.Alias As Alias, t_object.Name As Name, t_object.Note As notes
From t_object
Where t_object.Object_Type = 'Requirement' And t_object.Note LIKE '%TBD%'

This seems to work only when TBD are the only word in the notes. It does not return any results if TBD is part of a sentence.

Any help is appreciated.

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Find substring in element notes using SQL query
« Reply #1 on: January 26, 2017, 08:34:09 pm »
Hello,

The wildcard character differs between SQL dialects, so it depends on which DBMS you're using.
For Access databases (.EAP file), the query works with '*'.

/Uffe
My theories are always correct, just apply them to the right reality.

Fuglesteg

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: Find substring in element notes using SQL query
« Reply #2 on: January 27, 2017, 01:44:00 am »
Thank you uffe,
Problem solved

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Find substring in element notes using SQL query
« Reply #3 on: January 27, 2017, 06:20:24 pm »
In the future best use the macro #WC# as this works on any type of repository.

Geert

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Find substring in element notes using SQL query
« Reply #4 on: January 27, 2017, 07:43:34 pm »
In the future best use the macro #WC# as this works on any type of repository.

Does that work in free-form SQL queries entered manually?
My theories are always correct, just apply them to the right reality.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Find substring in element notes using SQL query
« Reply #5 on: January 27, 2017, 09:05:35 pm »
In the future best use the macro #WC# as this works on any type of repository.

Does that work in free-form SQL queries entered manually?
No, only in actual SQL Search queries, not in the scratch pad (and probably not when using the API)

Geert