Is there a way to remove specific characters from SQL Server Column [closed] - sql

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I have a database table that contains a column for pricing.
Its very old, so it was written before i understood datatypes. so we are using varchar for a money value.
Ive noticed some columns have $ in them, so what I'm wondering is... is there a way with SQL Server to perform an update of the table and remove any instances of non numeric characters or at the very least remove the $ from the string in the columns in one go ?
I hope this is possible.

Update tbl
SET price = replace(price, '$', '')
Here is the replace definition

Related

SQL LIKE doesn't find obvious matches [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I'm writing the following SQL query:
SELECT *
FROM OS
WHERE OS.VERSION LIKE '%1%';
In my table there are rows with char 1 in it. However, it returns an empty result.
I changed a little bit the LIKE clause to different values, but it still doesn't work.
What can I do to fix that?
Try double-quotes and * for wildcards. You are using Oracle syntax instead of Access syntax.
LIKE operation can't be used with columns of integer type. I assume that OS.Version is of integer type?
Edit1:
If you are referring to MS Access then you have to do the LIKE with stars (*) instead of %.

Writing Query in Microsoft Access, error in field description [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Improve this question
I am writing a query in Microsoft Access. and I am getting a syntax error in "field description". Here is the code:
CREATE TABLE CONS
(
Com_Type text,
Cons_2008 double(10,2),
Cons_2009 double(10,2),
Cons_2010 double(10,2)
);
Thanks!
Specify the length of the text field, unless you want a field of length 255 when called through an Access query or a Memo field when called through an ADO connection.
Com_Type Text(50),
The Double type has no size and scale specifications. Either drop them or use the Decimal type.
Cons_2008 Double
Or
Cons_2008 Decimal(10, 2)
Note: See this SO answer for a limitation related to the decimal type.
When using the Double type, you can still specify a format in the TextBoxes linked to this table column. That way you can force the display of 2 decimals.
CREATE TABLE CONS
(
Com_Type TEXT(150),
Cons_2008 DOUBLE,
Cons_2009 DOUBLE,
Cons_2010 DOUBLE
);

Datatype supported in Oracle but not in Excel [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am writing a macro which pulls data from Oracle and displays in Excel. In Oracle DB we have a custom table with a column Named "Calculated_Quantity". The datatype of this column is BINARY_DOUBLE.
When I query for this column in Oracle using SQL developer I am able to view the data. However when I write the same query in Excel macro, I get the error as "Data Type is not Supported".
Any suggestions what do I need to do here. If needed I can post my query here.
Thanks,
You should use CAST (or CONVERT for some DBMSs) to convert the data to a supported datatype.
SELECT
CAST(CALCULATED_QUANTITY AS NUMBER(10)) AS Qty
FROM
DW_STG_FSN.SAMPLE

how to select specific value from text column containing an xml string? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I'm using sql server 2008 r2, I have my_table containing my_col of type text which contains xml, I want to select an attribute from the root element of that xml and convert it to a bit type (the attribute takes the value 'true'/'false') when I select a particular row from the table, rather than selecting out the whole string and passing it back to the server as its quite a long string and I could be selecting many rows at a time. I'm not too good with regex or sql. Here is the format of my text/xml column:
<rootElementName <!--lots of attributes--> Recommended="false"><!--...lots of stuff in here...--></rootElementName>
I just want to select out 0 for rows that have Recommended="false" and 1 for Recommended="true".
First you have to convert your text column to an xml type and then do the XQuery.
SELECT convert(XML,my_col).value('(/rootElementName/#Recommended)[1]', 'bit') rec
FROM my_table
I looked up/adapted stuff from this question and this question.
The conversion idea came from here
Here is a working SqlFiddle

Get me a SQL quesry to check whether the two table data contents are equal? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am having two table A and B of same structure.Both tables is loaded with data.I just want the mismatched row of two tables.,,
I'm certain you could do some gigantic JOIN query for each column and then issue a NOT IN over the result but a simple, pragmatic solution is to:
Write a query that orders the data on several columns (or all)
Export the query executed on each table to a separate text file
Use diff to compare the files with each other
Depending on the RDBMS vendor you may have other options you could consider as well.