How to find SELECT<whitespace>* or SELECT<alias>.* in Code for a view using sys tables

  • So we have been having replication/build failures due to views with SELECT *.

    The exercise below should be a trivial regex string..How should I code this search?

    The example below handles one case - how might I code for any combination of spaces and tabs between SELECT and *?

    SELECT OBJECT_NAME( SO.OBJECT_ID ) AS Name

    FROM sys.syscomments AS SC

    INNER JOIN sys.objects AS SO ON SC.ID = SO.OBJECT_ID

    WHERE SO.Is_MS_Shipped = 0 AND SO.[Type_Desc] = 'VIEW' AND SC.Text LIKE N'%SELECT *%' ESCAPE '\'

    It could even be SELECT<whitespace><cr or lf or both><whitespace>*

    Thanks ahead of time,

    Doug

  • Not a single response?

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply