Hi there
I'm struggeling by creating a regex to parse the column names whitin a given t-sql statement.
This is my test sql statement to work with:
SELECT
dbo.Reservation.Id,
dbo.Reservation.Beginn,
dbo.Reservation.Ende,
RessourceBezeichnung = (SELECT Value FROM dbo.Text WHERE FieldOid = dbo.Ressource.BezeichnungOid AND LanguageId = 'de'),
(SELECT Value FROM dbo.Text WHERE FieldOid = dbo.Ressource.BezeichnungOid AND LanguageId = 'de') AS StatusBezeichnung,
HasSubreservationRaum = ISNULL(CASE
WHEN (
Reservation.ReservationId IS NULL
AND EXISTS (
SELECT NULL
FROM dbo.Reservation AS ChildReservation WITH (NOLOCK)
WHERE ChildReservation.ReservationId = dbo.Reservation.Id
AND ChildReservation.RessourcetypId = 1
)
)
OR (
Reservation.ReservationId IS NOT NULL
AND EXISTS (
SELECT NULL
FROM dbo.Reservation AS ChildReservation WITH (NOLOCK)
WHERE ChildReservation.ReservationId = dbo.Reservation.ReservationId
AND ChildReservation.RessourcetypId = 1
)
)
THEN CAST(1 AS BIT)
ELSE CAST(0 AS BIT)
END, CAST(0 AS BIT))
FROM dbo.Reservation WITH (NOLOCK)
There are three ways a column can be name
- Just select the column name (e.g. dbo.Reservation.Id --> Id)
- Define the column name followed with an equal (e.g. HasSubreservationRaum = (A subquery)
- Or alias is it with the as (e.g (SELECT Value FROM dbo.Text WHERE FieldOid = dbo.Ressource.BezeichnungOid AND LanguageId = 'de') AS StatusBezeichnung)
Any ideas how to solve this?
Regards,
Lukas