![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
#3
| |||
| |||
|
|
I am writing a SSIS package and have a newbie question. I am in the Execute SQL Task Editor and want to create a SQL Statement. I clicked on the Expression Builder and was creating a insert statement. One of the values to insert will have " and ' in it. The value will be gotten from an enviroment variable that contains error text. I can't figure out how to get the insert statement to not error when the values to be inserted have " or '. I would prefer to not replace the characters. Can I create named parameters? Or is there a function I can use to replace the " or '. I tried using Replace(,,) but couldn't figure out how to specify the replace character. thanks |
#4
| |||
| |||
|
|
H Chunk, Welcome to use MSDN Managed Newsgroup Support. Would you make the statement more clear? The Expression Builder dialog box provides a graphical user interface for building the expressions that property expressions use. What does the insert statement do? What is the data type of the value you want to insert? Would you please post your insert statement? Thanks! Please let me know the result with this so that i can provide further assistance. Wei Lu Microsoft Online Partner Support Get Secure! - www.microsoft.com/security ================================================== === When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue. ================================================== === This posting is provided "AS IS" with no warranties, and confers no rights. |
#5
| |||
| |||
|
|
My SQL statememt uses single quotes to delimit strings, so I need to escape them when they are contained in the data string. The expression uses double quotes, but nowhere do I have a luiteral double quote, so no worries. My expression is this - "INSERT Table VALUES('" + REPLACE(@[User: ata], "'", "''") + "')"My variable value is this- My silly string's have quotes, " double as well. The evaluated result is- INSERT Table VALUES('My silly string''s have quotes, " double as well.') Using the parameter support of the Execute SQL Task would be safer and possibly easier. String concatenation for SQL statements just means a risk of SQL injection by default. |
#6
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |