How can i get this query on SQL server? it's cause an error: This is MySQL version
SELECT HEX(c1) FROM t1;
This simple example work:
/****** Script for SelectTopNRows command from SSMS ******/
SELECT CAST('example data' AS VARBINARY) AS Body2
But this sql dosnt work.
/****** Script for SelectTopNRows command from SSMS ******/
SELECT TOP 10 [NewsID]
,[upTitle]
,[Title]
,[Summary]
,CAST(Body AS VARBINARY) AS Body2
,[LargePic]
,[PublishDate]
FROM [Upgrade_News].[dbo].[News_News]
That's give me this error
Msg 529, Level 16, State 2, Line 6
Explicit conversion from data type ntext to varbinary is not allowed.
I need to convert ntext
to HEX data on select. it's not an integer or short string.
There's no direct conversion from ntext
to varbinary
, so convert to nvarchar(max)
first.
SELECT CAST(CAST(Body AS NVARCHAR(MAX)) AS VARBINARY) AS Body2
ntext
was deprecated with SQL2005. Avoid using it if possible.
https://msdn.microsoft.com/en-us/library/ms178158%28v=sql.90%29.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With