本文介绍了正则表达式在SQL查询中提取列名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 您好 我正在通过创建一个正则表达式来解析给定t-sql语句中的列名。 这是我的测试sql语句:Hi thereI'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:SELECTdbo.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(CASEWHEN (Reservation.ReservationId IS NULLAND EXISTS (SELECT NULLFROM dbo.Reservation AS ChildReservation WITH (NOLOCK)WHERE ChildReservation.ReservationId = dbo.Reservation.IdAND ChildReservation.RessourcetypId = 1))OR (Reservation.ReservationId IS NOT NULLAND EXISTS (SELECT NULLFROM dbo.Reservation AS ChildReservation WITH (NOLOCK)WHERE ChildReservation.ReservationId = dbo.Reservation.ReservationIdAND ChildReservation.RessourcetypId = 1))THEN CAST(1 AS BIT)ELSE CAST(0 AS BIT)END, CAST(0 AS BIT))FROM dbo.Reservation WITH (NOLOCK) 列可以有三种方式命名 - 只需选择列名称(例如dbo.Reservation.Id - > Id) - 定义列名后跟相等(例如HasSubreservationRaum =(子查询) - 或别名是as(例如(SELECT Value FROM dbo) .Text WHERE FieldOid = dbo.Ressource.BezeichnungOid AND LanguageId ='de')AS StatusBezeichnung) 任何想法如何解决这个问题? 问候, LukasThere 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推荐答案 这篇关于正则表达式在SQL查询中提取列名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-23 17:48