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.....
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...
Hi - Is there a resource I can go to that lists people who I pay to talk me through stuff like getting SQL Server Express installed, get some sample data input and then get that data into Excel? I just cannot seem to get any help that works for me to learn SQL Server; the books are obtuse, the online help too indirect. Once I get something working I hope to enhance it on my own, but I have been stuck at the start for a very long time. There is stuff for me to do that is not getting done.
I have about 160 packages in my system, all using about 20 shared datasources. When changing one of the datasource's connection (changing the server name), I need to open every one of my packages and press OK to allow the remapping to the new server. (this is something I don't understand: wasn't this the meaning of using a share datasource in the first place? what's the advantages in that case?)
So, I have heard about Package configuration, and how it supposed to support all of this, But I don't understand something: The configuration is set to a certain package. If I have 2 packages, using the same two (of four) Datasources. Using the configuration wizard from one of the packages, I mark the connection string from the datasource. I need to do the same in the other package? will the configuration table hold only one value for that connection? If I change the value of the connection string will it affect all the packages using that datasource or only the ones using configuration?
this querry below works perfect when i assign the us.UserID = 29 but i need to be able to use the @UsersMaxID variable..... when i debug all of my values are right where they need to be... even this on ((( @UsersMaxID ))) but for some reason it will not work with the next select statement...
can someone make the pain go away and help me here..??
erik..
GOSET ANSI_NULLS ON GO ALTER PROCEDURE AA ASDECLARE @GenericColumn Varchar (200) DECLARE @GenericValue Varchar (200) SET @GenericColumn = 'FirstName'SET @GenericValue = 'Erik' DECLARE @SQL NVARCHAR(4000) DECLARE @UserID INT DECLARE @UsersMaxID INT DECLARE @MaxID INT declare @tempResult varchar (1000) -------------------------------------------Define the #Temporary Table----------------------------------------------CREATE TABLE #UsersTempTable ( ID int IDENTITY PRIMARY KEY, UserID [int], FirstName [varchar](30), LastName [varchar](30), CompanyName [varchar](200), Address1 [varchar](75), Address2 [varchar](75), City [varchar](75),ActiveInd [int], Zip [varchar](10), WkPhone [varchar](12),HmPhone [varchar](12), Fax [varchar](12), Email [varchar](200), Website [varchar](200), UserType [varchar](20),Title [varchar](100),Note [text], StateCD [char](2), CountryCD [char](2), CompanyPhoto [varchar](50), CompanyDescr [varchar](2000)) ---------------------------------------Fill the temp table with the Customers data-----------------------------------SET @SQL = 'INSERT INTO #UsersTempTable (UserID, FirstName, LastName, CompanyName, Address1, Address2, City, ActiveInd, Zip, WkPhone, HmPhone,Fax, Email, Website, UserType, Title, Note, StateCD, CountryCD, CompanyPhoto, CompanyDescr) Select Users.UserID, Users.FirstName,Users.LastName, Users.CompanyName, Users.Address1, Users.Address2, Users.City, Users.ActiveInd, Users.Zip, Users.WkPhone, Users.HmPhone,Users.Fax,Users.Email,Users.Website, Users.UserType,Users.Title, Users.Note,Users.StateCD, Users.CountryCD,Users.CompanyPhoto,Users.CompanyDescr FROM USERS WHERE ' + @GenericColumn +' = ''' + @GenericValue + '''' EXEC sp_executesql @SQL SET @MaxID = (SELECT MAX(ID) FROM #UsersTempTable)SET @UsersMaxID = (SELECT UserID From #UsersTempTable WHERE ID = @MaxID) SELECT SpecialtyName FROM Specialty s INNER JOIN UserSpecialty us ON s.SpecialtyCD = us.SpecialtyCD WHERE us.UserID = 29 SELECT * FROM #UsersTempTable
==========================================================================================SET @UsersMaxID = (SELECT UserID From #UsersTempTable WHERE ID = @MaxID) SELECT SpecialtyName FROM Specialty s INNER JOIN UserSpecialty us ON s.SpecialtyCD = us.SpecialtyCD WHERE us.UserID = 29 <<<<<<<<<<<<<<<<< i need @UserMaxID ........RIGHT HERE
I am connecting to a new SQL Server 2008 R2 database using SSMS from my ADMIN VM workstation. I bring up a Stored Procedure and make a change.... I execute the Stored Procedure... after it finishes.... I exit out without saving to a file.... I go back in and my change was not held.
I can do the exact same process with an old SQL Server 2005 database. Is there a permission I am missing to set to be able to do this on the 2008 database.
I have this query that returns the largest value in a row, but i need to know the column name that this value is in as well. any help in advance is appreciated
select clientID, (select max(incomeValue) from (select earnings as incomeValue union all select unemployment union all select pensionRetirement union all select alimony union all select childSupport union all select dividendInterest union all select SS union all select SSI union all select SSDI union all select veteranBenefits union all select FIP union all select workStudy union all select other union all select otherHHWS) as income) as MaxIncomeValue from tbl_income
I don't know where to post this kind of stuff so here goes...
I have maintenance plans which sometimes fail because the delete step reports that the old backup file is "in use." I have no idea how to determine what Windows thinks is holding the file. HOw do you determine who is holding a file hostage??
Warning: Process Being Freed While Holding Dataserver Semaphore
I understand that this is a bug. And that it is supposed to be fixed in service pack 4. However, has anyone experienced or figured out how to get rid of this message?
Here's a quick script that will return the inputbuffer of processes that are holding more than a certain threshold of locks (by default, 10, but it's easy to modify). Handy for tracking down what query is holding those 1400 locks.
Yes, it uses a cursor. I'd welcome amendment by anyone who has the insight on converting it to pure set-based.
Cheers -b
CREATE PROCEDURE sp_lock4 AS set nocount on
DECLARE @tSpids table(spid int PRIMARY KEY CLUSTERED,count int) DECLARE @iSpid int,@iCount int
insert into @tSpids (spid,count) select convert (smallint, req_spid) As spid, count(*) as count
from master.dbo.syslockinfo, master.dbo.spt_values v, master.dbo.spt_values x, master.dbo.spt_values u
where master.dbo.syslockinfo.rsc_type = v.number and v.type = 'LR' and master.dbo.syslockinfo.req_status = x.number and x.type = 'LS' and master.dbo.syslockinfo.req_mode + 1 = u.number and u.type = 'L' group by converT(smallint,req_spid),'dbcc inputbuffer(' + cast(req_spid as varchar(4)) + ')' having count(*)>10 order by count(*) desc
DECLARE cLoop cursor for select spid,count from @tSpids
OPEN cLoop
FETCH NEXT FROM cLoop INTO @iSpid,@iCount WHILE @@FETCH_STATUS=0 BEGIN select 'spid ' + cast(@iSpid as varchar(4)) + ' has ' + cast(@iCount as varchar(5)) + ' locks.' exec ("dbcc inputbuffer (" + @ispid + ")") FETCH NEXT FROM cLoop INTO @iSpid,@iCount END
I've done some basic database design in the past, but am a relative newbie to design. I have recently come across a situation I'm not sure how to handle. Here's the situation...
Assume we've got a contacts table which holds information about our contacts. All contacts have the same basic information - name, address, telephone, etc. Each contact is of a certain type - let's just say a, b, and c, for ease. This contact type is stored in the contacts table. Now, on contacts of type b, I also have to store some additional data. What it is doesn't really matter. I found a way to set this up, but I'm not sure that I'm going about it the right way, and would love some advice on the proper way to do this. Basically, what I did is create my contacts table: Contact_id, contactName, ContactAddress, ContactPhone, ContactType. Created a contacttype table ContactType, ContactTypeDescription, ContactAddInfo
What I've done is left contactaddInfo as a nullable field. When it has a value, that value is the name of a table which holds the additional information that I need for the contact... So when I'm running a query, I can tell if I need to reference another table by checking the value of ContactAddInfo.
I can't imagine that this is the best solution, but it was the first thing that popped into my head, and it's a really small database that's using it. However, I'm now being faced with the same situation in a much more important, larger database, and I'd love to know the 'right' way.
is there any more efficient way for example to implement the next query?
SELECT s1.article, dealer, s1.price FROM shop s1 JOIN ( SELECT article, MAX(price) AS price FROM shop GROUP BY article) AS s2 ON s1.article = s2.article AND s1.price = s2.price; WHERE dealer = 'dealer sample'
I'm working on an application that allows users to set up scheduled time based reports. Each scheduled report creates a SQL Agent job associated with a schedule.The default time to fire these off is 8:00 AM. There are several hundred. DWH and it has no trouble running hundreds of reports all fired off at the same time.
There are several ETL processes and occasionally they don't complete before our verbal SLA of 8:00 AM.
My problem is on days where the ETL runs past 8:00 AM I wan't to hold these scheduled jobs from firing off.
I am not comfortable with DTS 2000 but I need to execute a encapsulated DTS 2000 package from a SSIS package. The real problem is when I need to pass SSIS variables to DTS 2000 package. The DTS 2000 package have 3 global variables that I can identify on " Execute DTS 2000 Package Task Editor - Inner Variables ". I believe the SSIS variables must be mapped on " Execute DTS 2000 Package Task Editor - OuterVariables ". How can I associate the SSIS variables(OuterVariables ) to "Inner Variables"? How can I do it? Much Thanks.
SELECT TOP 1 @From = CONVERT(char,CreateDate,101) FROM CustomerInfo WHERE TicketNum = (SELECT TOP 1 TicketNum FROM CustomerInfo WHERE CreateDate <= DATEADD(mm, -30, CURRENT_TIMESTAMP) ORDER BY CreateDate DESC) SELECT @To = CONVERT(char,GETDATE(),101)
SET @DBName = 'Archive_SafeHelp' CREATE DATABASE @DBName + ' ' + @From + ' ' + @To END
I am trying to create a database based on the name contained in the variables. I get the error 'Incorrect syntax near '@DBName'. How do i accomplish this?
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
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?
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.
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.
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?
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?
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.
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
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.
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.
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
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.
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