You use a Microsoft SQL Server database that contains a table named BlogEntry that has the following columns:
Id is the Primary Key.
You need to append the -This is in a draft stage- string to the Summary column of the recent 10 entries based on the values in EntryDateTime.
Which Transact-SQL statement should you use?
A. UPDATE TOP(10) BlogEntry
SET Summary.WRITE(N This is in a draft stage, NULL, 0)
B. UPDATE BlogEntry
SET Summary = CAST(N This is in a draft stage as nvarchar(max))
WHERE Id IN(SELECT TOP(10) Id FROM BlogEntry
ORDER BY EntryDateTime DESC)
C. UPDATE BlogEntry
SET Summary.WRITE(N This is in a draft stage, NULL, 0) FROM (
SELECT TOP(10) Id FROM BlogEntry ORDER BY EntryDateTime DESC) AS s
WHERE BlogEntry.Id = s.ID
D. UPDATE BlogEntry
SET Summary.WRITE(N This is in a draft stage, 0, 0)
WHERE Id IN(SELECT TOP(10) Id FROM BlogEntry
ORDER BY EntryDateTime DESC)
Explanation:
The UPDATE SET colum_name.WRITE (expression,@Offset,@Length) command specifies that a section of the value of column_name is to be modified. expression replaces @Length units starting from @Offset of column_name.
If @Offset is NULL, the update operation appends expression at the end of the existing column_name value and @Length is ignored.
References: https://msdn.microsoft.com/en-us/library/ms177523.aspx