Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 UPDATE method .WRITE

Author  Topic 

mzvarik
Starting Member

1 Post

Posted - 2007-10-29 : 11:09:46
Hi, this SQL:

UPDATE [dbo].tblCommodity SET sImagePath .WRITE('abcdef', 0, 5)

gives me following error:
Cannot call methods on varchar.

I did it same way as it is in SQL Server Online Help :(

Thanks for ideas,
Martin

KenW
Constraint Violating Yak Guru

391 Posts

Posted - 2007-10-29 : 13:58:48
quote:
Originally posted by mzvarik

Hi, this SQL:

UPDATE [dbo].tblCommodity SET sImagePath .WRITE('abcdef', 0, 5)

gives me following error:
Cannot call methods on varchar.

I did it same way as it is in SQL Server Online Help :(

Thanks for ideas,
Martin





Ummm... You didn't get that out of SQL Server Books On-Line. It's not valid SQL at all.

The proper SQL syntax would be


UPDATE tblCommodity SET sImagePath = 'Whatever'


So, you're apparently mixing .NET with SQL. That doesn't work.
Go to Top of Page

Zoroaster
Aged Yak Warrior

702 Posts

Posted - 2007-10-29 : 14:21:28
Actually, the OP has the syntax correct for .write, but it is only supposed to be used for certain data types:

From an article on the subject:
"USE .WRITE (To manipulate VARCHAR(MAX) Columns)
In MS SQL Server 2005, Microsoft introduced three new data types VARCHAR(MAX), NVARCHAR(MAX) and VARBINARY(MAX) to store the large data sets. This will replace TEXT, NTEXT and IMAGE data types in future releases. To manipulate columns defined with this datatype, Microsoft also introduced the .WRITE clause. Using this clause we can replace entire column (WRITETEXT) or update portion of the column (UPDATETEXT)."

FROM BOOKS ONLINE:

To achieve the same functionality of .WRITE with other character or binary data types, use the STUFF (Transact-SQL).

Article referenced:
http://decipherinfosys.wordpress.com/2007/07/24/update-textntext-or-varcharmax-data-type-columns-in-sql-server/




Future guru in the making.
Go to Top of Page
   

- Advertisement -