Looking For A Filename With A Certain String
Feb 27, 2008
Hi, I want to get my SSIS package to look for a file in a named directory that has a ceratin string in the filename.
example - My file is in a folder called data and the filename is 'System_UT_INCR_BOOKINGHEADER_20080214000000.TXT' Every day the fiel name changes to reflect the current date. I need my package to search for the String "BOOKINGHEADER". I know I need to create a variable with that value but I am not sure (using the example below) how to write the code to do this.
Imports System.IO
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Public Class ScriptMain
Public Sub Main()
Try
File.Move(Dts.Variables("Source").Value.ToString, Dts.Variables("Destination").Value.ToString)
Dts.Events.FireInformation(0, "", "File Moved Succesfully", "", 0, True)
Catch ex As Exception
Dts.Events.FireError(1, "", "Source file or destinations does not exist", "", 0)
End Try
Dts.TaskResult = Dts.Results.Success
End Sub
End Class
View 3 Replies
ADVERTISEMENT
Mar 31, 2008
I'm trying to write a stored procedure in SQL that will make a copy of a file and then append the current date to the end of the copy's filename. I'm storing the date in a variable called @currentdate which is defined as:
declare
@currentdate varchar(10)
set @currentdate='' + 'select datepart(month,getdate())' + '-' + 'select datepart(day,getdate())' + '-' + 'select datepart(year,getdate())'
Here is the SQL code I'm using:
exec xp_cmdshell 'copy "C:DevelopmentParticipant Limits ReportParticipant Limits Report template.xls" "C:DevelopmentParticipant Limits ReportParticipant Limits Report ' + @currentdate + '.xls"'
GO
The resulting file should have a filename something like "Participant Limits Report 3-31-2008". I get an "Incorrect syntax near '+'." error.
View 20 Replies
View Related
Sep 7, 2007
Doesn't appear you can do this.
Am I wrong?
Please tell me I am.
View 11 Replies
View Related
Oct 4, 2015
I am studying indexes and keys. I have a table that has a fixed width of data to be loaded in the first column which is parsed in a view based on data types within the fixed width specifications.
Example column A:
(name phone house cost of house,zipcodecountystatecountry)
-a view will later split this large varchar string basedÂ
column b: is the source filename of the data load (varchar 256)
....
a. would there be a benefit of adding a clustered or nonclustered index (if so which/point in direction on why)
b. is there benefit of making one of these two columns a primary key (millions of records) or for adding a 3rd new column as a pk?
c. view: this parses the data in column a so it ends up looking more like "name phone house cost of house zipcode county state country" each having their own column.
-any pros/cons of adding indexes (if so which) to the view instead of the tables or both for once the data is parsed?
View 4 Replies
View Related
Apr 19, 2008
Hi Champs,
Scenario Configuration : VB.net 2005 Code, WebService for Executing SSIS on Server, SSIS deployed on the Database Server
Problem Description : We are developing windows applicaiton in which we call webservice which was deployed on the same server where SSIS packages are deployed.
Now from Code we are passing FilePath name in variable and execute the Package. But the SSis result says that
The file name "\computernamefol1fol2fol3fol4abc.txt" specified in the connection was not valid.
More Information:
1. Full Permission are given on this network folder.
2. Package executes successfully from SSIS development solution (BIS solution)
3. Deployed packed executes successfully from the Database Server.
4. From Development pc packege executes successfully.
5. Other packages deployed on the same server executed suucessfully with same configuration and scenario.
Only this package is not executing.
-- the only differece with this package with other is -
using ".txt" extension in Flat file connection and using VB Script task
Can any one suggest the appropirate solution for this problem...
Thanks
Tarang Pandya
View 21 Replies
View Related
May 23, 2008
If you use "SELECT filename FROM sys.sysdatabases" this will return
the full path , such as "E:MSSQLdatamyData.MDF" ,
is it possible to return just the "myData.MDF" part of it?
I know that you can parse the string , but is it stored somewhere else , or is there a command that will return just the physical file name ?
Jack Vamvas
--------------------
Search IT jobs from multiple sources- http://www.ITjobfeed.com
View 1 Replies
View Related
Mar 25, 2008
Hi Guys, got a question that I'm not sure there is an answer to other than 'No Way'.
I have to export a file whose filename must include a sequence number. I have created the table to hold the seq# and the code to increment it. My problem is how do I include the seq# in the output filename. I am using the Flat File Destination tool for exporting. should I be using another tool?
Any suggestions?
Thanx,
Trudye
View 2 Replies
View Related
Jun 19, 2002
Hello,
Is there any way to change the logical filename of exsiting database
Thanks
Lara
View 1 Replies
View Related
Oct 10, 2001
Does anyone know how to execute a directory listing of a file and return the file name to a variable in SQL? For instance, there's a file called c:datach20011010.txt and i execute the following:
xp_cmdshell 'dir c:datach*.txt'
or any other transact sql or procedure, how can i get the filename into a variable...all in sql?
FYI - I need to pass a filename to a process so that it can bcp the data into a temp table. But I don't know the filename at the time the process is setup/scheduled.
TIA,
Mike Nolen
View 3 Replies
View Related
Jul 26, 2007
Hi,
I am using a foreach loop to go through the .txt files inside a folder.
Using a variable I can pickup the filenames the loop is going through.
At present there is a sql task inside the foreach loop which takes the filename as a parameter and passes this filename to a stored procedure.
Now I would like to add one extra step before this sql task. Would like to have a dataflow with flatfile source which connects to oledb destination.
The question is:
While in the loop, how is it possible to pass the filename to the flatfile source using the FileName variable which I have created?
Please note, this is a different question to my other post.
Many Thanks
View 1 Replies
View Related
Jul 26, 2007
Hi,
I think I may have mis-guided some of you in my previous post.
So I thought I explain it properly this time in a new post...
Here is the description of the ssis package:
Inside the connection manager there is a connection to the sql server database and a flat file connection.
The flat file connection inside the connection manager has the expression set
i.e. ConnectionString set to @[User::FileName]
And so there is nothing inside the connectionstring property of this flatfile connection.
Inside control flow:
1)
Dataflow which contains a flat file source and an ole db destination
The flatfile source is supposed to pickup the .csv file that gets passed to the ssis package.
Then the ole db destination is where the .csv gets imported into a sql server table.
2)
Back in the control flow, there is a task that calls a stored procedure with the parameter which is set to FileName
The question is:
How does this FileName parameter gets set before it is passed to the stored procedure?
Many thanks
View 1 Replies
View Related
Mar 28, 2008
HI,
I am writing data from a file in to a table and i have a field in that table for filename. How to read the file name to write in that table.
Thanks in advance.
View 4 Replies
View Related
Jul 26, 2007
Hi,
Using a ssis package I have several tasks.
A variable is also created called FileName.
There is a flat file connection called InputFileName.
initially when I designed the package, I hardcoded the pass of one of the .csv files into the path of the flatfile connection.
There is a dataflow which has flatfile source and oledb destination. These two basically pickup the file and import into the database using mapping.
So therefore the package works and data gets imported into the database.
Then I used the variable to make the filename dynamic. So I removed the hardcoded connectionstring in the InputFileName.
Is this the right thing to do to make the package dynamic? I would like to pass in any .csv filename and so the package runs.
My question is now that the connectionstring is deleted but instead placed an expression for the filename, then how does the system know which file to use?
Thanks
View 1 Replies
View Related
Jul 11, 2007
Using SSIS foreach loop I get the files names inside a folder on the network.
How do I pass this variable i.e. file name to a stored procedure?
Thanks
View 9 Replies
View Related
Sep 11, 2007
I take a backupfile every night and its named like 20070911_xvall.bak.
Now I need a procedure for an automatic restore in another sql server but I have to do a check to se that the date of the backupfile is the same as actual date so it can¨t happened that an older backupfile being restored.
Is it a good way to take actual date och build up the wanted filename and how can I then check if the file exist, its stored on another computer?
Anyone who has some sample I can start with?
Thanks
View 10 Replies
View Related
Feb 15, 2006
Hello,
I have a question regarding the report file which is included in an email, when a subscription is created:
Is it possible to programmatically add something to the name of the created file of the subscription? I want to have one parameter of the report, which is a date, added at the end of the filename to let the clients distinguish between different report files.
Thank you in advance.
Sandra Geisler
View 2 Replies
View Related
Apr 28, 2008
i have four text file which comes in different format , one of the fields i need to generate is the source Filename without extension as one of the coloums in the target tables.
The name of the file is requirment in the destination, how could i read the file name of the text file source and make it a coloumn and insert it into target.
Please advise
View 12 Replies
View Related
Aug 3, 2006
How do I correct this error:
"The database filename can not contain the following 3 characters: [ (open square brace), ] (close square brace) and ' (single quote)" ?
Where is the database stored and/or how can I change the relevant settings?
I have Both Visual Web Developer Express and SQL server express.
Exception detail:
System.Web.HttpException was unhandled by user code Message="The database filename can not contain the following 3 characters: [ (open square brace), ] (close square brace) and ' (single quote)" Source="System.Web" ErrorCode=-2147467259 StackTrace: at System.Web.DataAccess.SqlConnectionHelper.CreateMdfFile(String fullFileName, String dataDir, String connectionString) at System.Web.DataAccess.SqlConnectionHelper.EnsureSqlExpressDBFile(String connectionString) at System.Web.DataAccess.SqlConnectionHelper.GetConnection(String connectionString, Boolean revertImpersonation) at System.Web.Profile.SqlProfileProvider.GetPropertyValuesFromDatabase(String userName, SettingsPropertyValueCollection svc) at System.Web.Profile.SqlProfileProvider.GetPropertyValues(SettingsContext sc, SettingsPropertyCollection properties) at System.Configuration.SettingsBase.GetPropertiesFromProvider(SettingsProvider provider) at System.Configuration.SettingsBase.SetPropertyValueByName(String propertyName, Object propertyValue) at System.Configuration.SettingsBase.set_Item(String propertyName, Object value) at System.Web.Profile.ProfileBase.SetInternal(String propertyName, Object value) at System.Web.Profile.ProfileBase.set_Item(String propertyName, Object value) at System.Web.Profile.ProfileBase.SetPropertyValue(String propertyName, Object propertyValue) at ProfileCommon.set_MyNewProperty(String value) in c:WINDOWSMicrosoft.NETFrameworkv2.0.50727Temporary ASP.NET Fileslesson04385e3cebf08b8b90App_Code.jqcpv0qn.0.cs:line 24 at _Default.Page_Load(Object sender, EventArgs e) in D:Daniel's DocumentsVisual Studio 2005WebSitesLesson04Default.aspx.vb:line 15 at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Thanks in advance
View 3 Replies
View Related
Dec 13, 2006
how can I store a filename in the database, i have some GIF files which i want to show up on report, how can i specify those filename with a path in the database.
i tried manually entering the path c:Dataimages.gif but it didnt work. Can someone pls tell me how to do it.
Regards,
Karen
View 5 Replies
View Related
Mar 7, 2008
I have a page called 'upload.vb', which is the code for a file upload project I am working on. I am trying to write the filenames to an SQL database that I have built, but I keep getting this error: Compiler Error Message: BC30201: Expression expected. It doesn't seem to like the @ on line 46 in the VALUES part of my INSERT statement. Can anybody shed any light on this. Thanks. 1 Imports System
2 Imports System.Data
3 Imports System.Configuration
4 Imports System.Web
5 Imports System.Web.Security
6 Imports System.Web.UI
7 Imports System.Web.UI.WebControls
8 Imports System.Web.UI.WebControls.WebParts
9 Imports System.Web.UI.HtmlControls
10 Imports System.IO
11 Imports System.Data.SqlClient
12
13 ''' <summary>
14 ''' Upload handler for uploading files.
15 ''' </summary>
16 Public Class Upload
17 Implements IHttpHandler, IReadOnlySessionState
18
19 Public Sub New()
20 End Sub
21
22 #Region "IHttpHandler Members"
23
24 Public ReadOnly Property IsReusable() As Boolean Implements System.Web.IHttpHandler.IsReusable
25 Get
26 Return True
27 End Get
28 End Property
29
30
31
32 Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
33
34 If context.Request.Files.Count > 0 Then
35 ' get the applications path
36 Dim tempFile As String = context.Request.PhysicalApplicationPath
37 ' loop through all the uploaded files
38 Dim j As Integer = 0
39 While j < context.Request.Files.Count
40 ' get the current file
41 Dim uploadFile As HttpPostedFile = context.Request.Files(j)
42 ' if there was a file uploded
43 If uploadFile.ContentLength > 0 Then
44
45 uploadFile.SaveAs(String.Format("{0}{1}{2}", tempFile, "Uploads", uploadFile.FileName))
46 SqlDataSource.InsertCommand = "INSERT INTO tblDocuments(TheFileName) VALUES ('" & @TheFileName & "')"
47
48 End If
49 System.Math.Max(System.Threading.Interlocked.Increment(j), j - 1)
50 End While
51 End If
52 ' Used as a fix for a bug in mac flash player that makes the
53 ' onComplete event not fire
54 HttpContext.Current.Response.Write(" ")
55 End Sub
56 #End Region
57
58 End Class
View 10 Replies
View Related
Sep 6, 2005
Hi,
I have inherited a database that has a table called "Resources" that contains a field called "FilePath". FilePath is a VarChar(100) and contains the server path and filename of an XML file on the server hard disk.
I need to join the data in the XML with rows in the "Resources" table (and other tables).
Is it possible to get a Stored Procedure to load the XML file into a temporary table?
Is loading it into a table the best way to do it - or can I join directly to the XML file somehow?
What is the best approach? (I know nothing about XML in SQL Server yet)
Thanks in advance,
Chiz.
View 3 Replies
View Related
Feb 23, 2006
Basically like the topic says, I need to populate a filename with data from other columns and im having a tough time doing it.
Code:
UPDATE nice_cls_calls_0027
SET vcarchivepath = 'G:Nice Storageicestorage.safeautonet.netSafe Auto Task - Logger (807101)2006_feb_1SC_807101_'start_time'_'=stop_time'_'=channel'_'=cls_call_id'.aud'
I need start_time, stop_time, channel, and cls_call_id to populate the filename. The first 2 are datetime fields in the db and no conversion is needed for them, just raw data. The remaining two are smallint and raw data is needed there also. Any help would be greatly appreciated. TY
View 4 Replies
View Related
Dec 15, 2005
Hi!
Is there a way I can make the source file in my DTS dynamic so that every time I run it using ASP I can tell it which file to use?
View 1 Replies
View Related
Jan 30, 2006
I need to use DTS to create a dynamic destination filename based on the value of a field. I tried creating a DTS package using the wizard. It works fine if I wanted a static filename for the destination filename. I tried creating a Dynamic Properties Task by selecting Connection2/OLEDB Properties/Data Source and then using a SQL Statement to return a value for the name of the file. It doesn't seem to run the query everytime the DTS is ran. The first time I run it it names the file correctly but after that it keeps naming the file the old value from the SQL statement. Any idea what I need to do to fix this?
View 5 Replies
View Related
Dec 18, 2006
I am running the following sqllitespeed backup script on Windows 2003 Server
against SQL Server 2000
sqllitespeed -Bdatabase -T -DNorthwind -FH:MicrosoftSQLServerBACKUPSDATABACKUPSNorthWi ndorthwind.bak
How could I place the date variable into the output filename?
I've tried variations of %date% etc but nada.
Any thoughts?
Thanks in advance.
Gerry
View 3 Replies
View Related
Nov 8, 2013
I have to extract only the filename from the below filepath.
The first part prodserverexport always remains the same. A new folder is created prodserverexport 20071001, prodserverexport 200710012 etc each time the file is dropped . I want to extract only the part after that namely 20071001-200001-e430f8fd-PREC272.wma and like wise and dump it into a table.
prodserverexport2007100120071001-200001-e430f8fd-PREC272.wma
prodserverexport2007100220071002-013203-d00b2007-PREC120.wma
prodserverexport2007100220071002-032038-18381b92-PREC207.wma
prodserverexport2007100820071008-144758-16359a7b-PREC224.wma
prodserverexport2007100920071009-170426-4ed3535c-PREC97.wma
View 7 Replies
View Related
Jan 22, 2007
I want to change the following field in the database - text field.
Want it to be like this,
C:ProgramFilesHEATHEATSelfServiceattachmentsWinter019997.htm
want it to be H:2007Winter019997.htm
My aim is to move the files from C: to H: drive and update the database to reflect this. Thanks
Thsi is my code;
declare @str varchar(1000)
UPDATE heatgen
set @str = 'c:Program FilesHEATHEATSelfServiceattachmentsWinter019997.htm'
select reverse(@str)
select charindex('', reverse(@str))
select right(@str, charindex('', reverse(@str)))
select 'H:2007' + right(@str, charindex('', reverse(@str)))
SET gdetail = 'H:2007' + RIGHT(gdetail, CHARINDEX('', REVERSE(gdetail)))
The field is text I get error
Line 9: Incorrect syntax near '='.
Thanks.
View 19 Replies
View Related
Feb 8, 2007
I already posted this question in the Wrong Forum.
However I was wondering if it is possible to create a variable that holds the filename as an expression. I am using a For each loop to pick up files and i want to insert the 'Filename' as a colum so that i can differentiate among the rows in my destination Table.
Using the 'Derived Colum' in DTS I can link the colum to the variable. However i do not know how to create the variable which will store the filename for each file....
Any Clues...
Would really appreciate the help.....
View 2 Replies
View Related
Jan 14, 2008
I'm trying to read the filename from a file that I'm downloading by FTP (FTP Component) into a string variable so I can later use it for another part of the process, how can I do this?
View 2 Replies
View Related
Nov 23, 2005
I have to create a view where the filename is seperated from the pathto the file. Examples of the data include:m:imagesigmyimg.jpgm:imagesmediummyimg.jpgz:mediaimageshighqualmyimg.jpgIs there a function that will return the position in a string of thelast ? With this I can easily use substring or similar to pull andpush this stuff into the fields I want. If this function does notexist how do I move forward?
View 5 Replies
View Related
Nov 24, 2006
I have a stored procedure that (after selecting, incrementing and updating)returns the next sequential filename.I haven't been able to plug it in to the destination textfile filename in myDTS package.I know it has something to do with Dynamic Properties and I can navigate tothe property I want to set, but just can't seem to get the result of mystored procedure into the filename.I know somebody must have done this before.ThanksJoe
View 1 Replies
View Related
Jul 20, 2005
Hi.I am trying to create a database based on variables from xp_regread.Somehow I can´t pass @dBDir as FILENAME.I get the following error-message :Server: Msg 170, Level 15, State 1, Line 24Line 24: Incorrect syntax near '@dBDir'.What am I doing wrong ?I think the problem is somehow related to a datatype-problem orit is simply not possible to pass a variable to a "createdatabase"-statement.I have checked the xp_regread-output...naturally :) ...and it is correct.Hope someone can help :)regardsMichael----------------------------------------Source-code is as follows:USE masterGODECLARE @dBDir nvarchar(128)DECLARE @dBlog nvarchar(128)EXECUTE xp_regread 'HKEY_LOCAL_MACHINE','SOFTWARESchool-ProjectIRPFDatabase','dBDir',@param = @dBDir OUTPUTSET @dBDir =@dBDir+'IRPF.mdf'SET @dBlog =@dBDir+'IRPF.ldf'CREATE DATABASE IRPFON PRIMARY( NAME = IRPF_db,FILENAME = @dBDir)LOG ON( NAME = 'IRPF_log',FILENAME = @dBlog)GO
View 2 Replies
View Related
Apr 20, 2008
Hi all,
I am processing multiple flatfiles in the same folder using a "for each loop". Inorder to keep track of the file where the record comes from, I would like to add the full path and filename to the record that gets written to SQL.
Can anyone help me with this.
Thanks,
Dan
View 3 Replies
View Related