Solution:
Just set the visibility expression to:
=IIF(Fields!Comments.Value = "", IIF(Fields!Comments.Value is nothing, IIF(Len(Trim(Fields!Comments.Value)) = 0,True, False), False), False)
Sharing my daily SQL and BI challenges, tips and tricks.
=IIF(Fields!Comments.Value = "", IIF(Fields!Comments.Value is nothing, IIF(Len(Trim(Fields!Comments.Value)) = 0,True, False), False), False)
Create TABLE Employees
(
ID int IDENTITY (1,1),
Name varchar(50),
Comments varchar(MAX)
)
Insert Employees VALUES('Jason', 'Lazy Employee')
,('Yousef', NULL)
,('John', 'Anything Goes')
,('Smith', NULL)
DECLARE @Schema varchar(3)
DECLARE @Table Nvarchar(max)
DECLARE @Column varchar(30)
DECLARE @Keyword Nvarchar(30)
SELECT @Keyword = 'BMAC2120-01'
DECLARE Curs CURSOR FAST_FORWARD FOR
SELECT s.name As [Schema], o.Name AS [Table],c.Name AS [Column]
FROM sys.columns c JOIN sys.objects o ON o.object_id = c.object_id
JOIN sys.schemas s ON s.schema_id = o.schema_id
WHERE o.type = 'U' and c.collation_name IS NOT null
ORDER BY o.Name,c.Name
OPEN Curs
FETCH NEXT FROM Curs INTO @Schema,@Table, @Column
WHILE @@FETCH_STATUS = 0
BEGIN
SELECT @Table = 'SELECT top 5 [' + @Column + '],''' + @Table + ''' as [Table Name] from ' + +@Schema +'.' + @Table + ' where [' + @Column + '] LIKE ''%' +@Keyword +'%'''
print @Table
FETCH NEXT FROM Curs INTO @Schema,@Table, @Column
END
CLOSE Curs
DEALLOCATE Curs
Select 'DTColumn' = CASE WHEN len(convert(varchar(12),Time)) = 3That's it...Hope it helps someone...
THEN cast(CONVERT(char(8),Date, 112) + ' ' +
convert(varchar(10),Substring(convert(varchar(12),Time, 108),1,1) + ':' + right(Time, 2) + ':00'
,108) AS datetime)
WHEN len(convert(varchar(12),Time)) = 4
THEN cast(CONVERT(char(8),Date, 112) + ' ' +
convert(varchar(10),Substring(convert(varchar(12),Time),1,2) + ':' + right(Time, 2) + ':00'
,108) AS datetime)
End
from Table
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper
Imports Microsoft.SqlServer.Dts.Runtime.Wrapper
<Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute> _
<CLSCompliant(False)> _
Public Class ScriptMain
Inherits UserComponent
Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
Row.ErrorDescription = Me.ComponentMetaData.GetErrorDescription(Row.ErrorCode)
End Sub
End Class
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Imports Microsoft.Office.Interop
<System.AddIn.AddIn("ScriptMain", Version:="1.0", Publisher:="", Description:="")> _
<System.CLSCompliantAttribute(False)> _
Partial Public Class ScriptMain
Inherits Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
Enum ScriptResults
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
End Enum
Public Sub Main()
'opening the Variables for write and read for some of them
Dim Vars As Variables = Nothing 'var dispenser
Dts.VariableDispenser.LockForRead("User::StrExcelFilePath")
Dts.VariableDispenser.LockForWrite("User::StrExcelSheetName")
Dts.VariableDispenser.GetVariables(Vars)
Dim objExcel As Excel.Application
Dim objWorkBook As Excel.Workbook
Dim totalWorkSheets As Excel.Worksheet
Dim objWorkSheets As Excel.Worksheet
Dim ExcelSheetName As String = ""
objExcel = CreateObject("Excel.Application")
objWorkBook = objExcel.Workbooks.Open(Vars("User::StrExcelFilePath").Value)
' this code gets the names off all the worksheets
For Each totalWorkSheets In objWorkBook.Worksheets
'ExcelSheetName += totalWorkSheets.Name
Vars("User::StrExcelSheetName").Value = totalWorkSheets.Name.ToString
MsgBox(totalWorkSheets.Name.ToString)
Next totalWorkSheets
Dts.TaskResult = ScriptResults.Success
Vars.Unlock()
End Sub
End Class
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Imports System.IO.File
Imports System.IO.FileInfo
<System.AddIn.AddIn("ScriptMain", Version:="1.0", Publisher:="", Description:="")> _
<System.CLSCompliantAttribute(False)> _
Partial Public Class ScriptMain
Inherits Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
Enum ScriptResults
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
End Enum
Public Sub Main()
'opening the Variables for write and read for some of them
Dim Vars As Variables = Nothing 'var dispenser
Dts.VariableDispenser.LockForRead("User::FilePath")
Dts.VariableDispenser.LockForWrite("User::FileSize")
Dts.VariableDispenser.LockForWrite("User::FileCreationDate")
Dts.VariableDispenser.LockForWrite("User::FileLastAccessedDate")
Dts.VariableDispenser.LockForWrite("User::FileLastModifiedDate")
Dts.VariableDispenser.LockForWrite("User::FileAge")
Dts.VariableDispenser.GetVariables(Vars)
Dim f As IO.FileInfo = New System.IO.FileInfo(CStr(Vars("User::FilePath").Value.ToString))
Dim fileSize As Double = f.Length
Dim fileDate As Date = f.CreationTime
Dim fileLastAccess As Date = f.LastAccessTime
Dim fileLastMod As Date = f.LastWriteTime
Vars("FileSize").Value = fileSize / 1024 'get file size
Vars("FileCreationDate").Value = fileDate
Vars("FileLastAccessedDate").Value = fileLastAccess
Vars("FileLastModifiedDate").Value = fileLastMod
Vars("FileAge").Value = CInt(DateDiff(DateInterval.Minute, fileDate, Now()))
'only for testing to visualize the results, comment out
MsgBox("File Name: " & f.FullName & vbCrLf & _
"File Size: " & Vars("FileSize").Value.ToString & vbCrLf & _
"File Date: " & Vars("FileCreationDate").Value.ToString & vbCrLf & _
"File Age: " & Vars("FileAge").Value.ToString)
Dts.TaskResult = ScriptResults.Success
End Sub
End Class
=Left(DateSerial(Year(Now()), 1, "1").AddMonths(1).AddDays(-1) , 10)Use that for February (2)
=Left(DateSerial(Year(Now()), 2, "1").AddMonths(1).AddDays(-1) , 10)
[Column] == "0000000" ? "NULL" : (DT_WSTR,2)20 + (DT_WSTR,2)RIGHT([Column],2) + "-" + (DT_WSTR,2)SUBSTRING([Column],2,2) + "-" + (DT_WSTR,2)SUBSTRING([Column],4,2)
[Column] == (DT_WSTR,7)0000000 ? "NULL" : (DT_WSTR,2)20 + (DT_WSTR,2)RIGHT([Column],2) + "-" + (DT_WSTR,2)SUBSTRING([Column],2,2) + "-" + (DT_WSTR,2)SUBSTRING([Column],4,2)
@[User::Column] == "0000000" ? "NULL" : ( (DT_I4)(DT_WSTR,2) RIGHT(@[User::Column],2) <= 11 ? ((DT_WSTR,2)20 + (DT_WSTR,2)RIGHT(@[User::Column],2) + "-" + (DT_WSTR,2)SUBSTRING(@[User::Column],2,2) + "-" + (DT_WSTR,2)SUBSTRING(@[User::Column],4,2) ) : ( (DT_WSTR,2)19 + (DT_WSTR,2)RIGHT(@[User::Column],2) + "-" + (DT_WSTR,2)SUBSTRING(@[User::Column],2,2) + "-" + (DT_WSTR,2)SUBSTRING(@[User::Column],4,2) ))That's the only way since we have only 2 digits for the year, plus i'm calculating patient's age, so I don't think any of them over 100 years old !
(DT_DBTIMESTAMP)(SUBSTRING([date string], 7, 4) + "-" SUBSTRING([date string], 1, 2) + "-" + SUBSTRING([date string], 4, 2))