3 rules
3 rules

Reputation: 1409

Remove slash from data and create new field in select query in sql server

I am using SQL SERVER for database related operation in my application.

I have created one view that contains following data:

enter image description here

I want one new field with this view and that field should contains the same data as you can see in Size column in the above view.

But I have to remove coming slash from that data.

Is there any query or function to remove slash from the data in SQL SERVER?

Upvotes: 3

Views: 6801

Answers (3)

ishan joshi
ishan joshi

Reputation: 270

Try to use SQL replace function to replace single character

example:

select Replenter code hereace(ColumnName, '/', '') as NewColumnName,* from  TableName

Upvotes: 2

Tim Biegeleisen
Tim Biegeleisen

Reputation: 521534

Just select the columns you need from the view, but use REPLACE() on the Size column to remove the forward slash:

SELECT [SizePropId],
       [VendorId],
       [VendorName],
       [ModelId],
       [Model],
       [SizeId],
       REPLACE([Size], '/', ''), AS [Size]
       [ProductCode],
       [CategoryId],
       [LoadIndex_Spec],
       [RunFlate],
       [ListPrice]
FROM yourView

Upvotes: 3

Vijunav Vastivch
Vijunav Vastivch

Reputation: 4191

Do it like this in Query:

declare @sam varchar(50);
set @sam= 'this/is/sample';

select replace(@sam,'/','');

Upvotes: 3

Related Questions