|
SSIS expression
1. Calculate the number of times a substring appears in a string
Number of occurrences of "." In the Liang. Liang string
Set the string variable to v_str
-
SQL code
-
Len(@[User: v_str])-(Len(Replace(@[User: v_str],".",""))/Len("."))
|
2. If the current date is Saturday, the string "break" is returned; otherwise, the string "work" is returned.
-
SQL code
-
datepart (" weekday ", getdate () = 7 || datepart (" weekday ", getdate () = 1 ? "Break": "work"
3. Return date format
Yyyy-mm-dd hh: mm: SS
-
-
SQL code
-
(Dt_wstr, 4 ) Year ( Getdate ()) + " - " + Right (" 00 " + (Dt_wstr, 2 ) Month ( Getdate ()), 2 ) + " - " + Right (" 00 " + (Dt_wstr, 2 ) Day ( Getdate ()), 2 ) + "" + Right (" 00 " + (Dt_wstr, 2 ) Datepart ("Hour ", Getdate ()), 2 ) + ":" + Right (" 00 " + (Dt_wstr, 2 ) Datepart ("Minute ", Getdate ()), 2 ) + ":" + Right (" 00 " + (Dt_wstr, 2 ) Datepart ("Second ", Getdate ()), 2 )
Mm/DD/YYYY
-
-
SQL code
-
Right (" 00 " + (Dt_wstr, 2 ) Month ( Getdate ()), 2 ) + " / " + Right (" 00 " + (Dt_wstr, 2 ) Day ( Getdate ()), 2 ) + " / " + (Dt_wstr, 4 ) Year ( Getdate ())
4. in SSIs expressions, up to 4000 characters are returned in. (dt_wstr, <length>) and (dt_str, <length>, <code_page>.
Replicate ("X", 4000) successful
Replicate ("X", 4001) failed
5. In fact, SSIS expressions are almost the same as SQL Server expressions. Therefore, if you are familiar with SQL Server, SSIS expressions are easy to use.