Parse an SQL statement to find date columns

  • Hi All

    This is a general question about T-SQL statements

    If I have a reasonably complex Select statement (always a relative term I know!) and I would like to find all of the date columns used in the where clause within the statement

    At the point of parsing I may or may not have access to the database so only have the ability to look for date like values within the where

    select
    .......
    join ....
    join ....
    join ....
    join ....
    where Amount > 100 and PeriodStart>'20190405' and PeriodEnd<'20190405' and Category='Green'

    Basically I need to be able to find the date to be able to change it

    Has anyone had the need to do anything like this ?

    Thanks

  • andrew 67979 - Friday, March 22, 2019 11:14 AM

    Hi All

    This is a general question about T-SQL statements

    If I have a reasonably complex Select statement (always a relative term I know!) and I would like to find all of the date columns used in the where clause within the statement

    At the point of parsing I may or may not have access to the database so only have the ability to look for date like values within the where

    select
    .......
    join ....
    join ....
    join ....
    join ....
    where Amount > 100 and PeriodStart>'20190405' and PeriodEnd<'20190405' and Category='Green'

    Basically I need to be able to find the date to be able to change it

    Has anyone had the need to do anything like this ?

    Thanks

    I use variables instead of hard-coding in dates.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

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

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