Error Retrieving Result From CLR Procedure

May 15, 2007

Hi,



We are using a simple CLR sp where an SQL statement is executed inside the same. THe execution happens in a server of different context that is connected inside CLR sp. The result set is returned in tabular format using pipe. But, when we access the result as below


create table #t(c1 int, c2 int, c3 int)
insert #t exec TestProc
select * from #t



it give the following error. Any help is appreciated. It seems to be some error with distibuted transaction. We tried adding BEgin Distributed trnasaction, but still the error comes.


Msg 6522, Level 16, State 1, Procedure TestProc, Line 0
A .NET Framework error occurred during execution of user-defined routine or aggregate "TestProc":
System.Transactions.TransactionException: The partner transaction manager has disabled its support for remote/network transactions. (Exception from HRESULT: 0x8004D025) ---> System.Runtime.InteropServices.COMException: The partner transaction manager has disabled its support for remote/network transactions. (Exception from HRESULT: 0x8004D025)
System.Runtime.InteropServices.COMException:
at System.Transactions.Oletx.ITransactionShim.Export(UInt32 whereaboutsSize, Byte[] whereabouts, Int32& cookieIndex, UInt32& cookieSize, CoTaskMemHandle& cookieBuffer)
at System.Transactions.TransactionInterop.GetExportCookie(Transaction transaction, Byte[] whereabouts)
System.Transactions.TransactionException:
at System.Transactions.Oletx.OletxTransactionManager.ProxyException(COMException comException)
at System.Transactions.TransactionInterop.GetExportCookie(Transaction transaction, Byte[] whereabouts)
at System.Data.SqlClient.SqlInternalConnection.EnlistNonNull(Transaction tx)
at System.Data.SqlClient.SqlInternalConnection.Enlist(Transaction tx)
at System.Data.SqlClient.SqlInternalConnectionTds.Activate(Transaction transaction)
at System.Data.ProviderBase.DbConnectionInternal.ActivateConnection(Transaction transaction)
at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()

at Class1.RunRemoteMetalProc()

Regards,

Kart

View 1 Replies


ADVERTISEMENT

Getting Error When Retrieving Data From Stored Procedure

Jan 9, 2008

Hi,
I'm at my wit's end with this. I have a simple stored procedure:
PROCEDURE [dbo].[PayWeb_getUserProfile] ( @user_id_str varchar(36), @f_name varchar(50) OUTPUT)AS
BEGINDECLARE @user_id uniqueidentifier;
SELECT @user_id = CONVERT(uniqueidentifier, @user_id_str);
select @f_name=f_name FROM dbo.tbl_user_profile WHERE user_id = @user_id;
ENDRETURN
The proc runs perfectly from the Management Console. In my ASP.net form (C#), the following always results in: "Invalid attempt to read when no data is present." (I'll highlight the line where the error results):
SqlConnection conn = new SqlConnection(<connection string data>);SqlDataReader reader;
SqlCommand comm = new SqlCommand("dbo.PayWeb_getUserProfile", conn);comm.CommandType = System.Data.CommandType.StoredProcedure;
SqlParameter f_name = new SqlParameter("@f_name", SqlDbType.VarChar, 50);
f_name.Direction = ParameterDirection.Output;comm.Parameters.Add(f_name);
comm.Parameters.Add("@user_id_str", SqlDbType.VarChar, 36).Value = Membership.GetUser().ProviderUserKey.ToString().ToUpper();reader = comm.ExecuteReader();Response.Write("Num: " + reader["@f_name"].ToString()); // ERROR: Invalid attempt to read when no data is present.
reader.Close();conn.Close();
The data is there. When I put a watch on 'Reader', I see the correct first_name data there.
Your help is appreciated.

View 8 Replies View Related

Retrieving Large Result Set.

Sep 11, 2001

Hello,
I have a web application which retrieves values from a table and the table has grown really huge now. This has slowed down the performance and I need to do something else instead of the select statement that I currently have. Can cursors be a solution?
Any help/suggestions would be greatly appreciated.

Thanks,
Subha

View 2 Replies View Related

Set Variable Based On Result Of Procedure OR Update Columns Fromsproc Result

Jul 20, 2005

I need to send the result of a procedure to an update statement.Basically updating the column of one table with the result of aquery in a stored procedure. It only returns one value, if it didnt Icould see why it would not work, but it only returns a count.Lets say I have a sproc like so:create proc sp_countclients@datecreated datetimeasset nocount onselect count(clientid) as countfrom clientstablewhere datecreated > @datecreatedThen, I want to update another table with that value:Declare @dc datetimeset @dc = '2003-09-30'update anothertableset ClientCount = (exec sp_countclients @dc) -- this line errorswhere id_ = @@identityOR, I could try this, but still gives me error:declare @c intset @c = exec sp_countclients @dcWhat should I do?Thanks in advance!Greg

View 4 Replies View Related

Saving Query Result To A File , When View Result Got TLV Error

Feb 13, 2001

HI,
I ran a select * from customers where state ='va', this is the result...

(29 row(s) affected)
The following file has been saved successfully:
C:outputcustomers.rpt 10826 bytes

I choose Query select to a file
then when I tried to open the customer.rpt from the c drive I got this error message. I am not sure why this happend
invalid TLV record

Thanks for your help

Ali

View 1 Replies View Related

[ActiveX Script Task] Error: Retrieving The File Name For A Component Failed With Error Code 0x001B6438.

Jul 28, 2006

This error occurs when the ActiveX task tries to execute:

[ActiveX Script Task] Error: Retrieving the file name for a component failed with error code 0x001B6438.

Anybody know how to troubleshoot these errors? I can't find anything on this error code. The same script works in DTS.







View 8 Replies View Related

Retrieving Data Using A Stored Procedure

Mar 31, 2007

I have created the following stored procedure and tried to retrieve it's output value in C#, however I am getting exceptions. Can anyone tell me what I am doing wrong? Thanks!  1 ALTER PROCEDURE [dbo].[GetCustomerById]
2
3 @CustId NCHAR(5),
4 @CustomerName NVARCHAR(50) OUTPUT
5
6 AS
7 BEGIN
8
9 SELECT @CustomerName = ContactName
10 FROM Customers
11 WHERE CustomerId = @CustId
12
13 END
14
15 RETURN
16
17
18
19
20
21
22 SqlConnection conn = GetConnection(); //retrieves a new SqlConnection
23 SqlCommand cmd = new SqlCommand();
24 cmd.Connection = conn;
25 cmd.CommandType = CommandType.StoredProcedure;
26 cmd.CommandText = "GetCustomerById";
27
28 SqlParameter paramCustId = new SqlParameter();
29 paramCustId.ParameterName = "@CustId";
30 paramCustId.SqlDbType = SqlDbType.NChar;
31 paramCustId.Direction = ParameterDirection.Input;
32 paramCustId.Value = "ALFKI";
33
34 SqlParameter paramCustomerName = new SqlParameter();
35 paramCustomerName.ParameterName = "@CustomerName";
36 paramCustomerName.SqlDbType = SqlDbType.NVarChar;
37 paramCustomerName.Direction = ParameterDirection.Output;
38
39 cmd.Parameters.Add(paramReturn);
40 cmd.Parameters.Add(paramCustId);
41 cmd.Parameters.Add(paramCustomerName);
42
43 conn.Open();
44 SqlDataReader reader = cmd.ExecuteReader();
45
46 string custName = cmd.Parameters["@CustomerName"].Value.ToString();
  

View 6 Replies View Related

Procedure For Retrieving Data From SQL Tables With VBA

Oct 24, 2005

Hi All;

I'm new to SQL, the long and short is I am trying to access some data from an SQL Table to use in my VBA Code in my MS Access front-end.

Here is what I am doing now;

HSTUHoursPriorPeriods = CDbl(Nz(DLookup("[Hours]", "dbo_TIMS_HSTU_HoursHist_Insync", "[eeLink] =" & EmployeeLink), 0))

I am accessing data (YTD Hours for a selected employee) through the view "dbo_TIMS_HSTU_HoursHist_Insync" which is connected by ODBC to my application. The result "HSTUHoursPriorPeriods" is used to determine the rate of pay for a specific employee and is run literall each time a user enters a pay record at data entry.

Because the view itself returns about 1,000 records, before I select the specific record and associated Hours, it is a little slow from a data entry standpoint.

I understand I can achieve the same result through an SQL Procedure, but
for the life of me I don't know how.

ANY thoughts would be greatly appreciated.

View 1 Replies View Related

Retrieving Data From Stored Procedure

May 25, 2008

Hi,

For a particular application i retrieve records using stored procedure and bind the same to the data grid and display the same. The data are fetched from a table say A joined with couple of tables to staisfy the requirement. Now this table A has around 3700000 + records. The Select statement is as

Select column1, column 2, column 3...................... column 25
from table A

inner join hash table D
on A.Column3 = D.Column3
and A.Column4 = D.Column4
and a.nColumn1 = @ParameterVariable
Inner join table B
on a.nColumn1 =b.nColumn1
inner join table C
on A.column2 = C.column2


Indices defined on A are
IDX1 : Column 3, Column 4
IDX2 : Column 1

Around 350 records per second are inserted into the table A during the peak operation time. During this time when executing the procedure, it takes around 4 mins to fetch just 25000 records.

I need to fine tune the procedure. Please suggest me on same.

Thanks


View 4 Replies View Related

Retrieving Return Value From Stored Procedure Declaratively

Nov 1, 2007

Hi.
I have a stored procedure "sp1" which returns a value (with the sql statement Return @ReturnValue).
Is it possible for my asp.net page to retrieve this return value, and to do it declaratively (meaning without writing code to connect to the database in the code behind). If it is possible to do it like this please tell me how, and if not please tell me how to do it with code.
Thanks in advance .

View 5 Replies View Related

Retrieving Output Parameter From A Stored Procedure

Feb 28, 2008

Lets say I have the following stored procedure

Code:

View 2 Replies View Related

Stored Procedure Retrieving Duplicate Data

Apr 17, 2008

Hi i have the following stored procedure which should retrieve data, the problem is that when the user enters a name into the textbox and chooses an option from the dropdownlist it brings back duplicate data and data which should be appearing because the user has entered the exact name they are looking for into the textbox. For instance
Pmillio Jones
Pmillio Jones
Pmillio Jones
Robert Walsh
Here is my stored procedure;
ALTER PROCEDURE [dbo].[stream_UserFind]
-- Add the parameters for the stored procedure here
@userName varchar(100),
@subCategoryID INT,@regionID INT
AS
SELECT DISTINCT SubCategories.subCategoryID, SubCategories.subCategoryName,
Users.userName ,UserSubCategories.userIDFROM Users INNER JOIN UserSubCategoriesON
Users.userID= UserSubCategories.userIDINNER JOIN
SubCategories ON UserSubCategories.subCategoryID = SubCategories.subCategoryID WHEREuserName LIKE COALESCE(@userName, userName) OR
SubCategories.subCategoryID = COALESCE(@subCategoryID,SubCategories.subCategoryID);

View 11 Replies View Related

Retrieving Parameter List For A Stored Procedure

Jul 23, 2004

Is there a way to retrieve the parameter list for a given stored procedure?

I am trying to create a program that will autogenerate a list of stored procedures and their parameters so that changes to the database can be accurately reflected in code.

Thanks,
Allen K.

View 1 Replies View Related

Retrieving Server Time Using Stored Procedure

Jul 21, 2000

Hello all,

We have a domain where all computers are on GMT(Greenwitch Mean Time). We have an access front end that timestamps certain fields according to the client time that the program is running on, but we will be moving our client workstations off of GMT time and keep our SQL Server on GMT time, and want to keep the timestamps GMT.

So, I wanted to know if it was possible to create a stored procedure that gets the Server's time and returns it to the Access frontend for entry into the timestamp fields?

Or, if anyone has a better idea of how to get the time from the server to use on the clients, I would greatly appreciate it!!!

Kevin Kraus

View 2 Replies View Related

Access Result Set From Storede Procedure W/in A Stored Procedure

Jan 24, 2004

Hi All

I have a stored procedure, sp_GetNameDetail, which return a one row, multiple columns result set.

Yet I have another storede procedure which would call sp_GetNameDetail, and would like to access this result set. Is there a way I can do this?

Thanks,

View 1 Replies View Related

Retrieving Values From Stored Procedure Using FormView && SqlDataSource

Mar 3, 2008

Please excuse me if this question has been asked before; I couldn’t find it.  Perhaps someone could point me to the solution.
A few years ago I wrote an order-entry application in classic ASP that I am now re-writing in ASP.NET 2.0.  I am having very good success however I can’t figure out how to retrieve data from a stored procedure.
I am using the FormView & SqlDataSource controls with a stored procedure to insert items into an order.  Every time an item is inserted into the order the stored procedure does all kinds of business logic to figure out if the order qualifies for pricing promotions, free shipping, etc.  If something happens that the user needs to know about the stored procedure returns a message with this line (last line in the SP)
 SELECT @MessageCode AS MessageCode, @MessageText AS MessageText 
I need to retrieve both the @MessageCode and the @MessageText values in my application.  In classic ASP I retrieved these values by executing the SP with a MyRecordset.Open() and accessing them as normal fields in the recordset.
In ASP.NET I have specified the SP as the InsertCommand for the SqlDataSource control.  I have supplied all the parameters required by my SP and told the SqlDataSource that the insert command is a “StoredProcedureâ€?.  Everything actuly works just fine.  The items are added to the order and the business logic in the SP works fine.  I just have no way of telling the user that something important has happened.
Does anyone know how I can pickup these values so that I can show them to my users?  Bassicly if @MessageCode <> 0 I want to show @MessageText on the screen.

View 10 Replies View Related

Retrieving Default Values For Parameters In A Stored Procedure.

Jul 23, 2005

I'm generating a list of parameters needed by stored procedures, and
I'd like to know which ones have default values assigned to them.
To retrieve the parameter information I use:


sp_sproc_columns @Procedure_Name='InsertUser''


However, the column that is supposed to give the default value,
'COLUMN_DEF' always returns as NULL, even when that column has a
default value assigned to it.
i.e.
CREATE PROCEDURE InsertUser@UserID INT = 10,.....


And then if I do a sp_sproc_columns @Procedure_Name='InsertUser'', the COLUMN_DEF value for the @UserID column is still NULL.

Does anyone know what I'm doing wrong and how I can retrieve the default value?

Thanks

View 1 Replies View Related

Problem With Stored Procedure And Retrieving Inserted Identity Value

Jul 11, 2006

Hello!I use a procedure to insert a new row into a table with an identitycolumn. The procedure has an output parameter which gives me theinserted identity value. This worked well for a long time. Now theidentity value is over 700.000 and I get errors whiles retrieving theinserted identitiy value. If I delete rows and reset the identityeverything works well again. So I think it is a data type problem.My Procedure:create procedure InsertProduct@NEWID int outputasbeginset nocount oninsert into PRODUCT(D_CREATED)values(getdate()+'')set nocount offselect @NEWID = @@IDENTITYendMy C# code:SqlCommand comm = new SqlCommand("InsertProduct", sqlCon);comm.CommandType = CommandType.StoredProcedure;comm.Parameters.Add(new SqlParameter("@NEWID",System.Data.SqlDbType.Int)).Direction =System.Data.ParameterDirection.Output;try{SqlDataReader sqlRead = comm.ExecuteReader();object o = comm.Parameters["@NEWID"].Value;//...}catch ( Exception ex ){throw ex;}The object o is alwaya System.DbNull. I also tried to use bigint.Any hints are welcomeCiaoSusanne

View 3 Replies View Related

Error Retrieving Reports

Jul 23, 2007

I have a report serve at http://MyServer/reportserver
My Asp .net web application is running on anothere machine http://WebappMachine/default.aspx.

Here is what is happening
1.My Report server admin created a folder <<MyName>> and gave me user name and password to acess it .

2.I connect through url http://Servername/reportserver . server prompts me for Username and password . When I key in user name pass word it takes me to the
root . I browsed through to the <<MyNameReports>> and created datasource and uploaded .RDL files.

3.I browse the URL to run reports externally using http://myReportserver/ReportServer/Pages/ReportViewer.aspx?%2fDeveloper%2fmyname%2fReports%2ftestreport&rs:Command=Render

it works .

4. I am developing a web app in Asp .net and use reportviewer control to show the report. Credentials is the same as what I using during manually running the reports .Code is as follows

Me.ReportViewer1.ServerReport.ReportServerCredentials = New System.Net.NetworkCredential(uid, pwd)
Me.ReportViewer1.ProcessingMode = ProcessingMode.Remote
Me.ReportViewer1.ServerReport.ReportServerUrl = New System.Uri("http://myreportserver/reportserver")
Me.ReportViewer1.ServerReport.ReportPath = New String("/Developer/myname/Reports/testReport")
Me.ReportViewer1.ServerReport.SetParameters(RptParameters)
Me.ReportViewer1.ServerReport.Refresh()


I get following error .

"The request failed with the error message:
--
<html><head><title>Object moved</title></head><body>

Object moved to here.


</body></html>

--."

I tried to use API

Dim rs As New Microsoft.SqlServer.ReportingServices2005.ReportingService2005()
rs.Url = "http://myreportserver/reportserver/ReportService2005.asmx"
rs.Credentials = New System.Net.NetworkCredential(UID, PWD)
rs.LogonUser(UID, PWD, Nothing)

Dim items As CatalogItem() = rs.ListChildren("/Developer/myname/Reports", True)

When I debug , it pass through LogonUser method ( or Displays Logon failed when wrng pwd entered ) .But displays same message as above when ListChildren is called .


I appreciate for your time and would be of great help if someone can help me with this .

View 4 Replies View Related

Error Retrieving Datetime Value From SQL Server

Sep 13, 2005

Please HELP!
On my asp.NET page I'm setting a datetime variable to Now() and inserting that value into SQL Server as a datetime stamp.  I want to then retrieve the count of the number of records that were inserted into the table that have that value.   The field in the table is just a datetime datatype.But it's returning 0 records because the Now() value is getting converted to military time and losing the seconds!  For example, Now() is "9/13/2005 2:48:25 PM" but the value being inserted into the table is "2005-09-13 14:48:00.000".ARRRGGHH!  What am I missing??  What do I need to do to be able to (1) keep the seconds, and (2) identify the records in order to retrieve them?Thanks in advance for your help!!!Lynnette

View 11 Replies View Related

Retrieving Error Message Text

Jan 19, 2006

Hi,

I'm new to SQL Server and I'm building an SQL Server 2000 database that will be loaded and accessed via stored procedures.

One of the requirements is that I have to log any errors that occur to an error log table containing the date/time, error code and the exact error text - ie containing problem table name, column name, etc.

The problem I'm having is that I can't see a way of capturing the exact error text in a stored procedure. The only thing that seems available is @@error which only returns the error code - not the actual text. I could go to the sysmessages table using the error code but that'll only return the message template containing parameters - not containing the actual table/column/etc causing the problem.

Does anyone have any ideas how to retrieve the exact error message text?

Any help would be most appreciated!

Regards,

Chris

View 2 Replies View Related

Error Message While Retrieving Table From Database

Dec 15, 2004

well i have got a form which displays some result from the databasse, it runs fi9 in webmatrix, but when i try to run it from my main page and when i click on that button which should displays the aspx page, it gives me this error:

############################################################

Server Error in '/' Application.
--------------------------------------------------------------------------------

Login failed for user 'MUFADDALASPNET'.
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.SqlClient.SqlException: Login failed for user 'MUFADDALASPNET'.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[SqlException: Login failed for user 'MUFADDALASPNET'.]
System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction) +472
System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) +372
System.Data.SqlClient.SqlConnection.Open() +384
System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState) +44
System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +304
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +77
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +36
Microsoft.Matrix.Framework.Web.UI.SqlDataSourceControl.PopulateDataSet(DataSet dataSet, String listName) +494
Microsoft.Matrix.Framework.Web.UI.SqlDataSourceControl.GetDataSource(String listName) +51
Microsoft.Matrix.Framework.Web.UI.DataBoundControl.ResolveDataSource() +95
Microsoft.Matrix.Framework.Web.UI.DataBoundControl.DataBind() +59
Microsoft.Matrix.Framework.Web.UI.MxDataGrid.DataBind() +10
Microsoft.Matrix.Framework.Web.UI.MxDataGrid.OnPreRender(EventArgs e) +62
System.Web.UI.Control.PreRenderRecursiveInternal() +62
System.Web.UI.Control.PreRenderRecursiveInternal() +125
System.Web.UI.Control.PreRenderRecursiveInternal() +125
System.Web.UI.Page.ProcessRequestMain() +1489




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573


############################################################





i have kept no passwords in my mssql server 2000 database

can anyone help me out with this problem

View 2 Replies View Related

Retrieving The Error Description In SQL SERVER 2000

Feb 25, 2008

Hello All,

I am stuck at a place in SQL SERVER 2000.

I have created stored procedures and I am checking whether any error has occured on execution of the statements in that procedure.

If the @@Error <>0 then I need to log this error into my error logging table.
For this, I need to retrieve the error description given by SQL SERVER 2000.

I tried this using the master.dbo.sysmessages table. But I get a text from master.dbo.sysmessages which has the placeholders like %l, %s, etc.


I dont want this type of error. I want the exact error description which has the actual objects names and not the placeholders.

I found some help at this link : http://www.sommarskog.se/error-handling-I.html#textretrieve

But i want to know whether there is any other way of doing this or not.

Thanks,
Kapadia Shalin P.

View 3 Replies View Related

Receiving System Error When Retrieving Database Record With Null Value

Sep 26, 2007

I have some VB.NET code to retrieve data from an SQL Server database and display it.  The code is as follows: -------------------------------------------------------------------------------------------------------
sw_calendar = calendarAdapter.GetEventByID(cid)
If sw_calendar.Rows.Count > 0 Then

lblStartDateText.Text = sw_calendar(0).eventStartDate
lblEndDateText.Text = sw_calendar(0).eventEndDate
lblTitleText.Text = sw_calendar(0).title
lblLocationText.Text = sw_calendar(0).location
lblDescriptionText.Text = sw_calendar(0).description
Else

lblStartDateText.Text = "*** Not Found ***"
lblEndDateText.Text = "*** Not Found ***"
lblTitleText.Text = "*** Not Found ***"
lblLocationText.Text = "*** Not Found ***"
lblDescriptionText.Text = "*** Not Found ***"
End If
 -------------------------------------------------------------------------------------------------------
If all of the fields in the database has values, everything works ok.  However, if the title, location or description fields have a null value, I receive the following error message:
Unable to cast object of type 'System.DBNull' to type 'System.String'.
I've tried a bunch of different things such as:

Adding ".ToString" to the database field,
Seeing if the value is null:  If  sw_calendar(0).description = system.DBnull.value...
...but either I get syntax errors in the code, or if the syntax is ok, I still get the above error message.
Can anyone help me with the code required to trap the null within the code example I've provided?  I'm sure there are other, and better, ways to code this, but for now I'd really like to get it working as is, and then optimize the code once the application is working (...can you tell I have a tight deadline )
 
Thanks,
Brad

View 6 Replies View Related

Error Retrieving A Record Based On 3 Parameters. Need Help With Forming My SQL Statement

May 18, 2008

I am having trouble returning the correct record with my stored procedure.
my problem is that i don't know how to structure the sql statement to do the following:
given a set of records that have the same loankey, i need to
1. find the record that has most recent date (lockExprDt)
2. for all records with that date, find the highest Lock Number (LockNo)
3. for the all the records with that date and that LockNo, find the highest extension number (Ext) 
currently my sql statement returns a record that has the most recent date. i don't now how to write the sql to further define my query to return the record that has the most recent date with highest lock number, and finally the highest extension number.
any suggestions as to what i am doing wrong. below is my slq statement. please note that i need to add the sql that will query for the max LockNo, and max Ext. Any help is greatly appreciated. thx!
select a.loankey, a.lockrate, a.investor, a.price, a.ext, a.cost, a.lockno, a.lockstatus , CASE WHEN CONVERT(CHAR(8),a.lockdate,10)='12:00:00 AM'  THEN NULL ELSE CONVERT(CHAR(8),a.lockdate,10)   END as 'LockDate' , CASE WHEN CONVERT(CHAR(8),b.lockExprDt,10)='12:00:00 AM'  THEN NULL ELSE CONVERT(CHAR(8),b.lockExprDt,10) END as 'LockExprDt'  , Case WHEN CONVERT(CHAR(8),b.lockExprDt,10)>= CONVERT(CHAR(8),GETDATE(),10) THEN datediff(day, CONVERT(CHAR(8),GETDATE(),10), CONVERT(CHAR(8),b.lockExprDt,10)) ELSE NULL END as 'Days' 
from cfcdb..locktable ainner join (select loankey, max(lockExprDt) as lockExprDtfrom cfcdb..locktablegroup by loankey) bON a.loankey = b.loankey AND a.lockExprDt = b.lockExprDt
where a.loankey = @LoanKey

View 6 Replies View Related

SQL Server 2014 :: Retrieving All Error Messages Generated By A Command

Jul 17, 2014

Some T-SQL commands can fail with multiple errors. For example, if you try to disable a primary key constraint using ALTER TABLE t1 NOCHECK CONSTRAINT PK, you will get messages like:

Msg 11415, Level 16, State 1, Line 341
Object 'PK' cannot be disabled or enabled. This action applies only to foreign key and check constraints.
Msg 4916, Level 16, State 0, Line 341
Could not enable or disable the constraint. See previous errors.

However, in the code below, only the last message is printed. How can I print all the error messages?

USE tempdb;
CREATE TABLE #t1(c1 INT CONSTRAINT PK PRIMARY KEY);
BEGIN TRY
ALTER TABLE #t1 NOCHECK CONSTRAINT PK;
PRINT 'Primary key disabled'
END TRY
BEGIN CATCH
PRINT ERROR_MESSAGE();
END CATCH

View 4 Replies View Related

SSMA 6.0 - Retrieving COM Class Factory For Component Failed Due To Error

Dec 21, 2014

I am running SQL Service Migration Assistant for Access 6.0 and I am getting the following error when I attempt 'Refresh from database':

Access Object Collector error: Database

Retrieving the COM class factory for component with CLSID {CD7791B9-43FD-42C5-AE42-8DD2811F0419} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

This error may be a result of running SSMA as 64-bit application while having only 32-bit connectivity components installed or vice versa. You can run 32-bit SSMA application if you have 32-bit connectivity components or 64-bit SSMA application if you have 64-bit connectivity components, shortcut to both 32-bit and 64-bit SSMA can be found under the Programs menu.

You can also consider updating your connectivity components from [URL] ....

An error occurred while loading database content.

I've clicked on the link above and installed the Access 2010 Runtime that I found there, but that is not working the problem. I'm running Access 2013 (32-bit) on a Windows 8.1 (64-bit).

View 6 Replies View Related

No Result From Stored Procedure

Dec 22, 2005

Hello evry1.
i m new to SQL Server2000. plzz tell me where i m
wrong in this SP . this procedure is not giving any
error but it is not showing any result. plzz help me n
give me any idea if u know how  i can solve my problem
best regards
sadaf
n here is the procedure


CREATE PROCEDURE Search12
(      @signup      char(50),  
      @user_name1       [char](50),
      @gender1       [char](6),
        @place1       [char](100),
      @email_address1       [char](50),
      @relegion1       [char](50),
      @political_view1       [char](50),
      @passion1       [varchar](150),
      @sports1       [varchar](150),
      @activities1       [varchar](150),
      @books1       [varchar](150),
      @music1       [varchar](150),
      @tv_shows1       [varchar](150),
      @movies1       [varchar](150),
      @cuisines1       [varchar](150),
      @intrested_in1       [varchar](150),
      @education1       [char](100),
      @college_university1       [char](50),
      @occupation1       [char](50),
      @industry1       [char](50),
      @job_desc1       [char](50),
      @career_intrest1       [char](100),
        @latitude1       [decimal],
      @longitude1       [decimal])
AS
if (@user_name1 is not null and  len(@user_name1) &gt; 0)

begin
select * from [profile] where [user_name] like
'%@user_name1%' and place like '%@place%' and
latitude=@latitude1 and longitude=@longitude1 and
signup_name != @signup;
end
if (@gender1 is not null and len(@gender1) &gt; 0)
begin
select * from [profile] where gender = @gender1 and
place like '%@place%' and latitude=@latitude1 and
longitude=@longitude1 and signup_name != @signup;
end
if(@email_address1 is not null and
len(@email_address1) &gt; 0)
begin
select * from [profile] where [email-address] like
'%@email_address1%' and place like '%@place%' and
latitude=@latitude1 and longitude=@longitude1 and
signup_name != @signup;
end
if(@relegion1 is not null and len(@relegion1) &gt; 0)
begin
select * from [profile] where relegion = @relegion1
and place like '%@place%'  and latitude=@latitude1 and
longitude=@longitude1 and signup_name != @signup;
end
if (@political_view1 is not null and
len(@political_view1) &gt; 0)
begin
select * from [profile] where political_view =
@political_view1 and place like '%@place%' and
latitude=@latitude1 and longitude=@longitude1 and
signup_name != @signup;
end
if (@passion1 is not null and len(@passion1) &gt; 0)
begin
select * from [profile] where passion like
'%@passion1%' and place = @place1 and
latitude=@latitude1 and longitude=@longitude1 and
signup_name != @signup;
end
if(@sports1 is not null and len(@sports1)  &gt; 0)
begin
select * from [profile] where sports like '%@sports1%'
and place = @place1 and latitude=@latitude1 and
longitude=@longitude1 and signup_name != @signup;
end
if (@activities1 is not null and len(@activities1) &gt;
0)
begin
select * from [profile] where activities like
'%@activities%' and place = @place1 and
latitude=@latitude1 and longitude=@longitude1 and
signup_name != @signup;
end
if (@books1 is not null and len(@books1)  &gt; 0)
begin
select * from [profile] where books like '%books1%'
and place = @place1 and latitude=@latitude1 and
longitude=@longitude1 and signup_name != @signup;
end
if (@music1 is not null and len(@music1) &gt; 0)
begin
select * from [profile] where music like '%@music%'
and place = @place1 and latitude=@latitude1 and
longitude=@longitude1 and signup_name != @signup;
end
if(@tv_shows1 is not null and len(@tv_shows1) &gt; 0)
begin
select * from [profile] where tv_shows like
'%@tv_shows1%' and place = @place1 and
latitude=@latitude1 and longitude=@longitude1 and
signup_name != @signup;
end
if (@movies1 is not null and len(@movies1) &gt; 0)
begin
select * from [profile] where movies like '%@movies1%'
and place = @place1 and latitude=@latitude1 and
longitude=@longitude1 and signup_name != @signup;
end
if (@cuisines1 is not null and len(@cuisines1) &gt; 0)
begin
select * from [profile] where cuisines like
'%@cuisines1%' and place = @place1 and
latitude=@latitude1 and longitude=@longitude1 and
signup_name != @signup;
end
if (@intrested_in1 is not null and len(@intrested_in1)
&gt; 0)
begin
select * from [profile] where intrested_in =
@intrested_in1 and place = @place1 and
latitude=@latitude1 and longitude=@longitude1 and
signup_name != @signup;
end
if (@education1 is not null and len(@education1) &gt; 0)
begin
select * from [profile] where education
like'%@education1%' and place = @place1 and
latitude=@latitude1 and longitude=@longitude1 and
signup_name != @signup;
end
if (@college_university1 is not null and
len(@college_university1) &gt; 0)
begin
select * from [profile] where institution like
'%@college_university1%' and place = @place1 and
latitude=@latitude1 and longitude=@longitude1 and
signup_name != @signup;
end
if (@occupation1 is not null and len(@occupation1) &gt;
0)
begin
select * from [profile] where occupation like
'%@occupation1%' and place = @place1 and
latitude=@latitude1 and longitude=@longitude1 and
signup_name != @signup;
end
if (@industry1 is not null and len(@industry1) &gt; 0)
begin
select * from [profile] where industry like
'%@industry1%' and place = @place1 and
latitude=@latitude1 and longitude=@longitude1 and
signup_name != @signup;
end
if (@job_desc1 is not null and len(@job_desc1) &gt; 0)
begin
select * from [profile] where job_desc like
'%@job_desc1%' and place = @place1 and
latitude=@latitude1 and longitude=@longitude1 and
signup_name != @signup;
end
if (@career_intrest1 is not null and
len(@career_intrest1) &gt; 0)
begin
select * from [profile] where career_intrest like
'%@career_intrest1%' and place = @place1 and
latitude=@latitude1 and longitude=@longitude1 and
signup_name != @signup;
end
GO

View 6 Replies View Related

Stored Procedure Result Set

Jul 20, 2005

Hi!How can I save a result set from a stored procedure into a table?Can you show me some examples?Thank you!Darko

View 2 Replies View Related

Seeing Result Of Stored Procedure

Nov 29, 2007



i made a new stored procedure and execute it. it works great but where can i see the result ?
i want to see the number of Count(*) in a window inside the SQL Server Managment studio, can i ?

my stored procedure is as follows :


set ANSI_NULLS ON

set QUOTED_IDENTIFIER ON

go



ALTER PROCEDURE [dbo].[GetTotalMovieCreations]

AS

select count(*)

from tbl_Animations

where statusID = 1

and ToolID = 1

and ToolID = -1

and isDeleted = 0


thanks...

View 4 Replies View Related

Stored Procedure Returning 2 Result Sets - How Do I Stop The Procedure From Returning The First?

Jan 10, 2007

I hvae a stored procedure that has this at the end of it:
BEGIN
      EXEC @ActionID = ActionInsert '', @PackageID, @AnotherID, 0, ''
END
SET NOCOUNT OFF
 
SELECT Something
FROM Something
Joins…..
Where Something = Something
now, ActionInsert returns a Value, and has a SELECT @ActionID at the end of the stored procedure.
What's happening, if that 2nd line that I pasted gets called, 2 result sets are being returned. How can I modify this SToredProcedure to stop returning the result set from ActionINsert?

View 2 Replies View Related

Error Retrieving Numeric Data From Oracle 10g On 64 Bit Itanium SSIS Server

Feb 1, 2007

I am working on a project to write SSIS packages to update a SQL Server 2005 database with data from an Oracle 10g database. Unfortunately, our development ETL box is running 32 bit Windows Server 2003 while the production ETL box is running 64 bit Itanium Windows Server 2003. We have created SQL Server Agent jobs to execute all of our packages. All of our jobs run without error on the 32 bit development box, but in our preproduction tests they are failing in the 64 bit box.

In my testing, I've found that I can successfully pull character data from Oracle. For example, I can write a package that retrieves the data for the following query:

SELECT 'test' FROM dual

However, the following fails:

SELECT 1 FROM dual

I have logging turned on in my package. When the package fails, I typically see informational messages in the log up to the point of failure, but no actual error event logs are generated. The only error information I have is in the SQL Server Agent job history log, which contains the following:

Executed as user: SERVERNAMESYSTEM. The return value was unknown. The process exit code was
-2147483646. The step failed.

I have also tried using the 64 bit version of the DTS Wizard to create a sample package, and observe the same behavior. When I run the DTS Wizard, queries that return numeric data cause DTSWizard.exe to exit and produce the following message in the application event log:

Event
Type: Error
Event
Source: .NET Runtime 2.0 Error Reporting
Event
Category: None
Event
ID: 1000
Date:
2/1/2007
Time:
12:36:13 PM
User:
N/A
Computer: SERVERNAME
Description:
Faulting
application dtswizard.exe, version 9.0.2047.0, stamp 443f5e50, faulting module
oracore10.dll, version 10.2.0.1, stamp 435841b0, debug? 0, fault address
0x00000000001e4910.Has anyone else experienced similar behavior, and know of a solution aside of wrapping all retrieval of numeric data in to_chars in our Oracle queries?

View 1 Replies View Related

Store Procedure Retunrs No Result

Jan 16, 2008

I have a store procedure that works fine when tested in SQL Management Studio and Visual Studio but when I actually running the page in a browser, it does not work. There is no result generated. Below is my store procedure.1 ALTER PROCEDURE [dbo].[spSearch]
2 -- Add the parameters for the stored procedure here
3 @schoolID int = NULL,
4 @scholarship varchar(250) = NULL,
5 @major varchar(250) = NULL,
6 @requirement varchar(250) = NULL
7 --@debug bit = 0
8 AS
9 BEGIN
10 -- SET NOCOUNT ON added to prevent extra result sets from
11 -- interfering with SELECT statements.
12 SET NOCOUNT ON;
13
14 -- Insert statements for procedure here
15
16 Declare @SQL as NVarchar(4000);
17 Declare @Params as NVarchar(3000);
18 Set @SQL = N'SELECT * FROM [scholarship] WHERE [sectionID] = @schoolID';
19 Set @Params = N'@schoolID int,@scholarship varchar(250),@major varchar(250),@requirement varchar(250)'
20
21 If @scholarship IS NOT NULL
22 Set @SQL = @SQL + N' AND [scholarship].[schlrName] LIKE + ''%'' + @scholarship + ''%'''
23 If @major IS NOT NULL
24 Set @SQL = @SQL + N' AND [scholarship].[Specification] LIKE + ''%'' + @major + ''%'''
25 If @requirement IS NOT NULL
26 Set @SQL = @SQL + N' AND ([scholarship].[reqr1] LIKE + ''%'' + @requirement + ''%'''
27 If @requirement IS NOT NULL
28 Set @SQL = @SQL + N' OR [scholarship].[reqr2] LIKE + ''%'' + @requirement + ''%'''
29 If @requirement IS NOT NULL
30 Set @SQL = @SQL + N' OR [scholarship].[reqr3] LIKE + ''%'' + @requirement + ''%'''
31 If @requirement IS NOT NULL
32 Set @SQL = @SQL + N' OR [scholarship].[reqr4] LIKE + ''%'' + @requirement + ''%'''
33 If @requirement IS NOT NULL
34 Set @SQL = @SQL + N' OR [scholarship].[reqr5] LIKE + ''%'' + @requirement + ''%'')'
35 --If @debug = 1
36 --PRINT @SQL
37 Exec sp_executesql @SQL, @Params, @schoolID, @scholarship, @major, @requirement
38 END
39
 

View 27 Replies View Related







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