Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Prefix first Column Header with #

Status
Not open for further replies.

wvandenberg

Technical User
Oct 24, 2002
125
CA
I have a stored procedure that builds a dynamic query. I would like to prefix the first column header with a pound sign (#) but the following does not include the # in the final SQL string. Please note that the first colomn is intended to be filled with an empty string.

Current select portion of the dynamic query:

Code:
set @select = 'SELECT '''' as [#Location_Group], l.sys_loc_code as Location, f.facility_code
	, c.x_coord, c.y_coord, REPLACE(LEFT(RIGHT(c.coord_type_code,5),2),''_'',''''), f.client '


Current resulting SQL

Code:
SELECT '' as [#Location_Group], l.sys_loc_code as Location, f.facility_code
	, c.x_coord, c.y_coord, REPLACE(LEFT(RIGHT(c.coord_type_code,5),2),'_',''), f.client FROM cte
INNER JOIN ...

Resulting column headers:

Location_Group Location facility_code Easting Northing Zone Client


Desired column headers

#Location_Group Location facility_code Easting Northing Zone Client

Thanks in anticipation,
Wendy
 
That works for me:
Code:
DECLARE @test varchar(2000)
SET @test = 'SELECT '''' AS [#Test]'
PRINT @Test
EXEC (@Test)

Borislav Borissov
VFP9 SP2, SQL Server
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top