DTC - Transaction Context In Use By Another Session

May 5, 2006

Hi

I have a master package that executes a series of sub packages. The master package is run from a SQL Agent job. The packages are reading from and writing to two databases on the same instance of SQL Server 2005.

If I set the Execute Package Tasks for the sub packages without any precedence constraints between them and set TransactionOption = Required at the master package level (and supported from there downwards) I get the following errors.

The event log shows me:

The SSIS Runtime has failed to enlist the OLE DB connection in a distributed transaction with error 0x8004D00A "Unable to enlist in the transaction.".

Running a SQL Profiler trace shows me:

Error: 3910, Severity: 16, State: 2
Transaction context in use by another session.

This problem is well documented and seems to go back to DTS in SQL Server 7.0 . . . see http://support.microsoft.com/?scid=kb;en-us;279857&spid=2852&sid=150

I can get round it by setting precedence between the sub packages - making them run one at a time solves the problem. But then we don't get the performance benefits of running the packages concurrently. Does anyone have any other solutions.

TIA . . . Ed

View 6 Replies


ADVERTISEMENT

Transaction Context In Use By Another Session.

Jun 6, 2006

I'm having a SP1 on server A.

This procedure has a begin trans and a commit. In this procedure i'm inserting data into tables. This data is provided by an extrenal app in staging tables. On the tables i'm inserting data on i'm having triggers that again are starting a SP2. I'm using a cursor on the inserted table to achieve this. The SP2 only insert a record on a table that is on a linked server.

For testing reasons at this moment this is my dev machine too.

The error 'Trans ... ' pops up ....

Any suggestions ..



Kind Regards, Harry

View 5 Replies View Related

Transaction Context In Use By Another Session Error

May 12, 2006

I have written a stored procedure that calls a C# class.  The sp is called by a trigger on table A.  The class has 2 methods.  Method 1 is the main call from the stored procedure.  Inside it, it sets a connection to the db.  Then it calls another private method which has it's own connection and returns a dataset so that I can close that connection by the end of the method.  When I execute the sp from within sql management studio, it runs just fine.  But when being called from the trigger, I get the "transaction context in use by another session error" error.  I read that I needed to wrap my 2nd connection in ...
using (new TransactionScope(TransactionScopeOption.Suppress)){  open conn here, do work, etc.}
I've tried that and I still get the same error from the trigger.  Anyone know what else I can try?  Thanks.

View 9 Replies View Related

Transaction Context In User By Another Session

Feb 29, 2008

Im using SQL Server 2000 sp2 for ASP application on windows server 2003 sp2.

Im getting an error 'Transaction context in user by another session'.

I have not at all used BEGINTRANS / committrans , No Insert / Update statements.
the kind of SQL statements that i was using in that page load is only "SELECT statements"

Can any one give me answer how to get rid of this. I have used only one connection object. and result set as a loop containing few more result sets. But I m sure they are so complex statements to block the SQL server transactions.



Awaiting for reply..................

View 1 Replies View Related

Error: Transaction Context In Use By Another Session

Oct 30, 2006

I am programming in ASP and SQL server.

I am using this tag <%Transaction=Required%> to do the transaction.

And it woks well, but the problem is that sometimes I get this error: "transaction context in use by another session"...

It's really weird because it only happens in the same row. If choose this row to be shown I get that message, but if choose another row I get result with no error. And if take out the tag <%Transaction... I don't get any error.

I've searched in other forums about this error, and one guy claims that there is a bug in the MTS and there is no way to solve the problem.

View 2 Replies View Related

Transaction Context In Use By Another Session Error In C# Sp From Trigger

May 12, 2006

I have a c# stored procedure that is being called from a trigger. When I execute it from management studio, it works just fine. But, when I update a record in the table that has the trigger that calls the sp, I get the error "transaction context in use by another session error". I've tried a few of the "fixes" that I found through searching, but so far nothing seems to work. What I've tried so far is...

Removing the transaction from my code
making sure my code is only using 1 connection
setting XACT_ABORT ON

Any other ideas? Thanks.

View 1 Replies View Related

Linked Server Exec Stored Procdure Results In Transaction Context In Use By Another Session.

Nov 3, 2005

I am using sql 2005 beta

View 23 Replies View Related

Error 8525: Distributed Transaction Completed. Either Enlist This Session In A New Transaction Or The NULL Transaction.

May 31, 2008

Hi All

I'm getting this when executing the code below. Going from W2K/SQL2k SP4 to XP/SQL2k SP4 over a dial-up link.

If I take away the begin tran and commit it works, but of course, if one statement fails I want a rollback. I'm executing this from a Delphi app, but I get the same from Qry Analyser.

I've tried both with and without the Set XACT . . ., and also tried with Set Implicit_Transactions off.

set XACT_ABORT ON
Begin distributed Tran
update OPENDATASOURCE('SQLOLEDB','Data Source=10.10.10.171;User ID=*****;Password=****').TRANSFERSTN.TSADMIN.TRANSACTIONMAIN
set REPFLAG = 0 where REPFLAG = 1
update TSADMIN.TRANSACTIONMAIN
set REPFLAG = 0 where REPFLAG = 1 and DONE = 1
update OPENDATASOURCE('SQLOLEDB','Data Source=10.10.10.171;User ID=*****;Password=****').TRANSFERSTN.TSADMIN.WBENTRY
set REPFLAG = 0 where REPFLAG = 1
update TSADMIN.WBENTRY
set REPFLAG = 0 where REPFLAG = 1
update OPENDATASOURCE('SQLOLEDB','Data Source=10.10.10.171;User ID=*****;Password=****').TRANSFERSTN.TSADMIN.FIXED
set REPFLAG = 0 where REPFLAG = 1
update TSADMIN.FIXED
set REPFLAG = 0 where REPFLAG = 1
update OPENDATASOURCE('SQLOLEDB','Data Source=10.10.10.171;User ID=*****;Password=****').TRANSFERSTN.TSADMIN.ALTCHARGE
set REPFLAG = 0 where REPFLAG = 1
update TSADMIN.ALTCHARGE
set REPFLAG = 0 where REPFLAG = 1
update OPENDATASOURCE('SQLOLEDB','Data Source=10.10.10.171;User ID=*****;Password=****').TRANSFERSTN.TSADMIN.TSAUDIT
set REPFLAG = 0 where REPFLAG = 1
update TSADMIN.TSAUDIT
set REPFLAG = 0 where REPFLAG = 1
COMMIT TRAN


It's got me stumped, so any ideas gratefully received.Thx

View 1 Replies View Related

SSIS, Distributed Transaction Completed. Either Enlist This Session In A New Transaction Or The NULL Transaction.

Feb 22, 2007

I have a design a SSIS Package for ETL Process. In my package i have to read the data from the tables and then insert into the another table of same structure.

for reading the data i have write the Dynamic TSQL based on some condition and based on that it is using 25 different function to populate the data into different 25 column. Tsql returning correct data and is working fine in Enterprise manager. But in my SSIS package it show me time out ERROR.

I have increase and decrease the time to catch the error but it is still there i have tried to set 0 for commandout Properties.

if i'm using the 0 for commandtime out then i'm getting the Distributed transaction completed. Either enlist this session in a new transaction or the NULL transaction.

and

Failed to open a fastload rowset for "[dbo].[P@@#$%$%%%]". Check that the object exists in the database.

Please help me it's very urgent.

View 3 Replies View Related

Setting A Schema Context For A Session

Apr 25, 2006

Is there a way to specify a given Schema as the currently active one for a given database session ? i.e. im looking for somthing like:

Use Schema=<name>

Execute Queries / Stored Procs, etc

.....

I want all the Queries and Stored Procs to execute on the Schema set initially.

I can't use the Default_Schema on the User to do this due to certain restrictions in the way we create users and Schemas.

I know that i can always qualify the objects in the Queries with a Schema Name, but i have a requirement where the Queries need to be generic in nature and need to run on one of many identical schemas in the Database. Is this Possible in Sql Server?

Any help will be greately appreciated.

Thanks

View 3 Replies View Related

Distributed Transaction Completed. Either Enlist This Session In A New Transaction Or The NULL Transaction.

Feb 6, 2007

I am getting this error  :Distributed transaction completed. Either enlist this session in a new
transaction or the NULL transaction. Description:
An unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the error and
where it originated in the code. Exception Details:
System.Data.OleDb.OleDbException: Distributed transaction completed. Either
enlist this session in a new transaction or the NULL transaction.have anybody idea?!

View 1 Replies View Related

Distributed Transaction Completed. Either Enlist This Session In A New Transaction Or The NULL Transaction.

Dec 22, 2006

i have a sequence container in my my sequence container i have a script task for drop the existing tables. This seq. container connected to another seq. container. all these are in for each loop container when i run the package it's work fine for 1st looop but it gives me error for second execution.

Message is like this:

Distributed transaction completed. Either enlist this session in a new transaction or the NULL transaction.

View 8 Replies View Related

Distributed Transaction Completed. Either Enlist This Session In A New Transaction Or The NULL Transaction. (HELP)

Jan 8, 2008

Hi,

i am getting this error "Distributed transaction completed. Either enlist this session in a new transaction or the NULL transaction.".

my transations have been done using LINKED SERVER. when i manually call the store procedure from Server 1 it works but when i call it through Service broker it dosen't work and gives me this error.



Thanks in advance.


View 2 Replies View Related

Context Connection Transaction

Feb 24, 2006

Hello Guys,

I need some some clarifications on how Context connections and transactions inter operate in CLR.

The context connection allows for ADO objects to be " running in the same transaction space". So the association to the current transaction is implied. So as long as I set for example my SqlCommand to use the context connection I am going to be running under the same transaction.

SqlConnection sqlConn = new SqlConnection("context connection=true");
SqlCommand sqlComm = new SqlCommand("EXEC myCommand", sqlConn);

I guess my ambiguity comes from the fact that the Transaction is not specifically specified.

In addition what happens upon a trigger that for example watches and insert on a table? If the insert occurs under a transaction, I would assume that I will be also picking up that transaction in the CRL Trigger, thus the whole operation would seem atomic.

Thank you,

Lubomir

View 1 Replies View Related

Using LINQ And Context Acts Like It Is In Transaction.

Apr 18, 2008

I am using VS2008 Team Edition under Vista with SQL Compact 3.5

I am trying to develop an app using C# and LINQ and take advantage of the Sync services. The problem is that everything seems to work but nothing ever really gets saved out to the local .sdf file. I have all the SQL commands logged to the the console and they seem fine. I have SubmitChanges() wrapped in a try/catch and no exceptions are thrown. When I requery the context for the data the new added rows do show up. If while the application is open, I go to VS2008 and query the file I just added to, I don't see the new rows. If I exit the application and try I still don't see them. If I restart the application the rows show up. If I exit the app and refresh the connection to the .sdf file in VS and then restart the application the inserted records are gone.

They act exactly as if when I made my connection to the database I started a transaction (which I didn't do, at least no explicitly) that I never commit. Did I miss some basic point about opening a connection to SQL compact?

I connect when the app launches and I store the context in a member variable of my class which doesn't go out of scope until the application quits. I tried creating a new connection in a local method right around the call to SubmitChanges() but it behaved the same.

Below is the console output from adding the record and then updating it (two calls to SubmitChanges() )



INSERT INTO [Milestone]([Milestone_Key], [MilestoneType_Key], [Inspection_Key], [MilestoneDate], [Description], [RowVersion], [ModifiedOn], [ModifiedBy_Key], [CreationDate])

VALUES (@p0, @p1, @p2, @p3, @p4, @p5, @p6, @p7, @p8)

-- @p0: Input Guid (Size = 0; Prec = 0; Scale = 0) [74ec904a-0c8d-46e5-8bea-af066d2c2f79]

-- @p1: Input Int32 (Size = 0; Prec = 0; Scale = 0) [3]

-- @p2: Input Guid (Size = 0; Prec = 0; Scale = 0) [57702e12-e0d8-487e-bf80-8066bf9ebdd5]

-- @p3: Input DateTime (Size = 0; Prec = 0; Scale = 0) [4/17/2008 6:50:52 PM]

-- @p4: Input String (Size = 0; Prec = 0; Scale = 0) []

-- @p5: Input Binary (Size = 8; Prec = 0; Scale = 0) []

-- @p6: Input DateTime (Size = 0; Prec = 0; Scale = 0) [4/17/2008 6:50:52 PM]

-- @p7: Input Int32 (Size = 0; Prec = 0; Scale = 0) [0]

-- @p8: Input Int64 (Size = 0; Prec = 0; Scale = 0) [0]

-- Context: SqlProvider(SqlCE) Model: AttributedMetaModel Build: 3.5.21022.8

SELECT [t0].[Milestone_Key], [t0].[MilestoneType_Key], [t0].[Inspection_Key], [t0].[MilestoneDate], [t0].[Description], [t0].[RowVersion], [t0].[ModifiedOn], [t0].[ModifiedBy_Key], [t0].[CreationDate]

FROM [Milestone] AS [t0]

WHERE [t0].[Inspection_Key] = @p0

ORDER BY [t0].[MilestoneDate]

-- @p0: Input Guid (Size = 0; Prec = 0; Scale = 0) [57702e12-e0d8-487e-bf80-8066bf9ebdd5]

-- Context: SqlProvider(SqlCE) Model: AttributedMetaModel Build: 3.5.21022.8

The thread 0x2604 has exited with code 0 (0x0).

UPDATE [Milestone]

SET [Description] = @p7

WHERE ([Milestone_Key] = @p0) AND ([MilestoneType_Key] = @p1) AND ([Inspection_Key] = @p2) AND ([MilestoneDate] = @p3) AND ([RowVersion] IS NULL) AND ([ModifiedOn] = @p4) AND ([ModifiedBy_Key] = @p5) AND ([CreationDate] = @p6)

-- @p0: Input Guid (Size = 0; Prec = 0; Scale = 0) [74ec904a-0c8d-46e5-8bea-af066d2c2f79]

-- @p1: Input Int32 (Size = 0; Prec = 0; Scale = 0) [3]

-- @p2: Input Guid (Size = 0; Prec = 0; Scale = 0) [57702e12-e0d8-487e-bf80-8066bf9ebdd5]

-- @p3: Input DateTime (Size = 0; Prec = 0; Scale = 0) [4/17/2008 6:50:52 PM]

-- @p4: Input DateTime (Size = 0; Prec = 0; Scale = 0) [4/17/2008 6:50:52 PM]

-- @p5: Input Int32 (Size = 0; Prec = 0; Scale = 0) [0]

-- @p6: Input Int64 (Size = 0; Prec = 0; Scale = 0) [0]

-- @p7: Input String (Size = 0; Prec = 0; Scale = 0) [added a record then changed a field and re-saved.]

-- Context: SqlProvider(SqlCE) Model: AttributedMetaModel Build: 3.5.21022.8

View 1 Replies View Related

New Transaction Is Not Allowed Because There Are Other Threads Running In The Session. - H&#228;h?

Apr 3, 2006

That is a SqlException I got at a...
at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()
Anyone an idea what THAT means? How do I cause it? How can I work around it?

View 4 Replies View Related

Is The Transaction Context Available Within A 'called' Stored Procedure For A Transaction That Was Started In Parent Stored Procedure?

Mar 31, 2008

I have  a stored procedure 'ChangeUser' in which there is a call to another stored procedure 'LogChange'. The transaction is started in 'ChangeUser'. and the last statement in the transaction is 'EXEC LogChange @p1, @p2'. My questions is if it would be correct to check in 'LogChange' the following about this transaction: 'IF @@trancount >0 BEGIN Rollback tran' END Else BEGIN Commit END.
 Any help on this would be appreciated.

View 1 Replies View Related

SQL Server Session State - Using A 1.1 Database Schema For 2.0 Session State Storage

Aug 3, 2006

The 2.0 version of ASPSTATE is slightly different than the 1.1 version in that one table has one additional column and another table uses a different data type and size for the key. The 2.0 version also has a couple additional stored procedures.

We'd like to manage just one session state database if possible so we're trying to figure out if Microsoft supports using the new schema for 1.1 session state access (it seems to work, but our testing has been very light).

Is there any official support line on this? If not, can anyone comment on whether or not you'd expect it to work and why?

Thanks.

View 1 Replies View Related

Session

Sep 20, 2001

Hi all,

I need some solution..
When i execute a program it first deletes all datas from a
'X' table .Then fetches data from various other tables and
inserts into this 'X' table.I finally generate a report from
this 'X' table.

Now the problem is,
USER 1 : Executes the program - Datas in 'X' table got deleted and
filled up with new data.Report is getting processed.....
USER 2 : Executes the same program - Datas in the same 'X' table
getting deleted ..
So the report process of USER 1 got affected.

Solution 1 : Using IP address of local machine i solved the problem.But
i need a concrete solution for this ..something related to sessions..

CAN ANYONE HELP ??

Thanx and Regards
Prabhu

View 2 Replies View Related

Session

Feb 1, 2006

Does Session term exist in SQL Server?If yes, when it creates, how can monitor it. And where does itsinformation store?Thanks alot

View 1 Replies View Related

Return ID From SQL Into Session

Jun 5, 2008

How do you return the ID of an item to a Session in a ASP forum?
I have a MS-SQL Server 2005 database.
My table looks like this QuoteID, QuoteNumber, Date.
In SQL:
INSERT INTO table (QuoteNumber, Date) values ('123490WC1", '06/2/2008')DECLARE @ItemID INTSET @ItemID=IDENT_CURRENT('table')
What I would like to do is return @ItemID to the ASP forum; I assume Session would be the best.
After I get the @ItemID I have a Grid which I will to insert the Quote Items into.
Thanks,
marly

View 1 Replies View Related

Session Parameters

Jun 16, 2008

Hi, Can somebody tell me what's wrong with this statement or why the Session parameter is not working.
   <asp:SqlDataSource ID="datalist_SQL" runat="server"
ConnectionString="<%$ ConnectionStrings:DatabaseConnectionString2 %>"
SelectCommand="SELECT * FROM tbl_subProduct, tbl_material, tbl_product, tbl_subCategory, tbl_topCategory, tbl_topLevelProduct WHERE [tbl_subProduct].[numProductID] = [tbl_product].[numProductID] AND [tbl_product].[numTopLevelProductID] = [tbl_topLevelProduct].[numTopLevelProductID] AND [tbl_topLevelProduct].[numSubCategoryID] = [tbl_subCategory].[numSubCategoryID] AND [tbl_subCategory].[numTopCategoryID] = [tbl_topCategory].[numTopCategoryID] AND [tbl_material].[numMaterialID] = [tbl_product].[numMaterialID] AND @fldArray ">
<SelectParameters>
<asp:SessionParameter Name="fldArray" SessionField="ids_array" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource> Many Thanks

View 10 Replies View Related

Session Variable Help!!!!!

Oct 29, 2004

Hi...
I'm developing a web app with VS 2005 Beta and I do not know how to include a seasson variable value into my code.

This is my code:

Function GetData() As System.Data.SqlClient.SqlDataReader
Dim sqlconn As System.Data.SqlClient.SqlConnection
Dim SqlCommand1 As System.Data.SqlClient.SqlCommand
Dim sqlRdr As System.Data.SqlClient.SqlDataReader
sqlconn = New SqlConnection("SERVER=SRVR;UID=USR;Password=PWD;DATABASE=MyDatabase")
sqlconn.Open()
SqlCommand1 = New SqlCommand("MyStrProc", sqlconn)
SqlCommand1.CommandTimeout = 1800
sqlRdr = SqlCommand1.ExecuteReader(CommandBehavior.CloseConnection)
Return sqlRdr
End Function

MyStrProc is:

CREATE PROCEDURE MyStrProc
@MyVar int
AS
IF @MyVar IS NOT NULL
BEGIN
.................
......t12.acct_nbr IN (@MyVar)
.....
END
GO

The variable @MyVar get its value from user log info in login page, and create a session variable.

My Question:

How and where to call seasson variable @MyVar, because now I'm getting this error:
Procedure 'MyStrProc' expects parameter '@MyVar', which was not supplied.

Any help will be great.

Tks

View 4 Replies View Related

Get Data From SQL To Session

Jan 13, 2006

I'm new on ASP.NET 2.0Can anyone tell me how to get data from SQL to Session properties?
In Classic ASP, it looks very simple as below.dim connset conn = server.createobject("adodb.recordset")rssql = "select myid, mypw from mydb where myid = '"& request("myid") &"' and mypw = '"& request("mypw") &"'"set rs = conn.execute(rssql)if rs.eof = true thensession("myid") = rs("myid")session("mypw") = rs("mypw")end if
How to do the same things on ASP.NET?Many thanks!

View 6 Replies View Related

How To Find Session Id

Sep 1, 2006

How to find user session id in mssql

View 1 Replies View Related

New Session Inside SP?

Sep 16, 2004

Hi:

I want to open a new session/connection inside the execution of a stored procedure. Is this possible ?
I ask this because I need a new sesssion with its own transaction.

Thanks,
Rui Ferreira

View 6 Replies View Related

Session Variable

Jun 22, 2007

Can we use session variable in reporting services.. say go to report -> properties and create a VB function that get ans set session variable.. If yes, how. If not, any workaround?

View 2 Replies View Related

Terminal Session Name

May 9, 2006

Is there any way in stored procedure to find out a name of terminal session initiated connection to SQL Server?

Thanks for response

View 10 Replies View Related

Transactions Over Session

Oct 17, 2007

Hi guys,

I would like to manage the following:
BEGIN TRANSACTION;
SELECT * From SomeTable;
INSERT INTO SomeTable (SomeData) VALUES(12);
COMMIT TRANSACTION;

This should be easy usually. However, we need to have each row/command executed individually (using the SqlDataSource object in ASP.NET).

Is there a way how to make the transactions work over multiple executions?

Thanks,

Martin

View 4 Replies View Related

Asp.net Session Has Expired

Jul 11, 2006

Hi

I have designed reports using SQL Server Business Intelligence Development Studio tool (Sql Server reporting service). I have uploaded these reports to report manager.

I am displaying list of reports in tree view control, in my application. I am viewing report in Report Viewer control as per the report selection in tree view control, in same page. I am getting

Server Error in '/Application_name' Application or
ASP.NET session has expired error frequently while switching between various reports. Kindly provide me solution


.





Regards

Sagayaraj Rayappan

View 11 Replies View Related

Database Context

Apr 29, 2003

Hi,

I am trying to create a block of sql statements that will read the sysdatabases table, and store the value of the database in a variable.

I want to use a cursor to step through all these databases (excep of course the control databases).

For each of the databases I want to run a backup log followed by dbcc shrinkfile. For dbcc shrinkfile, I need to change the database context.

What I am finding is that I cannot use the variable to hold the database name.

here is the code

-------------------------

SET NOCOUNT ON
DECLARE @db_name varchar(100)
DECLARE @db_filename varchar(100)

DECLARE list_dbs Cursor
FOR select [name] from master..sysdatabases

OPEN list_dbs

FETCH NEXT FROM list_dbs into @db_name

WHILE @@FETCH_STATUS = 0
BEGIN

select name = @db_filename from @db_name..sysfiles

backup log @db_name with no_log

use @db_name

dbcc shrinkfile (@db_filename, 25)


FETCH NEXT FROM list_dbs into @db_name

END

CLOSE list_dbs
DEALLOCATE list_dbs
-----------------------

I get a syntax error where ever the @db_name is used (on the select and on the use).

Any suggestions?

Thanks,

Jim

View 7 Replies View Related

Dynamic Sql Context ...

Apr 11, 2008

Hi,
I need to build up dynamically cursor and fetch variables in a script. I use exec(@sql) to declare the cursor and my hope was I could use the same method for doing the fetch. Unfortunately I run into a

Must declare the scalar variable "@c1".

Here's the part of the code:
... snippet

DECLARE @c1 varchar(max)
DECLARE @c2 char(3)
DECLARE @c3 char(3)
DECLARE @c4 char(3)
DECLARE @c5 char(3)
DECLARE @c6 char(3)
DECLARE @c7 char(3)
DECLARE @c8 char(3)
DECLARE @c9 char(3)
DECLARE @c10 char(3)
DECLARE @c11 char(3)
DECLARE @c12 char(3)
DECLARE @c13 char(3)
DECLARE @c14 char(3)
DECLARE @c15 char(3)
DECLARE @c16 char(3)
DECLARE @c17 char(3)
DECLARE @c18 char(3)
DECLARE @c19 char(3)
DECLARE @c20 char(3)
DECLARE @c21 char(3)
DECLARE @c22 char(3)
DECLARE @c23 char(3)
DECLARE @c24 char(3)
DECLARE @sql VARCHAR(MAX)
DECLARE @insert VARCHAR(MAX)
DECLARE @fetch varchar(max)


SET @sql ='DECLARE C1 CURSOR FOR SELECT * FROM OPENROWSET(' +
@apo+@int_provider_name+@apo+ ',' +
@apo+@int_provider_string+@apo + ',' +
@apo+@int_query_string+@apo +
') FOR READ ONLY'
PRINT @sql
EXEC(@SQL)

OPEN c1


set @fetch = 'FETCH c1 INTO '+@int_fetch
print @fetch
EXEC (@fetch)

... snippet

Output:
DECLARE C1 CURSOR FOR SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=C:work2007schenker.xls','SELECT * FROM [Datei$]') FOR READ ONLY

FETCH c1 INTO @c1,@c2,@c3,@c4,@c5,@c6,@c7,@c8,@c9,@c10,@c11,@c12,@c13,@c14,@c15,@c16,@c17,@c18,@c19,@c20,@c21,@c22,@c23,@c24

Msg 137, Level 15, State 2, Line 1
Must declare the scalar variable "@c1".

How can I declare the dynamically built 'fetch into' variables (@c1 etc.) so they are in the context of dynamic sql ?

Thanks: Peter

View 1 Replies View Related

Not Permitted In This Context

Jul 19, 2006

Hi,I am having a SQL Server 2005 problem with my Insert statement. I amsending a command via my website to my database. It comes up with anerror I'll put below. The code is here:"INSERT INTO tblUsers (userName) VALUES ( userNameTest)"This is the error I get:The name "userNameTest" is not permitted in this context. Validexpressions are constants, constant expressions, and (in some contexts)variables. Column names are not permitted.Now, userName is a varchar field in the database. What is wrong?Kivak

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved