Procedure Parameter Too Long Error

Nov 11, 2006

I'm generarintg a mail from a trigger, using xp_sendmail.
I use the query parameter to generate the body of the mail, the query is a procedure call with some parameters, one of this is a long string.
when the length is less that 128 work fine, but, when this parameter is longer than 128 charaters, return me the error 103 telling me that it has exceed 128 characteres, and do not send the mail.

I find this quite frustrating, the parameter is limited only to 128 characteres, what could I do.
Thanks in advance

Cheers.
Ale.

View 1 Replies


ADVERTISEMENT

ADO Stored Procedure Parameter Error With DB2

Jul 1, 2007

Hey all,



I ran into a little snag when writing a VBScript app for work that parses a text file and places that data into a DB2 V8.1 database via OLE DB ADO calls and a stored procedure with parameters.

I have found that I can call a stored procedure w/o parameters but as soon as I one that takes some I get the following error.




"arguments are of the wrong type, are out of acceptable range"


To try to troubleshoot it, I tried applying each parameter property individually. I noticed that when I didn't provide a direction, I received a different error (Don't have the exact one but it had something to do with an IBM OLE DB property error).

Because the VBScript error was on the line (mycmd.commandtype = adCmdStoredProc) I replaced the global constant with a literal (IE: 4). No fix.

I'm going to try to replace all of the global constants with their literal values but I also found this on the IBM site...


1: SQLProcedureColumns is used by many applications to
determine the direction of stored procedure parameters. The
ODBC driver is returning an ordinal of 1 for all the
parameters.
This causes problems with applications that use this
information. For example a stored procedure call using
Microsoft ActiveX Data Objects (ADO) and the adCmdStoredProc
syntax will return one of the following error messages:
3265 Item cannot be found in the collection corresponding to the
requested name or ordinal.
3001 Arguments are of the wrong type, are out of acceptable
range, or are in conflict with one another.
SQLProcedureColumns is also returning a "BUFFER_LENGTH" value
for numeric data types that is 1 byte too large. The default C
data type is character so this value should be display size
-without an extra byte for null.


I'm guessing this is the solution to my issue but I figured I'd put this out there just in case I was missing something.

If you have any other suggestions, please chime in.

View 5 Replies View Related

Procedure Expects Parameter Error When Adding To DB

May 15, 2007

Hi,I'm trying to create a page where a user can search the database according to some criteria and get back the result in the form of a GridView. Also, the user has the option of saving the criteria to another table in the database by assigning it a name so that it can be retrieved easily in the future.I have the search and display part working, however, saving the criteria to the database is giving problems for some reason.Given below is my stored procedure to add the info to the db.  SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[AddToReport]
(@ReportName varchar(100), @ProjID varchar(300), @DeptCode varchar(20), @ProjType varchar(20), @ProjectTitle varchar(300),
@ProjectManagerID int, @DateRequested datetime, @DueDate datetime, @ProjectStatusID int)

AS
SET NOCOUNT ON
DECLARE @Dept varchar(50)
DECLARE @err int

BEGIN TRANSACTION

IF @ReportName IS NULL
BEGIN
RETURN -1
END
ELSE
BEGIN
IF @DeptCode IS NOT NULL
BEGIN
SET @Dept = REPLACE(CONVERT(char,@DeptCode),'.','')
END
SET @err = @@ERROR


INSERT INTO dbo.tbl_Report (ReportName, ProjID, DeptCode, ProjType, ProjectTitle, ProjectManagerID, DateRequested, DueDate, ProjectStatusID)
VALUES (@ReportName, @ProjID, @Dept, @ProjType, @ProjectTitle, @ProjectManagerID, @DateRequested, @DueDate, @ProjectStatusID);
IF @err<>0
BEGIN
ROLLBACK TRANSACTION
RETURN @err
END
END
COMMIT TRANSACTION Given below is the relevant codebehind.  This is how the values are initialized:   Dim newManager As New ListItem
newManager.Text = "Choose a Manager"
newManager.Value = 0
projectManagerDDL.Items.Add(newManager)

Dim newDept As New ListItem
newDept.Text = "Choose a Department"
newDept.Value = ""
deptCodeDDL.Items.Add(newDept)

Dim newID As New ListItem
newID.Text = "Choose a Project"
newID.Value = ""
projIDDDL.Items.Add(newID)

Dim newStatus As New ListItem
newStatus.Text = "Choose a Status"
newStatus.Value = 0
projectStatusDDL.Items.Add(newStatus)

Dim newDateRequestedMonth As New ListItem
newDateRequestedMonth.Text = "Month"
newDateRequestedMonth.Value = 0
dateRequestedMonthDDL.Items.Add(newDateRequestedMonth)

Dim newDateRequestedDay As New ListItem
newDateRequestedDay.Text = "Day"
newDateRequestedDay.Value = 0
dateRequestedDayDDL.Items.Add(newDateRequestedDay)

Dim newDateRequestedYear As New ListItem
newDateRequestedYear.Text = "Year"
newDateRequestedYear.Value = 0
dateRequestedYearDDL.Items.Add(newDateRequestedYear)

Dim newDueDateMonth As New ListItem
newDueDateMonth.Text = "Month"
newDueDateMonth.Value = 0
dueDateMonthDDL.Items.Add(newDueDateMonth)

Dim newDueDateDay As New ListItem
newDueDateDay.Text = "Day"
newDueDateDay.Value = 0
dueDateDayDDL.Items.Add(newDueDateDay)

Dim newDueDateYear As New ListItem
newDueDateYear.Text = "Year"
newDueDateYear.Value = 0
dueDateYearDDL.Items.Add(newDueDateYear) This is the submit code:  Protected Sub saveButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim connString As String
Dim con As SqlConnection


Try
connString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings("ConnectionString1").ConnectionString

con = New SqlConnection(connString)

Dim cmd As SqlCommand = New SqlCommand()
cmd.Connection = con

If (([String].IsNullOrEmpty(reportNameTextBox.Text) = False) Or reportNameTextBox.Text <> "Enter Report Name") Then
cmd.Parameters.Add("ReportName", SqlDbType.VarChar, 300).Value = reportNameTextBox.Text
End If

If ([String].IsNullOrEmpty(projIDDDL.SelectedItem.Value)) = False Then
cmd.Parameters.Add("ProjID", SqlDbType.VarChar, 30).Value = projIDDDL.SelectedItem.Value
End If

If ([String].IsNullOrEmpty(deptCodeDDL.SelectedItem.Value)) = False Then
cmd.Parameters.Add("DeptCode", SqlDbType.VarChar, 20).Value = deptCodeDDL.SelectedItem.Value
End If

If (typeRBL.SelectedItem.Value <> "All") Then
cmd.Parameters.Add("ProjType", SqlDbType.VarChar, 20).Value = typeRBL.SelectedItem.Value
End If

If ([String].IsNullOrEmpty(projectTitleTextBox.Text)) = False Then
cmd.Parameters.Add("ProjectTitle", SqlDbType.VarChar, 300).Value = projectTitleTextBox.Text
End If

If CInt(projectManagerDDL.SelectedItem.Value) <> 0 Then
cmd.Parameters.Add("ProjectManagerID", SqlDbType.Int).Value = CInt(projectManagerDDL.SelectedItem.Value)
End If

If (dateRequestedDayDDL.SelectedItem.Value = 0 Or dateRequestedMonthDDL.SelectedItem.Value = 0 Or dateRequestedYearDDL.SelectedItem.Value = 0) Then
Dim dateRequested As New DateTime
dateRequested = Nothing
Else
Dim dateRequested As New DateTime(dateRequestedYearDDL.SelectedValue, dateRequestedMonthDDL.SelectedValue, dateRequestedDayDDL.SelectedValue)
If (dateRequested) <> Nothing Then
cmd.Parameters.Add("DateRequested", SqlDbType.DateTime).Value = dateRequested
End If
End If


If (dueDateDayDDL.SelectedItem.Value = 0 Or dueDateMonthDDL.SelectedItem.Value = 0 Or dueDateYearDDL.SelectedItem.Value = 0) Then
Dim dueDate As New DateTime
dueDate = Nothing
Else
Dim dueDate As New DateTime(dueDateYearDDL.SelectedValue, dueDateMonthDDL.SelectedValue, dueDateDayDDL.SelectedValue)
If (dueDate) <> Nothing Then
cmd.Parameters.Add("DueDate", SqlDbType.DateTime).Value = dueDate
End If
End If

If (projectStatusDDL.SelectedItem.Value) <> 0 Then
cmd.Parameters.Add("ProjectStatusID", SqlDbType.Int).Value = CInt(projectStatusDDL.SelectedItem.Value)
End If

cmd.CommandText = "dbo.AddToReport"
cmd.CommandType = CommandType.StoredProcedure

Try
con.Open()
cmd.ExecuteNonQuery()
Response.Write("Report Saved")
Catch ex As Exception
Response.Write(ex)
Finally
con.Close()
con.Dispose()

End Try



Catch ex As ApplicationException
Response.Write("Could not load the database")
End Try

End Sub   The only absolute requirement when saving to the table is the ReportName. All the other criteria can be NULL. If I don't select and values and try to save the values, I get an error:System.Data.SqlClient.SqlException: Procedure or function 'AddToReport' expects
parameter '@ProjID', which was not supplied. at
System.Data.SqlClient.SqlConnection.OnError...  etc If I choose the ProjID (thus giving it a value), I get the following error:System.Data.SqlClient.SqlException: Procedure or function 'AddToReport' expects
parameter '@DeptCode', which was not supplied. at
System.Data.SqlClient.SqlConnection.OnError... etc  and so forth. I'm guessing it's a problem of NULLs somewhere, but I'm not sure. Thanks. 

View 6 Replies View Related

Error On Passing Parameter To Stored Procedure

Jul 1, 2004

Hi,

I have a procedure that will save to table in sql server 200 via stored procedure. When I hit the save button it alwasy give me an error saying "Procedure 'sp_AddBoard' expects parameter '@dtmWarrantyStart', which was not supplied" even though I supplied it in the code

which is

Dim ParamdtmWarrantyStart As SqlParameter = New SqlParameter("@dtmWarrantyStart", SqlDbType.datetime, 8)
ParamdtmWarrantyStart.Value = dtmWarrantyStart
myCommand.Parameters.Add(ParamdtmWarrantyStart)

below is the stored procedure.

create Proc sp_AddBoard(@BrandID int,
@strPcName varchar(50),
@bitAccounted bit,
@dtmAccounted datetime,
@dtmWarrantyStart datetime,
@dtmWarrantyEnd datetime,
-- @strDescription varchar(500),
@intStatus int,
@ModelNo varchar(50),
@intMemorySlots int,
@intMemSlotTaken int,
@intAgpSlots int,
@intPCI int,
@bitWSound bit,
@bitWLan bit,
@bitWVideo bit,
@dtmAcquired datetime,
@stat bit output,
@intFSB int) as
if not exists(select strPcName from tblBoards where strPcName=@strPcName)
begin
insert into tblBoards
(BrandID, strPcName, bitAccounted,
dtmAccounted, dtmWarrantyStart,
dtmWarrantyEnd, --strDescription,
intStatus,
ModelNo, intMemorySlots, intMemSlotTaken,
intAgpSlots, intPCI, bitWLan,
bitWVideo, dtmAcquired,intFSB,bitWSound)

values

(@BrandID,@strPcName,@bitAccounted,
@dtmAccounted,@dtmWarrantyStart,
@dtmWarrantyEnd,--@strDescription,
@intStatus,
@ModelNo,@intMemorySlots,@intMemSlotTaken,
@intAgpSlots,@intPCI,@bitWLan,
@bitWVideo,@dtmAcquired,@intFSB,@bitWSound)
end
else
begin
set @stat=1
end

The table is also designed to accept nulls on that field but still same error occured.

Please help

View 1 Replies View Related

Error - Procedure Expects Parameter, Which Was Not Supplied

Aug 24, 2004

Hi,

I created a stored procedure in the sql server. I try to insert a record from the aspx page. But I keep getting this error,
"procedure expects parameter <@firstname>, which was not supplied". This is what I am doing.

cmd.CommandText = "proc_insertuser";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@firstname", SqlDbType.VarChar, 50);
cmd.Parameters["@firstname"].Value = txtFirstName.Text
....other parameters

I checked the parameter names, it matches correctly. The parameter does get added to the collection. I checked it using cmd.Parameters.Contains("@firstname") and the value is also correct. Using query analyzer I executed the procedure, I am able to insert a record.

Can anyone tell me what could be the problem.
TAI

View 2 Replies View Related

Stored Procedure Output Parameter Error

Sep 18, 2014

Stored procedure displays the follwing error.

Procedure or function 'getFavoriteList' expects parameter '@category_name', which was not supplied.

I have code

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[getFavoriteList]
@customer_id int,
@category_name varchar(200) OUTPUT

[Code] ....

View 6 Replies View Related

Error: Procedure Expectes Parameter '###', Which Was Not Supplied

Feb 13, 2008

I created the SP ( just called' SP_TEST') and when I tried to preview the report, I got the following error message:

"Procedure or fucntion 'SP_TEST' expects parameter @SelectWeek, which was not supplied.

This error message appears when you don't supply a value for a parameter expected by a stored procedure.
However, I set up the report parameter for Select Week and default week as well.
Here is what i've done for dataset,Select Week and parameter:




Code Snippet
SELECT DISTINCT Week ,
( SELECT DISTINCT Week FROM DIM_Date
WHERE full_date = CONVERT(VARCHAR(20),GETDATE(),112) ) AS defaultWeek
FROM DIM_Date
WHERE fiscal_year_number IS NOT NULL and @year = fiscal_year_number
ORDER BY Week





Any comments and advice would be greatly appreciated.
Thanks in advance.

View 4 Replies View Related

Long Execution Time When Using Parameter

Dec 20, 2007

Hi all,

If I use the following query for a Dataset and the execution takes a few seconds to show results



SELECT *

FROM dbo.ICParameter

WHERE (PatientID = @ID ) AND (LogTime > DATEADD(day, -1, GETDATE()))

ORDER BY LogTime


If I replace '99010200101' with @ID and enter '99010200101' when prompted for ID, the execution takes forever. Actually I have never got any results even after waiting for 10 minutes.

Could anyone shed some light on this?

Thanks in advance.

View 19 Replies View Related

Stored Procedure Parameter Supplied But Error Messages Says It's Not

Dec 7, 2007

I keep getting this error on one of my pages when trying to do an update to the table via a stored procedure:
*System.Data.SqlClient.SqlException: Procedure or function 'sp_u_contractor_references' expects parameter '@p_contractorrfid', which was not supplied
 I have verified that I am adding this parameter and that the spelling is correct. I have also made sure that the value is not NULL.
 I'm confused as to what else the problem could be. Any ideas?

View 5 Replies View Related

Strage Error Related To Stored Procedure Parameter

Sep 19, 2005

Can anyone explain what's wrong with this code which is supposed to populate a dropdownlist using a parametised stored procedure and SqlDataAdapter?
objCmd = new SqlCommand("bs_GetActivityValueTypes", objConn.GetConnection()); objCmd.Parameters.Add("@scid", SqlDbType.Int);objCmd.Parameters["@scid"].Value = Convert.ToInt32(Request.QueryString["scorecard"].ToString()); objAdapter = new SqlDataAdapter(objCmd);objAdapter.Fill(dsInitData, "tblValueTypes");
comboResultType.DataSource = dsInitData.Tables["tblValueTypes"]; comboResultType.DataValueField = "Type_ID";comboResultType.DataTextField = "Type_Desc";comboResultType.DataBind(); comboResultType.Items.Insert(0, new ListItem("- Select a value type -", ""));Basically, if I remove the parameter from the code and the stored procedure it works fine, but when I add the parameter back I get an "Incorrect syntax near 'bs_GetActivityValueTypes'" error at line: objAdapter.Fill(dsInitData, "tblValueTypes"); This makes no sense to me because I know the stored procedure is well formed and I've used almost identical code elsewhere. All variables are declared further up the code. Someone help please!

View 3 Replies View Related

Long Parameter List For Stored Procs

Nov 20, 2006

Hi All,

I've got a problem with increasingly long parameter lists for SProcs... Especially when one calls another SProc, and so on. Is there any way around this? Like can you dynamically construct a string and pass that? I'm just looking to see if more experienced players have found ways around this, or have just dealt with it by using well formed code.

Thanks

Chris

View 7 Replies View Related

Error--Procedure 'SP_Insert_NewPipeLine' Expects Parameter '@CompanyId', Which Was Not Supplied.

Jul 2, 2006

Can any body help me in solving this problem.
First I use to get Error which reads "Object Must Implement Iconvertible"
After using the overloaded Sp.paramerers.add() function It started giving this problem.
I am giving the sample code.
ConObject = new SqlConnection(ConString);
ConObject.Open();
string SpString ="dbo.SP_Insert_NewPipeLine";
SqlCommand CmdObject = new SqlCommand(SpString,ConObject);
CmdObject.CommandType = CommandType.StoredProcedure;
CmdObject.Parameters.Add("@RequestTypeId",SqlDbType.Int,4,"0");
//CmdObject.Parameters["@RequestTypeId"].Value= 0;
CmdObject.Parameters.Add("@OnBehalfOf",SqlDbType.Int,4,"21");//Onbehalf of Id
//CmdObject.Parameters["@OnBehalfOf"].Value = 21;

CmdObject.Parameters.Add("@SubmittedBy",SqlDbType.Int,4,ddlSalesRep.SelectedValue.ToString());//Submitted by Id
//CmdObject.Parameters["@SubmittedBy"].Value = ddlSalesRep.SelectedItem.Value;
CmdObject.Parameters.Add("@CompanyId",SqlDbType.Int,4,ddlCustomer.SelectedItem.Value.ToString());//Company_Id
//CmdObject.Parameters["@CompanyId"].Value = ddlCustomer.SelectedItem.Value;
CmdObject.ExecuteScalar();

View 2 Replies View Related

Error With Multi-Valued Report Parameter Using Stored Procedure

Dec 19, 2007

Hi All,
I'm unable to run the report the report with multi-valued parameter using the below StoredProcedure as dataset:

CREATE PROCEDURE spprodsales
@productid int

AS

select SalesOrderID,OrderQty,UnitPrice,ProductID

FROM Sales.SalesOrderDetail

Where ProductID IN (@productid)

RETURN


And when I'm replacing this dataset to a query as below I'm able to run the report with multiple values selected for productid parameter :

select SalesOrderID,OrderQty,UnitPrice,ProductID

FROM Sales.SalesOrderDetail

Where ProductID IN (@productid)

So, can anyone please help me out possibly using the same stored procedure as above.

Thanks,
Kripa

View 5 Replies View Related

Receive Procedure Or Function Expects Parameter... Error Unexpectedly

Oct 5, 2007

Maybe I am missing something completely obvious but as far as I can tell I aren't!

I am trying to simply pass a parameter to a stored proc to return results. Easy? So I thought so too...

This is my stored procedure below (in it's ALTER PROCEDURE form):


ALTER PROCEDURE [dbo].[spd_Tester]

-- Add the parameters for the stored procedure here

@Check int

AS

BEGIN

SELECT * FROM tblPerson

WHERE PersonID = @Check

END


Now I know this is a SQL Server forum but I figure anyone who reads this probably does some application programming as well, so here is the code that calls this. It's in VBA using Access 2003. I figure the error is being returned from SQL Server Express so that's why I have come to this forum instead of an Access forum! I could be wrong though...

Here is the code that calls this:

Dim rs As ADODB.Recordset
Dim cmd As ADODB.Command

Set cmd = New ADODB.Command

'Run sql command
With cmd
.ActiveConnection = CurrentProject.Connection

.CommandText = "dbo.spd_Tester"
.Parameters.Append .CreateParameter("@Check", adInteger, adParamInput, , Me.txtFirstName)


'Execute, return recordset
Set rs = .Execute

End With

Now I figure this should work. However, I get the error "Procedure or function 'spd_Tester' expects parameter '@Check', which was not supplied." when I execute the procedure with the number 1 in the txtFirstName text box.

Can someone tell me what I am doing wrong?? The tblPerson table has data in it, if I run the select from a query window, specifying a value for @Check, it works just fine.

Thanks in advance!

View 4 Replies View Related

Error: Procedure Or Function Roles_delete Expects Parameter @Role_name, Which Not Supplied...

Feb 12, 2008

Hello guy...i have a problem with my web application...i'm using SqlDataSource and GridView....i'm using store procedure that i've created in my mssql server...the problem is when i'm trying to delete current row...this error alert and said
Error

"Procedure or Function "Roles_delete" expects parameter "@Role_name", which not supplied"
Im new user in asp.net....how i can passing my selected value to this parameter??? This is my code...please help me guy...
Asp.net code
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:PVMCCon %>"
DeleteCommand="Roles_delete" DeleteCommandType="StoredProcedure" SelectCommand="Roles_select"
SelectCommandType="StoredProcedure">
<DeleteParameters>
<asp:Parameter Name="Role_name" Type="String" />
</DeleteParameters>
</asp:SqlDataSource>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="White"
BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px" CellPadding="4" DataKeyNames="Role_application_id"
DataSourceID="SqlDataSource1" ForeColor="Black" GridLines="Vertical">
<FooterStyle BackColor="#CCCC99" />
<Columns>
<asp:CommandField ShowDeleteButton="True" />
<asp:BoundField DataField="Role_application_id" HeaderText="Role_application_id"
ReadOnly="True" SortExpression="Role_application_id" />
<asp:BoundField DataField="Role_name" HeaderText="Role_name" SortExpression="Role_name" />
<asp:BoundField DataField="Role_description" HeaderText="Role_description" SortExpression="Role_description" />
</Columns>
<RowStyle BackColor="#F7F7DE" />
<SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" />
<HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
 
Store Procedure
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

ALTER PROCEDURE [dbo].[Roles_delete]
@Role_name varchar(50)
AS
BEGIN
SET NOCOUNT ON;
DELETE FROM Role
WHERE Role_name=@Role_name
END

 Error

Procedure or Function "Roles_delete" expects parameter "@Role_name", which not supplied"
Please help me guy to settle my problem...

View 3 Replies View Related

ERROR: Procedure Expects Parameter '@statement' Of Type 'ntext/nchar/nvarchar'.

Mar 27, 2004

/* INFO USED HERE WAS TAKEN FROM http://support.microsoft.com/default.aspx?scid=kb;en-us;262499 */
DECLARE @X VARCHAR(10)
DECLARE @ParmDefinition NVARCHAR(500)
DECLARE @Num_Members SMALLINT
SELECT @X = 'x.dbo.v_NumberofMembers'
DECLARE @SQLString AS VARCHAR(500)

SET @SQLString = 'SELECT @Num_MembersOUT=Num_Members FROM @DB'
SET @ParmDefinition = '@Num_MembersOUT SMALLINT OUTPUT'


EXECUTE sp_executesql <-LINE 11
@SQLString,
@ParmDefinition,
@DB = @X,
@Num_MembersOUT = @Num_Members OUTPUT


Just Need Help On This Error
Server: Msg 214, Level 16, State 2, Procedure sp_executesql, Line 11
Procedure expects parameter '@statement' of type 'ntext/nchar/nvarchar'.


I dont know why im getting a errrror b/c I followed http://support.microsoft.com/default.aspx?scid=kb;en-us;262499 exactly

View 3 Replies View Related

RS 2005: Stored Procedure With Parameter It Runs In The Data Tab But The Report Parameter Is Not Passed To It

Feb 19, 2007

Hello,
since a couple of days I'm fighting with RS 2005 and the Stored Procedure.

I have to display the result of a parameterized query and I created a SP that based in the parameter does something:

SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
CREATE PROCEDURE [schema].[spCreateReportTest]
@Name nvarchar(20)= ''

AS
BEGIN

declare @slqSelectQuery nvarchar(MAX);

SET NOCOUNT ON
set @slqSelectQuery = N'SELECT field1,field2,field3 from table'
if (@Name <> '')
begin
set @slqSelectQuery = @slqSelectQuery + ' where field2=''' + @Name + ''''
end
EXEC sp_executesql @slqSelectQuery
end

Inside my business Intelligence Project I created:
-the shared data source with the connection String
- a data set :
CommandType = Stored Procedure
Query String = schema.spCreateReportTest
When I run the Query by mean of the "!" icon, the parameter is Prompted and based on the value I provide the proper result set is displayed.

Now I move to "Layout" and my undertanding is that I have to create a report Paramater which values is passed to the SP's parameter...
So inside"Layout" tab, I added the parameter: Name
allow blank value is checked and is non-queried

the problem is that when I move to Preview -> I set the value into the parameter field automatically created but when I click on "View Report" nothing has been generated!!

What is wrong? What I forgot??

Thankx for any help!
Marina B.





View 3 Replies View Related

Stored Procedure With User!UserID As Parameter, As Report Parameter?

Jul 2, 2007

I had thought that this was possible but I can't seem to figure out the syntax. Essentially I have a report where one of the parameters is populated by a stored procedure.

Right now this is easily accomplished by using "exec <storedprocname>" as the query string for the report parameter. However I am not clear if it is possible to now incorporate User!UserID as parameter to the stored procedure. Is it? Thanks

View 1 Replies View Related

Long Time To Run A Stored Procedure

Feb 18, 2000

Hi There,
We have developed a application in VB and connected to SQL Server 6.5, we have some stored procedures where it brings the data from SQL Server 6.5, this application is running since some months, when we run this application it usually take only one minute to generate the report but since couple of days it is taking 25 Minutes to generate the report, even when I run that stored procedure at backend in Query analyzer at Server it is taking 15-20 Minutes to give the result.
please can any one help in identifying the problem, What all the things I need to check to identify it.
Give me the solution.

Thanks in Advance,

Bye,
Madhuker.

View 1 Replies View Related

Stored Procedure Runs Very Long

Jan 22, 2008

I think I may need help with query optimization.

We have a customer table and an address table. Each customer can have 1 or more addresses in the address table.

The task is to synchronize customer information from 2 entirely separate systems. I have a stored procedure that reads a text file (exported from the 'master' system) and updates all the customer records in the second system (which is in the sql server db). The queries themselves work. The data is accurate. My issue is with how long it takes the stored procedure to run. With over 11,000 records in the text file, the stored procedure sometimes takes over 3 hours to run.

That seems excessive to me. (and probably to those of you snickering in the back)

As an overview: my stored procedure does the following.

1) creates a temp table
2) dumps the data from the text file into the temp table
3) updates the address table with data from the temp table (records already there)
4) inserts records into the address table from the temp table (records not already there)
5) updates the customer table with an address id
6) drops the temp table

Any help/suggestions is appreciated. If you need more info, let me know.

View 10 Replies View Related

Stored Procedure Taking Too Long

May 2, 2006

I have a stored procedure that is taking too long to complete. I'ved narrowed the problem down to the following code. Is there any reason why this should take long to complete for about 40,000 records?

UPDATE Entries

SET EntryStatus = 1, reason = 'code entered more than once'

WHERE TimeSubmitted > @StartOfPeriod AND TimeSubmitted < @EndOfPeriod

AND TimeSubmitted <> @t and ShortCode = @ShortCode

AND verbatim = @v

View 4 Replies View Related

Help-take A Long Time Run This Stored Procedure 15 Second

May 3, 2008

help-take a long time run this stored procedure 15 second



Code Snippet

DECLARE @WantedDate SMALLDATETIME, -- Should be a parameter for SP

@BaseDate SMALLDATETIME,@NumDays TINYINT,@myNum TINYINT

set @myNum=4

SELECT @WantedDate = CAST(CAST(YEAR(GETDATE()) AS nvarchar)+ '-' +CAST(1 AS nvarchar)+ '-' +CAST(@myNum AS nvarchar) AS SMALLDATETIME), -- User supplied parameter value

@BaseDate = DATEADD(MONTH, DATEDIFF(MONTH, '19000101', @WantedDate), '19000101'),

@NumDays = DATEDIFF(DAY, @BaseDate, DATEADD(MONTH, 1, @BaseDate))

select @WantedDate

IF @NumDays = 28

BEGIN

SELECT dbo.v_hasot_all.empID, dbo.v_hasot_all.Fname, dbo.v_hasot_all.day1A, dbo.v_hasot_all.nameday, dbo.tb_mis_hsaot.mishs_txt, CONVERT(datetime,

CAST(dbo.v_hasot_all.nameday AS nvarchar) + '/' + CAST(@myNum AS nvarchar) + '/' + CAST(YEAR(GETDATE()) AS nvarchar), 103) AS date_mis

FROM dbo.v_hasot_all INNER JOIN

dbo.tb_mis_hsaot ON dbo.v_hasot_all.day1A = dbo.tb_mis_hsaot.mishs_int

WHERE (NOT (dbo.v_hasot_all.nameday IN (29, 30, 31)))



END

ELSE IF @Numdays = 29

BEGIN

SELECT ...............

WHERE (NOT (dbo.v_hasot_all.nameday IN ( 30, 31)))



END

ELSE IF @Numdays = 30

BEGIN

SELECT ......................

WHERE (NOT (dbo.v_hasot_all.nameday IN (31)))



END

ELSE IF @Numdays = 31

BEGIN

SELECT dbo.v_hasot_all.empID, dbo.v_hasot_all.Fname, dbo.v_hasot_all.day1A, dbo.v_hasot_all.nameday, dbo.tb_mis_hsaot.mishs_txt, CONVERT(datetime,

CAST(dbo.v_hasot_all.nameday AS nvarchar) + '/' + CAST(@myNum AS nvarchar) + '/' + CAST(YEAR(GETDATE()) AS nvarchar), 103) AS date_mis

FROM dbo.v_hasot_all INNER JOIN

dbo.tb_mis_hsaot ON dbo.v_hasot_all.day1A = dbo.tb_mis_hsaot.mishs_int

END
and whan i run my code separately it run fast
i think it is the ELSE IF @Numdays

TNX

View 5 Replies View Related

Is There Any Way To Bacground A Long Running Stored Procedure?

Feb 21, 2000

I have a stored procedure being called from Visual Cafe 4.0 that takes over 30 minutes to run. Is there any way to backround this so that control returns to the browser that the JFC Applet is running in? The result set is saved to local disk and an email message sent to the user on completion.
Thanks, Dave.

View 2 Replies View Related

SQL Server Stored Procedure Best Practices? - Long

Jun 13, 2007

I'm an experienced SQL Server and .NET developer, but I wanted to expand the way I look at things and see how other developers approach the situation I'm going to outline in this post. I'm going to be engineering a large, new project soon and I want to examine how I approach this and see if there is a better way.

I work in a small development group with two developers (myself and another). We pretty much wear all the design, testing ,and development hats during the course of a system's development. I had a discussion today with the other developer about creation of stored procedures.

I like to create small specific stored procedures for whatever I'm doing. I will usually have at least 4 stored procedures for each table; Insert, Delete, Update, and Select. Frequently I'll have more Select procedures for special cases. I do this for several reason. One I can get Visual Studio to generate the basic procedures for me and utilize them in a typed dataset. Secondly I can keep all my SQL code server side, and in small maintainable chunks. It is also fairly obvious what my stored procedures do from the name. The main drawback is that the list of stored procedures gets huge.

The developer I work with likes to create a single stored procedure for Insert, Update, and Deletes. Based on the passed primary key, the procedure determines what it should do. For example:




Code Snippet

CREATE PROCEDURE udp_users_processing
@key int output,
@name varchar(200),
@status int
AS
IF IsNull(@key,0)=0
BEGIN
INSERT INTO ut_users(key, name, status) VALUES (@key, @name, @status)
SET @key = SCOPE_IDENTITY()
END
ELSE
IF KEY > 0
UPDATE ut_users SET key = @key, name = @name, status = @status
ELSE
BEGIN
DELETE FROM ut_users WHERE key = @key
END
This has the advantage of being compact, but it has issues with VS.NET and designer support. Loss of designer support isn't a huge problem, but it can be handy to have. I'm also not certain how this approach would work when using typed dataset and the table adapter to do updates.

What is YOUR opinion? How would YOU approach this in your situations? Are there other alternatives that might work just as well?

View 1 Replies View Related

Long Running Stored Procedure Status

Mar 24, 2008

I have a stored procedure in SQL 2005 that purges data, and may take a few minutes to run. I'd like to report back to the client with status messages as the sp executes, using PRINT statements or something similar. I imagine something similar to BACKUP DATABASE, where it reports on percentage complete as the backup is executing.

I can't seem to find any information on how to do this. All posts on this subject state that it's not possible; that PRINT data is returned after the procedure executes. However it would seem possible since BACKUP DATABASE, for example, does this.


Is there any way to send status type messages to the client as the sp is executing??

Thanks.

View 6 Replies View Related

Timeout Errors When Execution Long Running Procedure

Apr 21, 2007

When I execute a long running procedure, I get timeout errors when other users try to execute other procedures with UPDATE or INSERT statements.



I suspect that the other procedures are trying to execute DML statements on tables that are locked by the long running procedure.



I have a sharred trigger on all my tables that creates and updates records in tables AuditLogDetails and AuditLogParent for keeping a log of modifications. I suspect that tables AuditoLogDetails and AuditLogParent are locked by the long running procedure.



How can I change the LOCKING behavior of the long running procedure to fix the time out errors that I get?



The long running procedure is displayed below.



ALTER PROCEDURE [dbo].[spPostPresenceToHistory2]

@PostDate DateTime,

@Department Int,

@Division Int,

@Testing Bit = 0,

@XDoc xml OUTPUT,

@XDoc2 xml OUTPUT,

@ModifierID varchar(20),

@Comment varchar(200)

AS

BEGIN

BEGIN TRANSACTION

DECLARE @PostCount Int,@PreCount Int,@DiffCount Int

IF @Testing=1

BEGIN

PRINT 'DELETE FROM History2_Presence'

EXEC sp_SetPostingProperties 'History2_Presence',@ModifierID,@Comment

SELECT @PreCount=COUNT(*) FROM History2_Presence

IF EXISTS(SELECT E.ID FROM History2_Personel E WHERE E.PostDate=@PostDate)

BEGIN

DELETE FROM History2_Presence FROM History2_Presence H

INNER JOIN History2_Personel Ps ON H.Personel_ID=Ps.ID AND Ps.PostDate=@PostDate

WHERE Ps.Category_Department_ID=@Department AND Ps.Category_Division_ID=@Division AND H.Date_de_Presence=@PostDate

AND EXISTS (SELECT P.ID FROM Presence P

WHERE (P.Date_de_Presence=@PostDate AND P.Personel_ID=H.Personel_ID AND P.Travaille_de_Jour=H.Travaille_de_Jour) OR (P.ID=H.ID))

END

ELSE

BEGIN

DELETE FROM History2_Presence FROM History2_Presence H

INNER JOIN Personel As Ps ON H.Personel_ID=Ps.ID

WHERE Ps.Category_Department_ID=@Department AND Ps.Category_Division_ID=@Division AND H.Date_de_Presence=@PostDate

AND EXISTS (SELECT P.ID FROM Presence P

WHERE (P.Date_de_Presence=@PostDate AND P.Personel_ID=H.Personel_ID AND P.Travaille_de_Jour=H.Travaille_de_Jour) OR (P.ID=H.ID))

END

SELECT @PostCount=COUNT(*) FROM History2_Presence

IF @PreCount<>@PostCount

BEGIN

SET @DiffCount = @PreCount-@PostCount

SET @XDoc2.modify('

insert <Table Name="History2_Presence" RecordDeleted="{ sql:variable("@DiffCount") }"/> as last into /Deleted_Records[1]

')

END

END

PRINT 'INSERT INTO History2_Presence'

EXEC sp_SetPostingProperties 'History2_Presence',@ModifierID,@Comment

SELECT @PreCount=COUNT(*) FROM History2_Presence

INSERT INTO [dbo].[History2_Presence]

([ID]

,[User_ID]

,[Personel_ID]

,[Date_de_Presence]

,[Category_Motif_ID]

,[DateEntre]

,[Category_TypeDePresence_ID]

,[Travaille_de_Jour]

,[Heur_Supplementaire_Travaille]

,[prime_transport]

,[Tarif]

,[Jour_Travaille]

,[Montant_Supplementaire_Par_Heur]

,[Salair_par_Jour]

,[Salair_Minimum]

,[IsAutomaticRec])

SELECT [P].[ID]

,[P].[User_ID]

,[P].[Personel_ID]

,[P].[Date_de_Presence]

,[P].[Category_Motif_ID]

,[P].[DateEntre]

,[P].[Category_TypeDePresence_ID]

,[P].[Travaille_de_Jour]

,[P].[Heur_Supplementaire_Travaille]

,[P].[prime_transport]

,[P].[Tarif]

,[P].[Jour_Travaille]

,[P].[Montant_Supplementaire_Par_Heur]

,[P].[Salair_par_Jour]

,[P].[Salair_Minimum]

,[P].[IsAutomaticRec]

FROM [dbo].[Presence] AS P

INNER JOIN Personel As Ps ON P.Personel_ID=Ps.ID

WHERE P.Date_de_Presence=@PostDate AND Ps.Category_Department_ID=@Department AND Ps.Category_Division_ID=@Division

AND NOT EXISTS

(SELECT HP.ID FROM History2_Presence HP

WHERE (HP.Date_de_Presence=@PostDate AND HP.Personel_ID=P.Personel_ID AND HP.Travaille_de_Jour=P.Travaille_de_Jour) OR (HP.ID=P.ID))



SELECT @PostCount=COUNT(*) FROM History2_Presence

IF @PreCount<>@PostCount

BEGIN

SET @DiffCount = @PostCount-@PreCount

SET @xdoc.modify('

insert <Table Name="History2_Presence" RecordAdded="{ sql:variable("@DiffCount") }"/> as last into /Inserted_Records[1]

')

END

IF @Testing=0

BEGIN

PRINT 'DELETE FROM Presence'

EXEC sp_SetPostingProperties 'Presence',@ModifierID,@Comment

SELECT @PreCount=COUNT(*) FROM Presence

DELETE FROM Presence FROM Presence P

INNER JOIN Personel As Ps ON P.Personel_ID=Ps.ID

WHERE P.Date_de_Presence=@PostDate AND Ps.Category_Department_ID=@Department AND Ps.Category_Division_ID=@Division

AND EXISTS

(SELECT HP.ID FROM History2_Presence HP

WHERE (HP.Date_de_Presence=@PostDate AND HP.Personel_ID=P.Personel_ID AND HP.Travaille_de_Jour=P.Travaille_de_Jour) OR (HP.ID=P.ID))

SELECT @PostCount=COUNT(*) FROM Presence

IF @PreCount<>@PostCount

BEGIN

SET @DiffCount = @PreCount-@PostCount

SET @XDoc2.modify('

insert <Table Name="Presence" RecordDeleted="{ sql:variable("@DiffCount") }"/> as last into /Deleted_Records[1]

')

END

END



COMMIT TRANSACTION

END







View 1 Replies View Related

DB Engine :: TLog Does Not Get Truncated During Long Running Stored Procedure

Nov 8, 2015

I have a vendor database that has a stored procedure that runs a long time.Eventually, the database runs out of log space.

Setting the database to FULL and doing frequent log backups does not work.

The log does not get truncated during this log backups.

The stored procedure in question has SET XACT_ABORT ON statement at the beginning.

View 4 Replies View Related

Procedure Or Function 'stored Procedure Name' Expects Parameter Which Was Not Supplied

Mar 26, 2007

Has anyone encountered this before?
Procedure or Function 'stored procedure name' expects parameter '@parameter', which was not supplied.
It seems that my code is not passing the parameter to the stored procedure.
When I click this hyperlink:
<asp:HyperLink
ID="HyperLink1"
Runat="server"
NavigateUrl='<%# "../Division.aspx?CountryID=" + Eval("CountryID")%>'
Text='<%# Eval("Name") %>'
ToolTip='<%# Eval("Description") %>'
CssClass='<%# Eval("CountryID").ToString() == Request.QueryString["CountryID"] ? "CountrySelected" : "CountryUnselected" %>'>
</asp:HyperLink>
it is suppose to get the country name and description, based on the country id.
I am passing the country id like this.
protected void Page_Load(object sender, EventArgs e)
{
PopulateControls();
}
private void PopulateControls()
{
string countryId = Request.QueryString["CountryID"];
if (countryId != null)
{
CountryDetails cd = DivisionAccess.GetCountryDetails(countryId);
divisionNameLabel.Text = cd.Name;
divisionDescriptionLabel.Text = cd.Description;
}
}
To my app code like this:
public struct CountryDetails
{
public string Name;
public string Description;
}
public static class DivisionAccess
{
static DivisionAccess()
public static DataTable GetCountry()
{
DbCommand comm = GenericDataAccess.CreateCommand();
comm.CommandText = "GetCountry";
return GenericDataAccess.ExecuteSelectCommand(comm);
}
public static CountryDetails GetCountryDetails(string cId)
{
DbCommand comm = GenericDataAccess.CreateCommand();
comm.CommandText = "GetCountryDetails";
DbParameter param = comm.CreateParameter();
param.ParameterName = "@CountryID";
param.Value = 2;
param.DbType = DbType.Int32;
comm.Parameters.Add(param);
DataTable table = GenericDataAccess.ExecuteSelectCommand(comm);
CountryDetails details = new CountryDetails();
if (table.Rows.Count > 0)
{
details.Name = table.Rows[0]["Name"].ToString();
details.Description = table.Rows[0]["Description"].ToString();
}
return details;
}
 
As you can see I have two stored procedures I am calling, one does not have a parameter and the other does. The getcountry stored procedure returns the list of countries in a menu that I can click to see the details of that country. That is where my problem is when I click the country name I get
Procedure or Function 'GetCountryDetails' expects parameter '@CountryID', which was not supplied
Someone please help!
 
Thanks Nickdel68

View 5 Replies View Related

Error: String Must Be Exactly One Character Long

Aug 27, 2007

hi all, i'm retreiving user input using textboxes and saving to a gridview. i'm getting this error and i dont know whats causing it. <asp:SqlDataSource ID="SqlDataSource1" runat="server"
InsertCommand="INSERT INTO test101(Surname,Names,Regno)VALUES (@Surname, @Names, @Regno)"ConnectionString="<%$ ConnectionStrings:engineeringConnectionString %>" ProviderName=System.Data.SqlClient
ConflictDetection="CompareAllValues" >
 
<InsertParameters>
<asp:ControlParameter ControlID="TextBox1" DefaultValue="TextBox1.Text" Name="Surname"
PropertyName="Text" Size="50" Type=Char />
<asp:ControlParameter ControlID="TextBox2" DefaultValue="TextBox2.Text" Name="Names"
PropertyName="Text" Size="50" Type=Char />
<asp:Parameter DefaultValue="TextBox3.Text" Name="Regno" />
</InsertParameters>
</asp:SqlDataSource>
<asp:GridView ID="GridView1"
runat="server" AutoGenerateColumns="False" AutoGenerateDeleteButton="True" DataKeyNames="ID"AutoGenerateEditButton="True" AllowSorting="True" BackColor="LightGoldenrodYellow"
BorderColor="Tan" BorderWidth="1px" CellPadding="2" ForeColor="Black" GridLines="None" PageSize="20"
Height="374px" EmptyDataText="null" DataSourceID=SqlDataSource1 Visible="False" >
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True"
SortExpression="ID" />
<asp:BoundField DataField="Surname" HeaderText="Surname" SortExpression="Surname" />
<asp:BoundField DataField="Names" HeaderText="Names" SortExpression="Names" />
<asp:BoundField DataField="Registration" HeaderText="Registration" SortExpression="Registration" />
<asp:BoundField DataField="Grade" HeaderText="Grade" SortExpression="Grade" />
 
</Columns>
</asp:GridView>
and the code behind is:protected void Page_Load(object sender, EventArgs e)
{SqlConnection conn = new SqlConnection("Data Source=(local);Initial Catalog=engineering; Integrated Security=True");
 
conn.Open();
 
 
GridView1.DataBind();
conn.Close();
 
}
 public void login1_Click(object sender, EventArgs e)
{
 
SqlDataSource1.Insert();
 
Response.Write("you have successfully being added to the database");
 can anyone help?!!!

View 1 Replies View Related

Is Too Long. Maximum Length Is 128. Error

Apr 17, 2006

I try to Update a field of a table using this statementUPDATE Table SET field="Forget.......(long text)" WHERE id=1and I get this error The identifier that starts with 'Forget your bus
excursions. Marta Pati&#241;o takes a trip out of this world at La
Laguna's Science Museum.
In April 2001, De' is too long. Maximum length is 128.What is wrong?

View 3 Replies View Related

Error [BC30494] Line Is Too Long

Jul 25, 2007

Hi,
I have a problem with a report in SSRS 2005. I tried to add some custom code to a report.
The code is absolutely simple and correct.
But when trying to show the report the debugger shows the following error message:
error [BC30494] Line is too long.

When I remove the code the report works again.

The code is about 12 words and could not be the problem.

Could anyone help please?

Best regards,
Stefoon

View 4 Replies View Related

Error In DTSX At The End Of Long Running ETL Process

Feb 14, 2006

Hi,

We have a DTSX in which parallel threads are processing ETL. There is a Final step in the DTS to do cleanup tasks. we are getting the following error after ETL completes. This is not consistently reproduced.

Description: An OLE DB error has occurred. Error code: 0x80004005. An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80004005 Description: "Login timeout expired". An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80004005 Description: "Unable to complete login process due to delay in prelogin response". An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80004005 Description: "Shared Memory Provider: Timeout error [258].

Connection manager is set as Localhost.

Can somebody help us out here?

thanks

View 1 Replies View Related

Error - Document Contains One Or More Extremely Long Lines Of Text

May 6, 2008

Hi,

I've created a dataset with 27 measures and 20 query parameters. When attempting to load the report containing this dataset I'm shown the message;

'Document contains one or more extremely long lines of text. These lines will cause the editor to respond slowly when you open the file. Do you still want to open the file.'

If I do open the file it does indeed respond very slowly or even hangs.

I can manually format the XML code but amending the code in any way (i.e. using the layout designer to move a chart) removes my formatting and re-introduces the problem.

Are these an unreasonable amount of measures / parameters?

Environment;
VS2005 v8.0.507
MSSQL 2005 9.00.1399.06 Build 3790 SP2
Windows Server 2003 SP2

Many thanks.

View 1 Replies View Related







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