I am using an document management application which uses SQL Server 2012.
I am trying to fetch document names along with its path. For example,
If my document name is test.txt and it is under folder structure A/B/C, my output should be A/B/C/test.txt.
Could anyone please help me with a query?
Table name: DTree
DataId Name
======= ========
12345 test.txt
If the folder structure is not in the database, or you don't have a mechanism to tell SQL what the file path is, I don't think you can do this.
You could have a file named test.txt in every single folder, so you will need to have the file path explicitly. If the file path is stored in that table as A/B/C, you can just concatenate the file path with the file name like
SELECT filepath + '/' + filename
Related
I am learning SSIS.
Had a question regarding the same.
I have a SQL Table
`(File id, File name, File content)
(1,abc,hi)
(2,ghi,how)
(3,ghi,you)`
I want to give an input in SSIS:
File ID and Destination Folder
Output:
I want to export 'File Content' in the destination folder as FileName.txt.
Example: From the above table if I give input as
File ID=1
I want all the files
(file ID>1)
in the destination folder as
abc.txt
def.txt
ghi.txt
having the respective File Content in them.
Can you please help me with this?
I have trued using Script task but its not giving the right output.
Thank You!!
I've created an S3 [external] stage and uploaded csv files into \stage*.csv folder.
I can see stage content by doing list #my_stage.
if I query the stage
select $1,$2,$3,$4,$5,$6 from #my_s3_stage it looks like I'm randomly picking up files.
So I'm trying to select from specific file by adding a pattern
PATTERN => job.csv
This returns no results.
Note: I've used snowflake for all of 5 hours so pretty new to syntax
For a pattern you can use
select t.$1, t.$2 from #mystage1 (file_format => 'myformat', pattern=>'.*data.*[.]csv.gz') t;
The pattern is a regex expression.
For a certain file you have to add the file name to the query like this:
select t.$1, t.$2 from #mystage/data1.csv.gz;
If your file format is set in your stage definition, you don't need the file format-parameter.
More info can be found here: https://docs.snowflake.com/en/user-guide/querying-stage.html
I want to pass several changelogfile in liquibase.properties to make sure all the files are applied in the order I like as well as I could simply drop one file if that part of the change was not suitable.
I have this liquibase.properties file now:
driver: com.microsoft.sqlserver.jdbc.SQLServerDriver
classpath: mssql-jdbc-7.0.0.jre8.jar
url: jdbc:sqlserver://localhost:1433;databaseName=test_db_migration;user=sa;password=Password1
changeLogFile: Changelogs/db.tables.part1.sql
Is there any way I can pass two .sql file address in ChangeLogFile attribute?
liquibase handle xml/yml file format - not directly sql file format.
in the xml grammar, you can include xml files to gather many changesets together.
you can also include sql in changeset if you want.
hope it helps !
I am trying to write a file name to a table in my database - at the moment all I am achieving is importing the whole file path.
I have a foreach loop, which on the Collection looks in a specific folder and for a specific file type (the retrieve file name is fully qualified)
This has a variable mapping to "ImportInvoiceFilePath"
Then within that is a Data Flow Task which includes the flat file source, a derived column which creates the file path in the database.
This works fine - but what I am trying really hard to do but can't work out is how do I get just the file name (no extension) to write to the database as well?
Literally worked it out. Set my forloop to nameonly then in my connection to my Source file under expressions put:
#[User::ProcessingInvoiceFilePath] + "\\"+#[User::ImportInvoiceFileName]+".saf"
Where saf is the file type
I need to do migration from one envionment to another envionomet.It is seach the file with extention and copy and paste into other envinoment.
is this possible to automate.file and folder, name is dynamic in nature.
can we take input as file of this information(file name ,envionoment name (Dev-> stage)or stage to prod and folder name)