Convert varchar to be float [closed] - sql

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I got this error when trying to convert varchar to float using cast or convert:
Error converting data type varchar to float.
Can someone please help?

You can use try_convert():
select try_convert(float, col)
If this fails, the functions returns NULL but the query continues processing.

Related

Comparison with '{0}' in SQL SELECT [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 months ago.
Improve this question
I have to take over old colleague's code and trying to understand this one SQL statement like below:
SELECT * FROM my_table WHERE date_key = '{0}'
Column date_keycontains int values such as 20220712, 20220120, etc.
The first guess is that SELECT statement filters for rows with 0 value in column date_key. However, when running that line of code, I receive this error :
SQL Error [100038] [22018]: Numeric value '{0}' is not recognized
What exactly does that line of code do?
That looks like a placeholder, replaced with an actual value in code when calling the query.
See similar What is {0},{1},{2},{3} in the SQL query

Why does insertion command is giving an error about new operator? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
I am bit new this, can someone please help me to rectify this error. I am using sqllite:
The table name in the INSERT is wrong. And the column list must match the values list.
Try INSERT correct table name (target columns) Values (vales for each column).
Additionally if you omit any columns the insert will fail unless they have defaults.

DATE BETWEEN issues [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
Trying to select data only between a range.
select ITM_NBR,
TOT_IVO_ITM_QTY,
Count(*)
FROM dataset
WHERE
bus_dt BETWEEN '2-14-2020' AND '2-15-2021'
Failed conversion to numeric value. Tried without single ticks and it returned zero rows which makes me believe that the column is stored as a VARCHAR. Tried Casting the bus_dt column into a date format.
CAST(bus_dt AS DATE FORMAT 'mm/dd/yyyy') BETWEEN 2/14/2020 AND 2/15/2021
Again failed conversion.
I feel as if I’ve tried every combination and can’t get anything to work of casting and putting the date values in yyyy-mm-dd, mm/dd/yyyy, etc. formats.
And also when I HELP VIEW to see the column type I get “?”.
Kind of at a loss right now.
After I thought I tried everything I figured it out....
I was not formatting my date literals correctly .... faceplam
DATE'yyyy-mm-dd'....

What is the correct type for ##ROWCOUNT? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
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.
Closed 6 years ago.
Improve this question
I am writing a stored procedure in SQL Server 2008 and I need to count the rows affected by a query.
DECLARE
#my_rows AS INT
and then
SELECT *
FROM a table
WHERE some conditions
SET #my_rows=##ROWCOUNT
if I declare my_rows as varchar it works correctly but if I declare as INT I get the following error:
Arithmetic overflow error converting expression to data type tinyint.
What is the correct type to declare? I think that the numer of rows could only be integer and betweeb 0 and the total numer of rows.
As Per MSDN the correct return type of ##ROWCOUNT is int.
SQL code is fine, working properly even #my_rows declared as tinyint.

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