Showing posts with label executing. Show all posts
Showing posts with label executing. Show all posts

Friday, March 9, 2012

How can I insert (Apostrophe) into sql table field ?

How can I insert ' (Apostrophe) into sql table field ?

Insert Into Table(Field) Values(?)

After executing sql statement above, I want to see ' (apostrope) in field.

Thanks

Replace every single apostrophe with two apsotrophes which "escapes" the apostrophe for eintry into the database.

Also, if you parameterize your query this escaping will be handled for you automatically,

|||

Hi Stiletto,

Thanks for your information.If I want to replace 1 apostrophe with 2 apostrophe using with REPLACE command in SQL 2005.

REPLACE(sql expression, 1 apostrope, 2 apostrope)

How can I do this with SQL REPLACE statement.

Thanks

|||

I think that you have to escape it before it gets to the SQL engine. So, you'd use the string.Replace() method on your SQL string before building your SqlCommand object.

Monday, February 27, 2012

How can I get the package name within a script?

Greetings,

I need to programmatically grab the name of the executing package so that it can be used in logging. Does someone have a code sample for this?

Thanks!

Use the system variable, PackageName.|||

Thanks.

For those who may benefit from a code sample:

Dim source AsString

Dim vars As Variables

Dts.VariableDispenser.LockOneForRead("System:Stick out tongueackageName", vars)

source = vars("PackageName").Value.ToString()

|||Also the other options (perhaps not for this example) are to use a derived column to add the system variable to the data flow, or in the control flow, using an Execute SQL task, you can map the variable to a parameter in the SQL statement.