DB Engine :: Cannot Access Destination Table - Appears Sometimes
Apr 23, 2015
I have a simple powershell script, that is writing single row to remote SQL server as sort of keepalive solution for branch machine. It opens System.Data.SqlClient.SqlConnection, SqlBulkCopy writes table, and closes connection.
Sometimes script throws an error in form of - Cannot access destination table.
We are not managing internet connectivity in that place, so I don't know for sure, but can this error be caused by connection timeout that comes when script tries to write ?
When I import data from MS Access databases, some fields appear as "<Long Text>" in SQL. I cannot edit these fields in SQL. I have to export the table to Access, update the field, and then import again.
There's got to be an easier way. What am I missing here?
Hi all, In the Object Explorer of my SQL Server 2005 Management Studio Express, I do not have €˜Northwind€™ Database installed yet. I executed the following source code (that was copied from a book) in my VB 2005 Express: /////////////////////----Form9.vb----////////////////////////// Imports System.Data.SqlClient Imports System.Data Public Class Form9
Dim cnn1 As New SqlConnection
Private Sub Form5_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'Compute top-level project folder and use it as a prefix for 'the primary data file Dim int1 As Integer = InStr(My.Application.Info.DirectoryPath, "bin") Dim strPath As String = Microsoft.VisualBasic.Left(My.Application.Info.DirectoryPath, int1 - 1) Dim pdbfph As String = strPath & "northwnd.mdf" Dim cst As String = "Data Source=.sqlexpress;" & _ "Integrated Security=SSPI;" & _ "AttachDBFileName=" & pdbfph cnn1.ConnectionString = cst
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Create a command to create a table Dim cmd1 As New SqlCommand cmd1.CommandText = "CREATE TABLE FromExcel (" & _ "FirstName nvarchar(15), " & _ "LastName nvarchar(20), " & _ "PersonID int Not Null)" cmd1.Connection = cnn1
'Invoke the command Try cnn1.Open() cmd1.ExecuteNonQuery() MessageBox.Show("Command succeeded.", "Outcome", _ MessageBoxButtons.OK, MessageBoxIcon.Information) Catch ex As Exception MessageBox.Show(ex.Message) Finally cnn1.Close() End Try
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'Create a command to drop a table Dim cmd1 As New SqlCommand cmd1.CommandText = "DROP TABLE FromExcel" cmd1.Connection = cnn1
'Invoke the command Try cnn1.Open() cmd1.ExecuteNonQuery() MessageBox.Show("Command succeeded.", "Outcome", _ MessageBoxButtons.OK, MessageBoxIcon.Information) Catch ex As Exception MessageBox.Show(ex.Message) Finally cnn1.Close() End Try
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
'Declare FromExcel Data Table and RowForExcel DataRow Dim FromExcel As New DataTable Dim RowForExcel As DataRow
'Create TextFieldParser for CSV file from spreadsheet Dim crd1 As Microsoft.VisualBasic.FileIO.TextFieldParser Dim strPath As String = _ Microsoft.VisualBasic.Left( _ My.Application.Info.DirectoryPath, _ InStr(My.Application.Info.DirectoryPath, "bin") - 1) crd1 = My.Computer.FileSystem.OpenTextFieldParser _ (My.Computer.FileSystem.CombinePath(strPath, "Book1.csv")) crd1.TextFieldType = Microsoft.VisualBasic.FileIO.FieldType.Delimited crd1.Delimiters = New String() {","}
'Loop through rows of CSV file and populate 'RowForExcel DataRow for adding to FromExcel 'Rows collection Dim currentRow As String() Do Until crd1.EndOfData Try currentRow = crd1.ReadFields() Dim currentField As String Dim int1 As Integer = 1 RowForExcel = FromExcel.NewRow For Each currentField In currentRow Select Case int1 Case 1 RowForExcel("FirstName") = currentField Case 2 RowForExcel("LastName") = currentField Case 3 RowForExcel("PersonID") = CInt(currentField) End Select int1 += 1 Next int1 = 1 FromExcel.Rows.Add(RowForExcel) RowForExcel = FromExcel.NewRow Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException MsgBox("Line " & ex.Message & _ "is not valid and will be skipped.") End Try Loop Try cnn1.Open() Using sqc1 As SqlBulkCopy = New SqlBulkCopy(cnn1) sqc1.DestinationTableName = "dbo.FromExcel" sqc1.WriteToServer(FromExcel) End Using Catch ex As Exception MessageBox.Show(ex.Message) Finally cnn1.Close() End Try
'Read the FromExcel table and display results in 'a message box Dim strQuery As String = "SELECT * " & _ "FROM dbo.FromExcel " Dim str1 As String = ""
Dim cmd1 As New SqlCommand(strQuery, cnn1) cnn1.Open() Dim rdr1 As SqlDataReader rdr1 = cmd1.ExecuteReader() Try While rdr1.Read() str1 += rdr1.GetString(0) & ", " & _ rdr1.GetString(1) & ", " & _ rdr1.GetSqlInt32(2).ToString & ControlChars.CrLf End While Finally rdr1.Close() cnn1.Close() End Try MessageBox.Show(str1, "FromExcel")
End Sub
End Class /////////////////////////////////////////////////////////////////////// This is Part 1 (The length of input exceeds 50000 characters). Part 2 will be posted in this site shortly.
I am unable to the access on table even after providing the SELECT permission on table.
Used Query by me :
Here Test is schema ; Card is table ; User is Satish
To grant select on Table
GRANT SELECT ON TEST.Card TO satish Even after this it is not working, So provided select on schema also. used query : GRANT SELECT ON SCHEMA::TEST TO Satish.
I want to schedule a job which pulls files from a non SQL server (Sybase) which later needs to have a step 2 kicking the ssis package. Problem is that, on the source a batch file will run every 4 hours and outputs total of 10 text files. (takes 5 minutes complete). Now, on destination i want to pull these files via SQL job but while scheduling;
1. I don't see any option saying like 4 hours 10 minutes or so 2. If its out there, then i believe this might be a problem as this time would be an increment one e.g next run would be 4 hours 20 minutes in that case.
How should i achieve pulling these files up because we have an SSIS package on destination that needs those text files to be used as soon as they arrive on SQL server(destination)
I can't seem to find a way to make the Data Flow Destination in a Business Intelligence Visual Studion Project output an MDB file for Microsoft Access.
Hello, For packages where an MS Access database is the destination, what are some ways to detect whether or not the file is 'in use'? I know there is a lock file associated with Access databases. Could it be as simple as using something from the FileSystem Object to discover whether or not there is a lock file with the same name as the destination database? I'd like to stop the package if the file is in use.
Instead of blindly inserting all my data from a previous task into a table using "Table" as the Data Access Mode in the OLEDB Destination editor. I would like to join this output with a reference table and insert only qualifying rows. Question is "how do I access the data from previous task so that I can do a meaningful equijoin" ? I know I have to use the "SQL Command" data access mode, but what next ?
I'm fairly new to SSIS, and I'm looking for some general guidance on the best approach to take to a particular issue. Essentially, I've built a web application, running on a remote server, and I'm looking to take the contents of an Excel spreadsheet, load it into memory, run a whole mess of calculations against it, and then load the results into a table on MS-SQL 2005. The calculations are in a class library, written in C#, so my sense was that the best approach would be to a) load the data into a datareader, b) run the calculations against the data and c) load it to SQL. Of these steps, a) seems like the place where SSIS would come into play.
My question is, once I've got the data into a datareader, how can it be accessed from my code? I'd been playing around with DtsClient until having the realization that it was intended to be used locally. Is there a similar method for doing this sort of thing remotely?
On my SQL Server 2014 SP1 on Windows Server 2012 R2, allow inbound TCP 1433 and UDP 1434 seems to not be enough for managing remotely any named instance on this server.
I have a raw file destination and am using a variable to store the filename. In an earlier task, I create the value in the variable. User:Filename ... set to C:Test.txt.
When I run the package, I get the "Error: 0xC0202070 at DFT Tekelec Call Events, RFD Tekelec [1365]: The file name property is not valid. The file name is a device or contains invalid characters". error. I then set a breakpoint to examine my variables on the DataFlow pre-execute event and found my variable showing the value "C:\Text.txt" ... so apparently XMLA is adding the escape character when it stores the value in the variable but not retracting it when it uses the value as the filename.
What am I missing? Can I not use pathing in the variable? And if that's the case, how do I specify a path. Went back through my Rational Guide to Scripting SSIS but did not find this addressed specifically ... my second option being build the fiilename by script and set the raw file destination property directly via script.
Trying to do a update/insert from SQL 2005 query to Access 2003 linked table.
In the Script Transformation I get this error.
Unable to cast COM object of type 'System.__ComObject' to class type 'System.Data.OleDb.OleDbConnection'. Instances of types that represent COM components cannot be cast to types that do not represent COM components; however they can be cast to interfaces as long as the underlying COM component supports QueryInterface calls for the IID of the interface.
Destinatoin Oledb connection is Native OLEDB Jet 4 to Access 2003 database.
Private sqlConn As OleDb.OleDbConnection
Private sqlCmd As OleDb.OleDbCommand
Private sqlParam As OleDb.OleDbParameter
Private connstring As String
Public Overrides Sub AcquireConnections(ByVal Transaction As Object)
I have user called DBA_USER he has db_owner access on (123DB) database ....
But when ever my machine restarted the user was getting access error (i.e.. you don't have access on this database) and i checked his access on that particular database his access got reverted back ....
Here my question is why this particular user getting this type of error ....
In a Data Flow Task, I have an insert that occurs into a SQL Server 2000 table from a fixed width flat file. The SQL Server table that the data goes into is accessed through an OLE DB connection manager that uses the Native OLE DBMicrosoft OLE DB Provider for SQL Server.
In the OLE DB Destination, I changed the access mode from Table or View - fast load to Table or View because I needed to implement OLE DB Destination Error Output. The Error output goes to a SQL Server 2000 table that uses the same connection manager.
The OLE DB Destination Editor Error Output 'Error' option is configured to 'Redirect' the row. 'Set this value to selected cells' is set to 'Fail component'.
Was changing the access mode the simple reason why the insert from the flat file takes so much longer, or could there be other problems?
I am stuck on finding a solution to transpose source data from a system via a metadata look-up table into a destination table. I need a method to transpose/pivot the source data into columns (which are by various data-types). The datatypes for each column are listed in a metadata table.
Source Data Table:
Table Name: Source
SrcID AGE City Date 01 32 London 01-01-2013 02 35 Lagos 02-01-2013 03 36 NY 03-01-2013
Metadata Table:
Table Name:Metadata
MetaID Column_Name Column_type 11 AGE col_integer 22 City col_character 33 Date col_date
Destination table:
The source data to be loaded into the destination table(as shown below):
SQL2008R2...Have a SPID  that started yesterday and contained a command to drop a server audit.  This did not finish (after 3hrs) so I killed the SPID. Problem is it's still there (sp_who2) and I think it's now blocking access to viewing editing logins within SSMS as I'm getting "Lock request time out period exceeded. (Microsoft SQL Server, Error: 1222)" when double clicking a login.Do I need to restart the instance as killing the "alter server" transaction (SPID=62) is not working? Code to show blocking transactions returns this.
I am trying to make my maintenance plan to backup on a remote server but it fails with:
"failed with the following error: "xp_delete_file() returned error 2".
I am pretty sure its because it doesnt have full access to the share folder... My question is, how can I grant access to it, if I am using a local account as sql agent service: NT ServiceSQLSERVERAGENT.I need to change the service account?
Hi there,I sincerely hope that someone out there can help. I have twoinstances of the SQL 2000 Desktop Engine running. One is on my localmachine for development and the other is on another machine on ournetwork which is the production environment. I have built an Access2003 front end application which connects to this database. Thisworks fine locally, as you would expect. I successfully installed thedatabase on the production machine and am able to connect to it viaAccess 2003 (using the Data Link Properties window) and from thirdparty database manager software (similar to Enterprise Manager). I amnot able to to connect to the database via my application.I am using the "sa" account with a strong password. This is myconnection string:strConnection = "Provider=sqloledb;DataSource=server02;UserId=sa;Password=strong;Initial Catalog=Test"The error I'm getting is:"Connection cannot be used to perform this operation. It is eitherclosed or invalid in this context."The connection string is the only thing that changes in my code when Iswitch from my local to my production database. Is there some reasonthat I can't use the "sa" account in this fashion that I'm not awareof? I'd rather not use integrated security for simplicity's sake asthis is a small, internal application. Also, I would have thoughtthat if that was the issue, I couldn't use "sa" at all, even locally.I'm going to post to the Access group as well but thought someone heremight have some advice to offer as well.Thanks,Barb
My DTS package does nothing special it just pulls in an data from another server (specifying the SQL in a Global V).
This data is then altered using various Stored Procedures.
What would be nice is if the data's destination table could be a #temp table (within tempdb) and then my sps could access it and perform their various operations.
At the moment i cannot get this to work and instead all i can think of is to Create a table within the main working db and insert the data into that and then insert the data into a #temp table and DROP the table i created in the working database.
There must be a better way to achieve this. Is there any way to copy the data straight to the #temp table i have created?
How to create a new table dynamically in OLE DB destination.
This is what i am doing
I am reading multiple flat files in loop and saving file name to a variable. Then i have a source script component which read and transforms data .Now how can I push the data to SQL table. I want to create a new table with name saved in a variable. I tried using OLE DB destination and assigning table name from variable. Does'nt work.
Thanks in advance for any insight on how to make this work.
Hi, I need to truncate the Destination table every time before the data is loaded. I had checked out in OLE DB Destination properties but couldn€™t find any information on truncate table.
EXP: In INFORMATICA we have a properties setting for truncating the table every time the data get loaded. I€™m looking for this option in SSIS can any one guide me on this. Thank you,
Hello, In my Data Flow I have a OLE DB Destination that needs to get the table name to write the data to dynamicaly from a variable I created. So I select "table name or view name variable" from the Data access mode and select my variable below. So far so good, but when I click "ok" I get the following error message :
I have two program (App1 And App2) on two separate system.on App1 there is a database named DB1 and on App2 there is a database named DB2.on DB1 i create a table named Table_1 .i define replication for DB1 to push publication (for table_1) .
I define DB2 as a subscriber to receive all changes on [DB1].[Table_1]. every thing is ok but just one thing. when App1 and App2 both are running if i change the contents of [DB1].[Table_1] this change only shown if one time i exit from App2 and rerun it . how can i refresh App2 without rerun it?
A friend said to me it is possible with trigger, but how? I don't know how can i define a trigger for this reason . or any way that exist for this reason.
I have a data flow task that performs an "upsert" by directing successful rows from a Lookup to an OLE DB Command that updates rows and unsuccessful rows (Lookup error output) to an OLE DB Destination for insertion.
The problem is that execution hangs when both tasks update/insert into the same table (execution is still hung after 20 minutes). Modifying the OLE DB Destination to insert into a different table succeeds (execution completese within 2 minutes). Replacing the OLE DB Destination with a Row Count transformation also works.
Could this be due to a table-locking issue? Any suggestions?
I created a package using the Import Data wizard and everything works fine when I re-execute it. I needed to change the name of the destination table so I went into SQL Server and renamed the table. I then went in and edited the DTSX file via a text editor and changed the OpenRowset setting from [CMBS].[dbo].[raw_Note] -> [CMBS].[dbo].[T_Raw_Note]
<property id="104" name="OpenRowset" dataType="System.String" state="default" isArray="false" description="Specifies the name of the database object used to open a rowset." typeConverter="" UITypeEditor="" containsID="false" expressionType="None">[CMBS].[dbo].[T_Raw_Note]</property>
There are no other references to the table in the DTSX, i saved the file and then re-ran.
When I run, I get invalid object name dbo.raw_Note (old table name). Is there some data being cached somewhere or hidden elsewhere that it would reference the old table? When I go back into the DTSX file, the correct name is in there so I don't know where it is getting the old name from? Any help would be appreciated.
Create a table at the beginning of a package (using a ExecuteSQLTask component) and then use the created table as a OLE DB destination component, later on the package.
Is this possible in SSIS?
The problem I run into is that I have to point the OLE DB destination component to a table and set up mappings, however as the table does not exist until the package is running, it does not seem to be possible.
Which is slightly similar to what I want, but the table I create would not be a temp tables, and I need to set up mappings and I don't see how this is possible.
I have searched the SSIS forum for an answer to my question, and I think I have found my answer but what i have read does not come out directly and answer my question.
I am attempting to create an SSIS package that imports data from a Visual Foxpro table into a SQL Server table. From what I have read, the source and destination tables must match column for column. Is this correct? My SQL Server table has a few more columns in it. However, i consistently get "Cannot create connector. The destination component does not have any available inputs...blah".
From what i have read, it sound like the reasoning is that my source and destination tables do not match.
Is this correct, or am i barking up the wrong tree?
Short Question: How do I delete all records from a destination table prior to appending new data to that table?
I am working with a SQL database that was migrated from MS Access. All relationships, primary keys, and identity columns have been set identically to the MS Access database values. The MS Access database is still being used as the database of record until the SQL database is fully functional with front-end, etc.
I want to delete the information stored in all the SQL tables, and then append the MS Access values to the SQL tables. I was able to write delete and append queries in MS Access to correctly transfer data to the SQL tables. However, I would prefer doing this through SSIS because I have several other sources of data to move to a SQL Server database and most of those other sources are not a MS Access database.
Due to relational entegrity settings, I need to delete the records from 8 tables in a specific order. I have tried independent control objects for each of the 8 tables with data flow objects of either "OLE DB Command" or "OLE DB Source" with the SQL command as "Delete From TableName". Results of the debug indicate everything is "green" but no records were deleted fromt the tables.
Is there any way around (or will there be) using the drop-down? It takes several minutes when running against an Oracle Apps database to populate that dropdown with the several hundreds of tables and views.
I am having a Data flow task in For each loop which will gets 100 sourcetable names and 100 target table names...
am having a simpleData flow task which trasferes from OLEDBSource to OLEDBDestination. I am repeating the Dataflow task which transfers from sourcetablename extracted from for loop to a destination table var.
The problem am gettting is for the first table it is able to transfer correcly because I did mapping for those tables at design time...but for the next coming sourcetable-desttable (which r having different no of cols,datatypes) its giving Validation failed...and...needs to refresh metadata....
is there any way to refresh the metadata of Data flow task (I set the property of OLEDBSource validate external meta to false then also same error is coming)