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 |
|
rajasekhar857
Constraint Violating Yak Guru
396 Posts |
Posted - 2010-01-20 : 05:11:48
|
| this is my querySELECT @PLocationName = @PLocationName + ISNULL(CAST(LOCATION_ID AS VARCHAR) + '::' + LOCATION_NAME,'~~') + '~~' getting output as 1501::USA~~1502::CANADA~~want output to be like1501::USA~~1502::CANADAwhat needs to be modified in above query? |
|
|
Kristen
Test
22859 Posts |
Posted - 2010-01-20 : 05:32:03
|
| Remove the + '~~'from the end of your SELECT line |
 |
|
|
rajasekhar857
Constraint Violating Yak Guru
396 Posts |
Posted - 2010-01-20 : 05:42:22
|
| then am getting output as 1501::USA 1502::CANADA where ~~ is missing |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2010-01-20 : 06:01:27
|
| Ah, sorry, I see now that you are concatenating several rows.If you can start with @PLocationName being NULL, rather than "empty string", then:SELECT @PLocationName = COALESCE(@PLocationName + '~~', '') + ISNULL(CAST(LOCATION_ID AS VARCHAR) + '::' + LOCATION_NAME,'~~')should do the trick.You will get "~~~~" whenever Location_ID or Location_Name is null |
 |
|
|
rajasekhar857
Constraint Violating Yak Guru
396 Posts |
Posted - 2010-01-20 : 06:09:16
|
| THANKS |
 |
|
|
|
|
|