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 |
javahf
Starting Member
34 Posts |
Posted - 2011-04-07 : 00:13:34
|
I have inquiry that was developed with the help here . it works great It is :SELECT o.Orderid,o.OrderStatus,o.BillingLastName,o.BillingCity,o.BillingState,o.PaymentAmount,o.TotalShippingCost, o.SalesTax1 ,STUFF((SELECT ',' + ProductName FROM Orderdetails d WHERE o.Orderid = d.Orderid FOR XML PATH('')),1,1,'') as ProductName,STUFF((SELECT ',' + CAST(d.Options AS VARCHAR(100)) FROM Orderdetails d WHERE o.Orderid = d.Orderid FOR XML PATH('')),1,1,'')AS OptionsFROM Orders owhere o.OrderID > 1179However in the field Options on our data base have some control characters so options looks like for example : [</i>Handlebars:Riser + Oury Grips][</i>Size:55][Add Tire Set:No Extra Tire Set][Pedal Type:Standardwe want it to look like [Handlebars:Riser + Oury Grips][Size:55][Add Tire Set:No Extra Tire Set][Pedal Type:StandardHow can we get rid of < and /i> in our data when we are reading the table |
|
javahf
Starting Member
34 Posts |
Posted - 2011-04-07 : 00:19:31
|
this is how data looks [</i>Handlebars:Riser + Oury Grips][</i>Size:55][Add Tire Set:No Extra Tire Set][Pedal Type:Standard, |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-04-07 : 00:25:09
|
use replace() function to remove it KH[spoiler]Time is always against us[/spoiler] |
 |
|
javahf
Starting Member
34 Posts |
Posted - 2011-04-07 : 00:26:18
|
quote: Originally posted by khtan use replace() function to remove it KH[spoiler]Time is always against us[/spoiler]
Thanks - But I am novice can you show where that replace goes ? |
 |
|
javahf
Starting Member
34 Posts |
Posted - 2011-04-07 : 00:36:46
|
quote: Originally posted by khtan use replace() function to remove it KH[spoiler]Time is always against us[/spoiler]
Can you assist and show how is doen - i just want the output to be replaced in the report not actual data .Thanks |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-04-07 : 00:42:22
|
see the link that in my last post for the details.basically it is something likereplace ( column_name , '</i>', '') KH[spoiler]Time is always against us[/spoiler] |
 |
|
javahf
Starting Member
34 Posts |
Posted - 2011-04-07 : 00:51:04
|
quote: Originally posted by khtan see the link that in my last post for the details.basically it is something likereplace ( column_name , '</i>', '') KH[spoiler]Time is always against us[/spoiler]
Thanks i got it - but where do you place it in the inquiry - no matter where I place it I get syntax error |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
javahf
Starting Member
34 Posts |
Posted - 2011-04-07 : 02:23:34
|
quote: Originally posted by khtan "no matter where I place it I get syntax error"please show us your query KH[spoiler]Time is always against us[/spoiler]
see below. this where I put the Replace function - I know is wrong - but do not know where it goes SELECT o.Orderid,o.OrderStatus,o.BillingLastName,o.BillingCity,o.BillingState,o.PaymentAmount,o.TotalShippingCost, o.SalesTax1 ,STUFF((SELECT ',' + ProductName FROM Orderdetails d WHERE o.Orderid = d.Orderid FOR XML PATH('')),1,1,'') as ProductName,STUFF((SELECT ',' + CAST(d.Options AS VARCHAR(100)) FROM Orderdetails d WHERE o.Orderid = d.Orderid FOR XML PATH('')),1,1,'')AS OptionsReplace "d.options,'</i>', '')FROM Orders owhere o.OrderID > 1179 |
 |
|
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2011-04-07 : 05:41:24
|
see below. this where I put the Replace function - I know is wrong - but do not know where it goes SELECT o.Orderid,o.OrderStatus,o.BillingLastName,o.BillingCity,o.BillingState,o.PaymentAmount,o.TotalShippingCost, o.SalesTax1 ,STUFF((SELECT ',' + ProductName FROM Orderdetails d WHERE o.Orderid = d.Orderid FOR XML PATH('')),1,1,'') as ProductName,STUFF((SELECT ',' + CAST(Replace(d.Options,'</i>','') AS VARCHAR(100)) FROM Orderdetails d WHERE o.Orderid = d.Orderid FOR XML PATH('')),1,1,'')AS OptionsFROM Orders owhere o.OrderID > 1179Corey I Has Returned!! |
 |
|
|
|
|
|
|