Showing posts with label dear. Show all posts
Showing posts with label dear. Show all posts

Wednesday, March 28, 2012

How can i check file size equal zero or not with scrip task ?

Dear all,

Could you tell me which code of vb scrip that i can check file size as follow ?

Dim FSO, Fyl
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Fyl = CreateObject("File")

If FSO.FileExists("C:\temp\lcbseg.log") Then
Set Fyl = FSO.GetFile("C:\temp\lcbseg.log")
If Fyl.Size > 0 Then
Main = DTSStepScriptResult_ExecuteTask
Else
Main = DTSStepScriptResult_DontExecuteTask
End If
End if

Thanks

Best regards,

Kusuma

You need to do this in two stages, since there is no workflow script anymore.

Here is a sample for nthe Script Task. It uses a variable called FileSize, into which it stores the file size, surpirse!

Public Sub Main()

Dim info As System.IO.FileInfo = New System.IO.FileInfo("C:\File.txt")

Dim variables As New Variables

Dts.VariableDispenser.LockOneForWrite("FileSize", variables)

variables(0).Value = info.Length

variables.Unlock()

Dts.TaskResult = Dts.Results.Success

End Sub

Now you would use a precedenc constraint from the sript task to the next task, but be sure to include an expression. Double-click to get the UI, and try and expression like this-

@.[Use::FileSize] > 0

|||

I've tried to follow your code DarrenSQLIS, but it has the error "FileSize" for read/write access with error 0xC0010001 "The variable cannot be found. how can i fix this problem?

So i've some questions where can i declare FileSize variable. It's on SSIS menu=> varible,isn't it? and what's type of FileSize variable. For next what's property of expresstion to use @.[Use::FileSize] > 0.

Many thanks.

Best Regards,

Kusuma

|||I know you asked how do check for a file size equal to non zero in a script task, which can certainly be done with a script task as Darren illustrates.

Another technique for checking file existence and size simultaneously is use of "WMI Data Reader Task" with WQL. Use of the WMI data reader task will require a WMI connection manager, which is quick simple to configure, and available through the task's UI.

For example, the following WQL query checks for the existence and size of c:\boot.ini. simultaneously.

Select FileSize From CIM_Datafile Where Name = 'C:\\boot.ini'

After the WMI task, a downstream task can constrained by the following expression, which evaluates to true only for an existent, non zero byte file.

@.FileLength > "0\r\n"

NOTE, in this case, @.FileLength is a string variable, unlike the script task case. The reason the variable for file size is a string rather than a uint64 is that the WMI Data Reader task writes string and/or object variable types. The backslash is a special character to WMI, and as such is doubled up (escaped) in the WQL query.|||

KUS wrote:

Dear all,

Could you tell me which code of vb scrip that i can check file size as follow ?

Dim FSO, Fyl
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Fyl = CreateObject("File")

If FSO.FileExists("C:\temp\lcbseg.log") Then
Set Fyl = FSO.GetFile("C:\temp\lcbseg.log")
If Fyl.Size > 0 Then
Main = DTSStepScriptResult_ExecuteTask
Else
Main = DTSStepScriptResult_DontExecuteTask
End If
End if

Thanks

Best regards,

Kusuma

|||Hey hi . Could you tell me a VB code so that I can check a file size in a folder and mail to abc@.xyz.com if the file size is less than 10MB?|||First of all read the code above, it shows you how to get the file size into a variable. Then use an SMTP Send Mail Task to send the mail. To restrict the email to only files < 10MB, add an expression on the precendence constraint between the Script Task and Mail Task, @.Var < 10000

How can i check file size equal zero or not with scrip task ?

Dear all,

Could you tell me which code of vb scrip that i can check file size as follow ?

Dim FSO, Fyl
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Fyl = CreateObject("File")

If FSO.FileExists("C:\temp\lcbseg.log") Then
Set Fyl = FSO.GetFile("C:\temp\lcbseg.log")
If Fyl.Size > 0 Then
Main = DTSStepScriptResult_ExecuteTask
Else
Main = DTSStepScriptResult_DontExecuteTask
End If
End if

Thanks

Best regards,

Kusuma

You need to do this in two stages, since there is no workflow script anymore.

Here is a sample for nthe Script Task. It uses a variable called FileSize, into which it stores the file size, surpirse!

Public Sub Main()

Dim info As System.IO.FileInfo = New System.IO.FileInfo("C:\File.txt")

Dim variables As New Variables

Dts.VariableDispenser.LockOneForWrite("FileSize", variables)

variables(0).Value = info.Length

variables.Unlock()

Dts.TaskResult = Dts.Results.Success

End Sub

Now you would use a precedenc constraint from the sript task to the next task, but be sure to include an expression. Double-click to get the UI, and try and expression like this-

@.[Use::FileSize] > 0

|||

I've tried to follow your code DarrenSQLIS, but it has the error "FileSize" for read/write access with error 0xC0010001 "The variable cannot be found. how can i fix this problem?

So i've some questions where can i declare FileSize variable. It's on SSIS menu=> varible,isn't it? and what's type of FileSize variable. For next what's property of expresstion to use @.[Use::FileSize] > 0.

Many thanks.

Best Regards,

Kusuma

|||I know you asked how do check for a file size equal to non zero in a script task, which can certainly be done with a script task as Darren illustrates.

Another technique for checking file existence and size simultaneously is use of "WMI Data Reader Task" with WQL. Use of the WMI data reader task will require a WMI connection manager, which is quick simple to configure, and available through the task's UI.

For example, the following WQL query checks for the existence and size of c:\boot.ini. simultaneously.

Select FileSize From CIM_Datafile Where Name = 'C:\\boot.ini'

After the WMI task, a downstream task can constrained by the following expression, which evaluates to true only for an existent, non zero byte file.

@.FileLength > "0\r\n"

NOTE, in this case, @.FileLength is a string variable, unlike the script task case. The reason the variable for file size is a string rather than a uint64 is that the WMI Data Reader task writes string and/or object variable types. The backslash is a special character to WMI, and as such is doubled up (escaped) in the WQL query.
|||

KUS wrote:

Dear all,

Could you tell me which code of vb scrip that i can check file size as follow ?

Dim FSO, Fyl
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Fyl = CreateObject("File")

If FSO.FileExists("C:\temp\lcbseg.log") Then
Set Fyl = FSO.GetFile("C:\temp\lcbseg.log")
If Fyl.Size > 0 Then
Main = DTSStepScriptResult_ExecuteTask
Else
Main = DTSStepScriptResult_DontExecuteTask
End If
End if

Thanks

Best regards,

Kusuma

|||Hey hi . Could you tell me a VB code so that I can check a file size in a folder and mail to abc@.xyz.com if the file size is less than 10MB?|||First of all read the code above, it shows you how to get the file size into a variable. Then use an SMTP Send Mail Task to send the mail. To restrict the email to only files < 10MB, add an expression on the precendence constraint between the Script Task and Mail Task, @.Var < 10000

Monday, March 26, 2012

How can i chang server level collation

Dear All,
How can i change my SQL server level collation.
Thank's in advance.
Faheem Latif
Network Solutions PVT LTM.
Pakistan.You can rebuild the master database. There is a bug with this if you use
sourcefiles off the cd, so have a look at these articles:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/howtosql/ht_install_8w8p.asp
http://support.microsoft.com/default.aspx?scid=kb;en-us;273572
Be very careful with this, as you'll need to have scripts of logins, linked
servers, messages and anything else you have in master and corresponding
scripts of MSDB's objects, all of which can then be recreated afterwards.
Actually you might not need to jump through all these hoops - why is it that
you want to change the collation?
Rgds,
Paul Ibison SQL Server MVP, www.replicationanswers.com
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)

How can i chang server level collation

Dear All,
How can i change my SQL server level collation.
Thank's in advance.
Faheem Latif
Network Solutions PVT LTM.
Pakistan.
You can rebuild the master database. There is a bug with this if you use
sourcefiles off the cd, so have a look at these articles:
http://msdn.microsoft.com/library/de...stall_8w8p.asp
http://support.microsoft.com/default...b;en-us;273572
Be very careful with this, as you'll need to have scripts of logins, linked
servers, messages and anything else you have in master and corresponding
scripts of MSDB's objects, all of which can then be recreated afterwards.
Actually you might not need to jump through all these hoops - why is it that
you want to change the collation?
Rgds,
Paul Ibison SQL Server MVP, www.replicationanswers.com
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)

Friday, March 9, 2012

How ASP into ASP.NET with SQL server 2000

Dear All,
I'm new on ASP.NET, now trying convert ASP with SQL 2000 into ASP.NET SQL 2000 server.
I facing a problem while read, write, update the SQL command.
like,
rs.open("Select * from tableA"),ocoon, permission,permission
If rs.eof then
rs.addnew()
rs.column1 = "1"
else
rs.column2 = "2"
rs.column3 = "3"
rs.update()
end if
rs.close()
set rs = nothing
this is how to change into ASP.NET with SQL selection and updating command??
Regards,
I would recommend reading up some articles on Data Access in ASP.NET. There are some Tutorials on this site.

Wednesday, March 7, 2012

How 2 create an effective search on NTEXT ?

Dear SQL,

since I create some multi-language table - I want to allow finding unicode text
so I made the field:Key_Words" (ntext)

It will have a string that can include some words in different languages, so that I can find by using:
SELECT Key_Words FROM MyTable WHERE Key_Words LIKE '%" & MyVar & "%' "...

The problem is that I can not apply clustered index onntext field (or *any* index...)

Any ideas how to deal with it ?SQL Server "large" edition and full text search.

Only way.|||Thanks,

I was trying to avoid reading about this stuff...

but I guess there is no escape 4 me :-(

hours cal

Dear frinends
I need to substract the hours. I need to calculate the hours worked after 6:00pm.
input is strat time like 30:june:03:30 PM until 8:00pm in night
I need to calculate the hours he worked after 6:00pm.
please help
elamsomething like this?

declare @.d datetime
set @.d = dateadd(hh,-12,getdate())
select @.d
, dateadd(hh,18,convert(varchar(10),@.d,120))
, datediff(hh,dateadd(hh,18,convert(varchar(10),@.d,1 20)),@.d)|||This calculates minutes worked after 6 pm. You could change it to calculate hours if you don't want the extra accuracy.

select (datediff(mi, convert(varchar(10), @.d, 120) + ' 18:00', @.d) + abs(datediff(mi, convert(varchar(10), @.d, 120) + ' 18:00', @.d)))/2

The absolute value conversion is used to return 0 instead of negative hours.