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

SQL Server Cursor Converting INT to Date

I have a column where the date is stored as an integer. This is something that we cannot change because it is a part of an older ERP system. If I could change the column type to date or datetime I would. The dates are stored as yymmdd I am trying to…
Matt Weick
  • 332
  • 6
  • 19
0
votes
1 answer

Entity Framework ExecuteSqlCommand bulk update

For performance reasons I'm trying to use Entity Frameworks ExecuteSqlCommand to bulk update data. ctx.Database.ExecuteSqlCommand(updateQuery, new object[] {newValue} ); However I'm having trouble setting the Value-field of my table. It should…
JohanLarsson
  • 475
  • 1
  • 8
  • 23
0
votes
5 answers

Convert function in sql

I am using this query to display date and time. I have used the 113 in conversion function that gave me the date format with spaces and i replaced it with a /, now i just want to take out the / that separates date from time. SELECT [ID] …
user3518032
  • 423
  • 8
  • 25
0
votes
1 answer

SQL How do you make a udf return null on error?

I'm running on SQL server 2008. I am selecting a column type varchar and converting every value into an XML type. However, the varchar values might not always be in the correct XML format. If it is not in the correct XML format, I need to print out…
-1
votes
1 answer

CAST with bigquery - Invalid NUMERIC value:

I'm trying to cast a value to covert from string to integer or numeric The string I'm trying to cast is like this: production-ross-3 but when I run SELECT CAST('production-ross-3' as numeric) it returns Invalid NUMERIC value: production-ross-3 why?…
Juanca
  • 1
  • 1
-1
votes
0 answers

How do I convert this to a number?

How do I make it a number instead of varchar? (SELECT CAST(CAST(( SELECT SUBSTRING(r.result, Number, 1) FROM master..spt_values WHERE Type='p' AND Number <= LEN(r.result) AND SUBSTRING(r.result, Number, 1) LIKE '[0-9\.]'FOR XML…
-1
votes
1 answer

Is there SQL function to update table by replacing one column with data (DIFFERENT TYPE) from another column (in a related table)?

I run into a problem in SQL, I don't know how to update table A by replacing its column "Edu" with another column "Level" of table B. Two tables have a relationship in column "Edu" Different data types bt "Edu" (number) & "Level" (Short Text) Can…
David
  • 1
-1
votes
2 answers

Convert string to datetime - SQL

I have a string parsed from XML which represents datetime. String format is: '20200915114000' - (YYYYMMDDhhmmss) Is there a function in SQL Server to convert or parse this string to datetime or should I split string manually and concatenate it into…
SZenko
  • 9
  • 3
-1
votes
2 answers

Int to date in SQL

I try to convert the column [policyeffective_date] which looks like YYYYMMDD (for example 20190430) into a date in SQL Server. I tried a few solutions find on the forum, but none worked. Currently I have the following code and errors: SELECT …
nimavancouver
  • 97
  • 1
  • 8
-1
votes
2 answers

Sql Server using Convert and Replace together in the same statement

I wanted to double check my logic for a query in SQL Server. The idea is that I am able to feed the following values and it will make sure the result is a decimal with four trailing digits. Possible values for @LABORQTY: 1,200 1,200.42 1200…
C. Ayers
  • 53
  • 1
  • 9
-1
votes
1 answer

I am debugging a stored procedure and trying to understand a Convert statement with Case

SELECT AcquistionDate = CONVERT(NVARCHAR, CASE WHEN D.CalendarDate NOT IN ('01/01/1900','12/31/9999') THEN D.CalendarDate WHEN…
-1
votes
2 answers

Microsoft T-SQL: Can I CONVERT smallint to varchar

It may just be me, but... Despite the fact that most sql developers may consider cast & convert to be very basic stuff, and that may be true, I find Microsoft's documentation page on CAST & CONVERT to be one of the most hideous,…
Isaac
  • 351
  • 1
  • 4
  • 21
-2
votes
1 answer

set Nonnumeric as they come in to null

I have a paymentHistory field that is an int that tracks how many payments have been made from the account before. I have a source that is varchar for this field and someone enters 1.11 by accident on the front end. I can't change my source but I…
an1234
  • 165
  • 1
  • 12
-2
votes
1 answer

Time in datatime field

I have a field that stores the date and time but need to extract this so it only shows the time but shows the date as 01/01/1900. I can extract the time using the below but need to include the data of 01/01/1900 convert(varchar(12), w.created, 114)
Raehef
  • 1
  • 1
1 2 3 4 5 6
7