0
  1. I have T_ABC_MASTER table which has column abcData and its image type in MS Server.
  2. I want to update the following text to abcData.
  3. Please help with any SQL script, not with the program, just need a query to do it.

TEXT

<note>
  <to1>abc`xyz</to1>
  <from2>local</from2>
  <heading>dadasd</heading>
  <body>Don't forget me this weekend!</body>
</note>
Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360
  • `IMAGE`, `TEXT` and `NTEXT` are deprecated for centuries and should not be used anymore... Convert your data to `VARBINARY(MAX)`, `VARCHAR(MAX)` and `NVARCHAR(MAX)`. In your specific case you should use the **native XML type**... – Shnugo Jun 08 '17 at 08:11
  • The image type will be removed from MS SQL in the future. Should use varbinary instead. And if you need a column to contain XML, wouldn't the XML type be a better match? Also, do you need to update it from a file? – LukStorms Jun 08 '17 at 08:11
  • Thanks, both, @LukStorms I don't need to update it from a file, want as text. – Suraj Kadam Jun 08 '17 at 08:29
  • Then use [update](https://www.w3schools.com/sql/sql_update.asp)? `update t_abc_master set abcData = '' where id = @id'`. – LukStorms Jun 08 '17 at 10:07
  • And the image type is binary, so to select it as text you need to convert or cast it. For example like [this post](https://stackoverflow.com/questions/7880137/convert-image-datatype-into-varchar-in-sql-server-2008) – LukStorms Jun 08 '17 at 10:17
  • @LukStorms That it thanks , set abcData = convert(varbinary(max),convert(varchar(max), 'String to update') – Suraj Kadam Jun 08 '17 at 10:56
  • It's stored in binairy, so you don't need to convert your string for the update. Just to display it as a string again when you select it. That image type is normally intented for binairy files like jpg or gif. – LukStorms Jun 08 '17 at 11:12

0 Answers0