What does this parameter do? ('* All')

  • Hey guys -

    It's become my job to decipher dozens (prob close to 100) of SPs written by a dozen different developers. Of course nothing is documented and that's where I come in.

    One SP has these couple of lines.....

    IF EXISTS(SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES

    WHERE TABLE_NAME = 'TableA')

    DROP TABLE TableA

    Select Distinct FieldNameA

    Into TableA

    from TableB

    Insert Into TableA(FieldNameA)

    Values ('* All')

    OK. So it seems Table A is dropped, recreated with fresh daily data and then repopulated with Distinct values from Table B.

    But what does the bolded text do??

  • RedBirdOBX (7/25/2013)


    Hey guys -

    It's become my job to decipher dozens (prob close to 100) of SPs written by a dozen different developers. Of course nothing is documented and that's where I come in.

    One SP has these couple of lines.....

    IF EXISTS(SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES

    WHERE TABLE_NAME = 'TableA')

    DROP TABLE TableA

    Select Distinct FieldNameA

    Into TableA

    from TableB

    Insert Into TableA(FieldNameA)

    Values ('* All')

    OK. So it seems Table A is dropped, recreated with fresh daily data and then repopulated with Distinct values from Table B.

    But what does the bolded text do??

    Ready for a facepalm moment? It inserts a row into TableA. The only value is for the column FieldNameA and the value is '* All'. This is only a string, nothing special about it all.

    create table #TableA(FieldNameA varchar(10))

    Insert Into #TableA(FieldNameA)

    Values ('* All')

    select * from #TableA

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

  • Hahaha.

    OK. I need a break from this. It's a literal string! Haha.

    I thought it was some clever Union or something.:-D

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

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