If I execute multiple SqlCommands in a single .aspx, using a single SqlConnection, are all the commands part of the same transaction?
That is, if I say:
cmd1.CommandText = "UPDATE foo SET myVal = myVal - 1"
cmd2.CommandText = "SELECT myVal FROM foo"
cmd1.Connection = myConn
cmd2.Connection = myConn
myConn.Open()
cmd1.ExecuteNonQuery() ' decrement myVal
intResult = CInt(cmd2.ExecuteScalar()) ' select value of myVal
myConn.Close()
Do the UPDATE and the SELECT happen in the same transaction, or is it possible that someone else would have changed the value of myVal between these two calls?
I know i can use the sentence SET IMPLICIT_TRANSACTIONS ON in a Stored Procedure to force SQL Server to set the connection into implicit transaction mode.
Have i a sentence or configuration to force all SQL Server connections to implicit transaction mode?
I'm receiving the below error when trying to implement Execute SQL Task.
"The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION." This error also happens on COMMIT as well and there is a preceding Execute SQL Task with BEGIN TRANSACTION tranname WITH MARK 'tran'
I know I can change the transaction option property from "supported" to "required" however I want to mark the transaction. I was copying the way Import/Export Wizard does it however I'm unable to figure out why it works and why mine doesn't work.
I'm investigating a poorly performing procedure that I have never seen before. The procedure sets the transaction isolation level, and I suspect it might be doing so incorrectly, but I can't be sure. I'm pasting a bastardized version of the proc below, with all the names changed and the SQL mucked up enough to get through the corporate web filters.
The transaction isolation level is set, but there is no explicit transaction. Am I right that there are two implicit transactions in this procedure and each of them uses snapshot isolation?
SET NOCOUNT ON; SET TRANSACTION ISOLATION LEVEL SNAPSHOT; DECLARE @l_some_type varchar(20), @some_type_code varchar(3), @error int, @error_msg varchar(50);
Can anybody tell me that how can i configure the things that will show my main report page when i enter Url like http://localhost/ReportServer. It gives directory struction first & then we have to select particular report
If I send multiple sql's with ado.net in one statement (one executeSql separated by semilcolons), and the second one fails, will the first one be rolled back? or do I need to put it all in a transaction?
Hi all, We are getting "New request is not allowed to start because it should come with valid transaction descriptor" when using transactions against SQL 2005. As I understand it, it's a bug that occurs after some statement has terminated against the database; see http://lab.msdn.microsoft.com/productfeedback/ViewWorkaround.aspx?FeedbackID=FDBK46530#1
Now, I wonder if there is a hotfix coming soon on this?
I get this error message when I try to connect to Reporting Services via the Management Studio.
I can see my machine listed in the Server Name > Browse For More > Local Servers dialogue. But no luck,
Ive tried:
Servername: localhost Servername: DED1774 (the machine name) Servername: localhost/reportserver Servername: DED1774/reportserver Servername: http://ded1774/reportserver (from the rsreportserver.config file
<UrlRoot>http://ded1774/reportserver</UrlRoot>)
I've Googled the error message and found postings for solutions, but none of these helped. Can anyone suggest some simple steps I can take to try to find the issue and get the connection working?
I have created one reports but all the records are displaying on one page.find a solution to display the records page by page. I created the same report without group so the records are displaying in page by page.
I have a report that has 3 nested lists. The report looks fine when I view it in the browser but when I print it or export it to another format it appears that keep together is on for each list because some pages are only partially filled. I do not have keep together turned on for any report control, and I don't have page break turned on for anything. This problem results in the report being many more pages than it needs to be. Can anyone help?
Hi Everyone- i have a report that include parameters that the user set and press the button ViewReport for rendering the report until that everything ok,.. .......but assume that there is an updating occurred on data after the user make the first press on the button ViewReport.
The problem is if the user press the button ViewReport again for the second time without changing the parameter value the report result will be the same even though it is the old data that appear in the 1st press button.
can anyone tell me how to handle this problem to make it refresh when the ViewReport button is pressed or if there is no solution can anyone provide me with a link that talks about that problem for more details
I am running into a problem which seems to indicate SQL Server 2005 is pretty aggressive with its implicit conversion which makes UNPIVOT apparently unusable for my current task of creating attribute/value pairs of strings for each of the records unpivoted around the primary key.
WITH cte as
(
SELECT 1 as Code, '2' as Status, 'Some Guy' as CreatedBy, Convert(varchar(19), getdate(), 120) as CreatedDate
)
SELECT
[Code]
,[Attribute]
,[Value]
FROM
cte
UNPIVOT([Attribute] FOR [Value] IN ([Status],[CreatedBy],[CreatedDate])) as U;
Msg 8167, Level 16, State 1, Line 1
The type of column "CreatedBy" conflicts with the type of other columns specified in the UNPIVOT list.
The same result shows up if I use an inner SELECT instead of the CTE:
SELECT
[Code]
,[Attribute]
,[Value]
FROM
(
SELECT 1 as Code, '2' as Status, 'Some Guy' as CreatedBy, Convert(varchar(19), getdate(), 120) as CreatedDate
) cte
UNPIVOT([Attribute] FOR [Value] IN ([Status],[CreatedBy],[CreatedDate])) as U;
It seems to me that some arbitrary decision about what column is processed first is made and the process fails as soon as a column is met which is not of the same datatype. I also think it is interesting that the engine will implicitly cast from varchar to DateTime but not the other way around.
I am trying to construct a query in Query Analyzer (with SQL Server 2000), but am getting an error regarding "implicit conversion."
Here is the query:
SELECT dbo.AUCTION.EbayNum, dbo.AUCTION.EndDate, DATENAME([month], dbo.AUCTION.EndDate) + ' ' + DATENAME([year], dbo.AUCTION.EndDate) AS [PmtMonth], dbo.LOT.Description, dbo.AUCTION.WinBid, PaidStat = CASE dbo.AUCTION.PaidStatus WHEN 0 THEN '' ELSE 'PAID' END, PaidAmt = CASE dbo.AUCTION.PaidStatus WHEN 0 THEN '' ELSE dbo.AUCTION.WinBid END FROM dbo.AUCTION INNER JOIN dbo.LOT ON dbo.AUCTION.LotNum = dbo.LOT.LotNum WHERE (LEN(dbo.AUCTION.Winner) > 0)
The error occurs in the PaidAmt CASE statment: "Implicit conversion from data type varchar to money is not allowed. Use the CONVERT function to run this query."
Why is there an implicit conversion going on? And how can I fix it? :mad:
Hi, I'm using this code to export record from sql to excel and i got this error message "Implicit conversion from data type text to nvarchar is not allowed. use the convert function to run this query"
Excel file is already created columns in the view and excel file are the same and cell format of the excel is converted to text.
--- code used insert into OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database=c:filename.xls;', 'SELECT * FROM [filename$]') select * from ViewName
Is there any difference between explicit inner join and implicitinner joinExample of an explicit inner join:SELECT *FROM employeeINNER JOIN departmentON employee.DepartmentID = department.DepartmentIDExample of an implicit inner join:SELECT *FROM employee, departmentWHERE employee.DepartmentID = department.DepartmentID
I have a sql statement that must run in both sql server and oracle. I can't change the sql statement as it is created as part of a core application from Rational Rose.
Basically the problem is that I have a table with a column defined as a decimal type in sql server (numeric in oracle).
The select statement, however, treats the column as a char. I can reproduce the problem with this simple code:
create table atest2 (a decimal(9,0))
insert into atest2 values (1)
insert into atest2 values (2)
insert into atest2 values (null)
insert into atest2 values (4)
select * from atest2 where a = ' '
This gives the error:
Error converting data type varchar to numeric.
The documents seem to indicate the sql server will implicitly convert decimals to varchar but this doesn't seem to be happening. Is there an environment setting that might control this?
have a sql statement that must run in both sql server and oracle. I can't change the sql statement as it is created as part of a core application from Rational Rose.
Basically the problem is that I have a table with a column defined as a decimal type in sql server (numeric in oracle).
The select statement, however, treats the column as a char. I can reproduce the problem with this simple code:
create table atest2 (a decimal(9,0))
insert into atest2 values (1)
insert into atest2 values (2)
insert into atest2 values (null)
insert into atest2 values (4)
select * from atest2 where a = ' '
This gives the error:
Error converting data type varchar to numeric.
The documents seem to indicate the sql server will implicitly convert decimals to varchar but this doesn't seem to be happening. Is there an environment setting that might control this?
Hi: I get this following error when I run try to insert a record from the DetailsView. Please help me out. --------------------------------------------------------------------------------------------------------------------- Disallowed implicit conversion from data type sql_variant to data type uniqueidentifier, table 'getsetwin.lax21.tblCreateGoal2', column 'ApplicationId'. Use the CONVERT function to run this query.Disallowed implicit conversion from data type sql_variant to data type uniqueidentifier, table 'getsetwin.lax21.tblCreateGoal2', column 'UserId'. Use the CONVERT function to run this query.Operand type clash: sql_variant is incompatible with image --------------------------------------------------------------------------------------------------------------------- Thank you & Best regards, Lax
I am using the HitSoftware driver to pass data to an AS400 from a SQL 7 database. Data makes it fine to 2 of the 4 tables but I cannot get the syntax correct to even get out of the S/P edtitor in SQL for the other 2.
I have fields in the SQL S/P defined as VARCHAR. The target fields on the AS400 are ALPHA. So I figured the insert statement to look like:
If i create a simple table with a foreign key constraint, does itcreate an implicit index on that given ID? I've been told this isdone in some databases, but i need to know for sure if SQL Server doesit. Has anyone heard of this before, on any other databses perhaps?Heres an example of how the foreign key constraint is being added:ALTER TABLE [dbo].[administrators] WITH CHECK ADD CONSTRAINT[FPSLUFSUOXZGAJOJ] FOREIGN KEY([AdministratorRoleID])REFERENCES [dbo].[administratorroles] ([AdministratorRoleID])My initial testing seems to indicate adding an index on the foreignkey column helps, but i need to know for sure. Any insight would begreatly appreciated!Bob
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
I am using SQL Server 2000. I have created a Store Procedure to insert information, 4 of the fields are date types. I am using OleDb Data Provider (System.Data.OleDb) namespace.
The dates are filled by a form (web form) on submit event, I created a class that has functions to create my OleDb Parameters. I add the parameters to the command and execute it through a SQL Server Stored Procedure. In the event that I must have coded something wrong, I tested in the SQL Query Analyzer and the IN parameters for the date I used the getDate() method. This is where I know it is OleDb and SQL Server Parameters.
What Converstion Format should I use in the SP for the date? OleDb.date are doubles from some date in 1979 or something or another. So I used an OleDbDataType.DBDate. It seems that when the Stored Procedure uses the IN Parameters dates provided by OleDbDataType.Date or DBDate, that it doesn't like the int format. I am guessing that I am not converting the date in the parameters in the Insert of the Store Procedure... this is basically what I have...
Function to add parameters and execute SP
private int _startdate = DateTime.Now; private int _finishdate = DateTime.Now.AddDays(30);
CREATE PROCEDURE myInsert @StartDate datetime, @FinishDate datetime AS
INSERT INTO myTable (STARTDATE, FINISHDATE) VALUES (Convert(datetime, @StartDate), Convert(datetime, @FinishDate))
Please keep in mind that I am using System.Data.OleDb namespace..... please don't tell me to use SQLClient, it seems since I've been so adaptive of using OleDb, that it sould work just as well. I am way too far into this to change my Provider to SQL Client, but I promise myself that the next project (if using SQL Server, I will be using SQLClient and I will keep using OleDb for Oracle.) *sigh*
In a stored procedure, the following code is causing a huge read and CPU load when it really shouldn't. The @IDParameter below is coming in as a parameter to the proc.
Here's the snippet of code where the problem is coming in:
DECLARE @ID INT; SET @ID = (SELECT ID From OtherTable WHERE FKID = @IDParameter); SELECT COUNT(*) FROM LargeTable
WHERE MostlyZeroID = @ID AND MostlyZeroID > 0Most (90+%) of the MostlyZeroID rows are 0 (hence the name) but regardless of distribution this should evaluate with minimal work on SQL Server's part to 0. However, when this was run, it is using a ton of CPU and doing a ton of Reads as it seeks through the entire index. When I look at the execution plan, I see under the seek predicate a Scalar Operator(CONVERT_IMPLICIT(int,[@1],0)) which is what is destroying the performance.
I've confirmed that the MostlyZeroID column in the LargeTable is defined as an INT NOT NULL. I also tested the scenario outside the stored procedure without any variables as the following to make sure it wasn't some kind of strange parameter sniffing scenario:
SELECT COUNT(*) FROM LargeTable WHERE MostlyZeroID = 0 AND MostlyZeroID > 0
However, this query also did the implicit conversion. I then tried this out on a temp table populated with a similar number of records (100 million) with a similar distribution and I didn't get the implicit conversion (I got a constant scan as I would've expected) when I did this:
SELECT COUNT(*) FROM #TestTable WHERE MostlyZero = 0 AND MostlyZero > 0
I also tried the same on several other tables that are set up similarly (large amount of zeros in an INT column) and I always got a constant scan and didn't do an implicit conversion.
why the query engine is interpreting this 0 as something other than an INT and doing an implicit conversion when getting the count in the scenario above? What can be done to protect against it? In the above scenario, an IF @ID > 0 statement was placed before the code including the count since there was no reason to even run the code if the @ID was equal to zero.
I am facing a problem while using SQL Server with VB application.Implicit conversion from datatype text to nvarchar is not allowed.Use the convert function to run this query.When i see the trace file, i see one stored procedure called but nolines of code get executed, and immediately after that the ROLLBACKTRANSACTION occurs and the applications fails.But to my surprise i am able to do the same thing on a differentmachine using the same application and the same database on the sameserver with the same user id.Can anyone explain the reason of occurance of this problem.I require this very urgently, so i will be oblized if anyone can comeup with a quick response.Kind Regards,Amit Kumar
CREATE ASSEMBLY asmRANDRTCalendaringGateway FROM 'E:sqlRANDRTCalendaringGateway.dll' WITH PERMISSION_SET = UNSAFE
I get this error ...
Msg 10301, Level 16, State 1, Line 1 Assembly 'RANDRTCalendaringGateway' references assembly 'system.web, version=2.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a.', which is not present in the current database. SQL Server attempted to locate and automatically load the referenced assembly from the same location where referring assembly came from, but that operation has failed (reason: 2(The system cannot find the file specified.)). Please load the referenced assembly into the current database and retry your request.
Even though I do not explicity refer to system.web in the DLL's code ...
using Microsoft.Win32; using System; using System.Data.Sql; using System.Data.SqlClient; using System.Collections.Generic; using System.Configuration; using System.Text; using log4net; using ADODB; using MAPI; using CDO; using System.Runtime.InteropServices;
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.