Questions tagged [sql-convert]

SQL `CONVERT()` is a general function that converts an expression of one data type to another.

SQL CONVERT() is a general function that converts an expression of one data type to another.

Note that this is a non-standard function. The ANSI/ISO SQL standard has the CAST() function.

Reference

104 questions
0
votes
2 answers

nvarchar date won't convert to date time

I can't seem to find an applicable solution to my issue. I am trying to pass through an NVARCHAR date and then convert it. When trying to trouble shoot my issue that I am getting: Conversion failed when converting date and/or time from character…
ggiaquin16
  • 165
  • 1
  • 15
0
votes
0 answers

Arithmetic overflow error converting expression to data type datetime when running dynamic sql

I have seen a couple solutions to this SQL error(8115) but none seems to work for me. I think its because I am using dynamic SQL script. I dynamically pull data from multiple servers that have the same structure and insert into a central table. The…
Castell James
  • 329
  • 6
  • 23
0
votes
1 answer

SQL Server to Oracle conversion

I am unable to convert this SQL Server code to Oracle code. I am not SQL expert, can anyone help in converting this code to Oracle compatible. Declare @lvl as int Declare @rows as int DECLARE @foo as Table( KV_MANAGERNR int, KV_PERSONNR…
0
votes
4 answers

Conversion of varchar into Datetime

Why does the following code work: CAST(DateOfAction AS Date) but this code does not: CAST(DateOfAction AS Datetime) note: DateOfAction is a varchar field Can someone explain this and give the right code?
0
votes
1 answer

Conversion Failed Nvarchar to INT

I have two tables called Entry_Data and Data Entry_Data has three columns: EntryID DataID DataTypeID 1       50       18 2       49       59 30      28      16 Data has two columns: DataID Value 50      0x00000000033654 49 …
Oliver843
  • 25
  • 1
  • 8
0
votes
1 answer

Convert columnB value if columnA = X in SQL

Overview I have an inner join statement that links 5 tables together which is working fantastically if i do say so myself. Now one of the values returned is in Hex and it is in a column named Value however, the Value column also contains other…
Oliver843
  • 25
  • 1
  • 8
0
votes
1 answer

How to convert numeric number into datatime

I need help to convert a bigint value into a datetime value using SQL Server. Example value 634254092190100000 How to convert to datetime value? So far this is what I have but getting an error: Arithmetic overflow error converting expression to…
Jason312
  • 197
  • 1
  • 1
  • 10
0
votes
2 answers

Converting SQL Decimal Date to DD-MM-YYYY HH:MM:SS format

I have a date/ time field in my database with the type set to 'decimal'. When querying the date/ time field using the below query: SELECT my_date_time_field FROM my_table It returns the following result (an example): 1323977278 This is meant to…
0
votes
1 answer

Using Convert function to change datatype of computed column

I know about the question found at How do I control the datatype of a computed column? I add a column by using the followed code. However, there is no datatype found in the Object Explorer > Design. I need the end result employment to show up…
Tim Wilcox
  • 1,275
  • 2
  • 19
  • 43
0
votes
1 answer

SQL update query fails to convert nvarchar to integer

The following query should return records that consist of 3 or 4 digits that are converted from nvarchar to integer and are lower than 1200. Instead of a desired result, an error returns stating: Conversion failed when converting the nvarchar value…
user2237168
  • 305
  • 1
  • 3
  • 17
0
votes
0 answers

Converting varchar to date for range SQL

I am trying to convert from a varchar field in TSQL to Date - The error I'm getting is conversion of varchar to date in US m/d/y mm/dd/yy format resulted in an index out of range This is my query select * from test_revision2 where…
rahulchawla
  • 170
  • 1
  • 3
  • 20
0
votes
1 answer

Convert varchar into numeric in SQL Server stored procedure

I'm writing a stored procedure for INSERT and I want to convert a varchar column into numeric so when I'm writing this code CONVERT(NUMERIC(18,2), CAST([Outcost] AS FLOAT)) then it throws this error Incorrect syntax near the keyword…
0
votes
4 answers

Failed conversion from nvarchar to datetime

I am trying to convert an nvarchar date into a date time, but this error occurs: I have tried multiple ways including CAST and Convert (as code below) with no avail. Any suggestions ? Date Format : Wed, 19 Jul 2017 16:23:38 +0000 Code: INSERT INTO…
Chanter
  • 99
  • 1
  • 12
0
votes
3 answers

SQL error while converting varchar to int by joining two tables

I need to find missing numbers in my database. I am comparing two databases, tempdb created in query with numbers 1 - 999 and MYDAT. MYDAT looks like: +-------+ | id | +-------+ | A-001 | | A-002 | | A-004 | | A-... | | A-952 | | A-...…
user2463808
  • 179
  • 11
0
votes
3 answers

SQL - char field with date - how to search between two dates

I have simple problem with SQL query.. I would like to search fields, where dates begin and ends in specific date and time. Field is defined as CHAR and have structure: DD.MM.YYYY hh:mm:ss and I cannot change it. I tried to declare some variables…
Frihu
  • 43
  • 9