I
I
Ivan Vishnevsky2018-08-01 11:45:15
SQL
Ivan Vishnevsky, 2018-08-01 11:45:15

How to convert field type in TSQL?

There is a storage that pulls all lines with a certain status from the database. The problem is that the table has a field called "guid", which has the type "text", while in the code we have the type "uniqueidentifier", respectively, the program crashes into an exception. It is necessary to convert the text type from the base during the select and return the uniqueidentifier.
Now the code in the storage is as simple as possible:

SELECT data.* FROM [my_table] data 
  WHERE STATUS_Code = 1

Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex, 2018-08-01
@forgetable

https://docs.microsoft.com/en-us/sql/t-sql/functio...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question