Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

What does this parameter do? ('* All') Expand / Collapse
Author
Message
Posted Thursday, July 25, 2013 12:34 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Monday, August 25, 2014 11:46 AM
Points: 98, Visits: 241
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??
Post #1477673
Posted Thursday, July 25, 2013 1:02 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 2:05 PM
Points: 13,327, Visits: 12,820
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 Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1477691
Posted Thursday, July 25, 2013 1:12 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Monday, August 25, 2014 11:46 AM
Points: 98, Visits: 241
Hahaha.

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

I thought it was some clever Union or something.
Post #1477695
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse