Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
kamii47
Constraint Violating Yak Guru
353 Posts |
Posted - 2008-08-29 : 07:38:06
|
| CREATE FUNCTION [dbo].[GetCommaSeperatedString](@StationCode INT)RETURNS VARCHAR(MAX)ASBEGINdeclare @listStr As VARCHAR(MAX)-- Fill the table variable with the rows for your result setSELECT @listStr = COALESCE(@listStr+',' , '') +CASE CategoryCodeWHEN 'A' THEN 'String'WHEN 'B' THEN 'Double'ENDFROM StationCategoryLink WHERE StationCode = @StationCodeRETURN @listStrendOutput for this query is String,Double.My question is when we add somemore CategoryCode columns in StationCategoryLink Table, like, A1, A2, B1,B2. How can i get the output as String,String1,String2,Double,Double1,Double2.Can you please tell me how i can get the Comma seperated string for dynamically added columns.Kamran ShahidSr. Software Engineer(MCSD.Net,MCPD.net)www.netprosys.com |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
|
|
|
|
|