Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Updating Extended properties
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00688296
Message ID:
00688323
Views:
15
You've to double single quotes inside string literal
strDetail = CHRTRAN(strDetail, ['], [''])
* Now your string looks like this
'Here is an ''example'' of what I mean'
>Hi,
>
>I have the following code to update an extended property:
>
>
>Dim cmdUpdateProp As New ADODB.Command
>Dim strSQL As String
>
>With cmdUpdateProp
>  .ActiveConnection = mconnDatabase
>  .CommandTimeout = 60
>  .CommandType = adCmdText
>End With
>
>strSQL = "EXEC sp_updateextendedproperty 'lds_Comment', '" & strDetail
> & "', 'user', dbo, 'table', '" & mstrTable & "', null, null"
>
>cmdUpdateProp.CommandText = strSQL
>cmdUpdateProp.Execute
>
>
>
>The code works fine except when strDetail contains an apostrophe. For example, if strDetail contains ...
>
>
>
> "Here is an 'example' of what I mean".
>
>
>
>Short of removing the apostrophe characters, what is the best way to handle this?
>
>I realize I could do it this way, but I'd have the same problem if the string contained a "#" ...
>
>
>
>strSQL = "EXEC sp_updateextendedproperty 'lds_Comment', #" & strDetail
> & "#, 'user', dbo, 'table', #" & mstrTable & "#, null, null"
>
>
>
>
>Al
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform