Unable To Pass Queue Name In A Parameter For The FROM Clause Of RECEIVE Statement

Mar 19, 2008

I'm writing some generalized stored procedures for use form managed code. The following stored proc works great:

CREATE PROCEDURE fnd_Send (
@Message VARCHAR(5000),
@Contract SYSNAME,
@MessageType SYSNAME,
@FromService SYSNAME,
@ToService VARCHAR(100),
@Encrypted Bit
)
AS
BEGIN
DECLARE @Handle UNIQUEIDENTIFIER;

BEGIN DIALOG CONVERSATION @Handle
FROM SERVICE @FromService
TO SERVICE @ToService
ON CONTRACT @Contract
WITH ENCRYPTION = OFF;

SEND ON CONVERSATION @Handle
MESSAGE TYPE @MessageType(@Message);

Notice the use of SYSNAME parameters €“ translating the parameter into an object name - allows it to work in the BEGIN DIALOG statement when an system object is needed. Works create and cues up generic messages.

The following will not compile:

CREATE PROCEDURE fnd_Receive (
@Queue SYSNAME,
@Message VARCHAR(5000) out,
@MessageType SYSNAME out
)
AS
BEGIN
DECLARE @Handle UNIQUEIDENTIFIER;

RECEIVE TOP (1)
@Handle = conversation_handle,
@MessageType = message_type_name,
@Message = message_body
FROM @Queue;
END
GO

It won€™t let me use the SYSNAME field @Queue in the FROM clause. I€™m getting an unfriendly:

Msg 102, Level 15, State 1, Procedure fnd_Receive, Line 15
Incorrect syntax near '@Queue'.

It looks like maybe I can€™t bind a variable in the FROM clause €“ perhaps like you cannot in a SELECT statement. I can fall back to dynamic SQL in the stored proc or in the managed code; I was hoping not to.


Can anyone shed any light on this? Also, are there any other techniques I'm missing to avoid falling back to a dynamic SQL statement.

Thank you in advance -

Jeff Odell
Catapult Systems

View 3 Replies


ADVERTISEMENT

Pass IN Clause Of Where As Parameter

Sep 29, 2005

HI

I want to Run a Dynamic SQL in which i need to pass IN parameters.

DECLARE @QUERY varchar(100)
DECLARE @Paremeter varchar(10)
SET @Parameter = '1,2'
SET @QUERY='SELECT * FROM TABLE_NAME WHERE COLUMN_NAME IN (' + @parameter + ')'

But this causes an error that cant convert varchar string to int. Please dont suggest to avoid Dynamic Sql. I have to use it.

View 1 Replies View Related

How To Pass Dynamic Parameter To Order BY Clause

Sep 13, 2004

Hi,

I use a DataGrid to show the data, and I want it has a sorting and Paging function,
so I use dataset to collect the data from middle tier function and stored procedure.
I have code in aspx page like BindData(ViewState("SortExpr")).

In the stored procedure I pass SortExpr as parameter as following:

CREATE Procedure Ruying_AutoSearch10
(
@Make varchar(50),
@Model varchar(50) = NULL,
@Condition varchar(20) = NULL,
@Miles float,
@Zipcode varchar(5),
@SortExpr varchar(100)
)
AS

DECLARE @RowCount int
SELECT @RowCount = Count(*) FROM ZIPCodes WHERE ZIPCode = @Zipcode AND CityType = 'D'

if @RowCount > 0
BEGIN
SELECT
z.ZIPCode, z.City, z.StateCode, a.Make, a.Model, a.AutoPrice, a.AutoPrice2, a.AutoYear, a.Mileage, a.AdID, a.ImageURL, dbo.DistanceAssistant(z.Latitude,z.Longitude,r.Latitude,r.Longitude) As Distance
/*
The above functions requires the Distance Assistant.
*/
FROM
ZIPCodes z, RadiusAssistant(@ZIPCode,@Miles) r, AutoAd a
WHERE
z.Latitude <= r.MaxLat
AND z.Latitude >= r.MinLat
AND z.Longitude <= r.MaxLong
AND z.Longitude >= r.MinLong
AND z.CityType = 'D'
AND z.ZIPCodeType <> 'M'
AND z.ZIPCode = a.Zipcode
AND a.AdActive = '1'
AND a.AdExpiredate >= getdate()
AND a.Make = @Make
AND a.Model = IsNull(@Model,a.Model)
AND a.Condition = IsNull(@Condition, a.Condition)
AND dbo.DistanceAssistant(z.Latitude,z.Longitude,r.Latitude,r.Longitude) <= @Miles
ORDER BY @SortExpr
END
ELSE
SELECT -1 As ZIPCode
--ZIP Code not found...
GO


but I got the error as "variables are only allowed when ordering by an expression referenceing
a column name". How I fix this error? Please help.

Thanks.

Lin

View 9 Replies View Related

Dynamic Queue Receive Sql ?

Sep 27, 2006

Hi There

My activation sp must be able to read of various queues.

I load a variable with the queue name that activated the sp btu i cannot get the syntax working to receive or get a conversation group of a queue name that is a variable.

I have tried:

WAITFOR

(

RECEIVE message_body, conversation_handle, message_type_name, message_sequence_number, conversation_group_id FROM @callingQueue INTO @msgTable WHERE conversation_group_id = @conversationGroup

), TIMEOUT 2000;

But i get this error:

Incorrect syntax near '@callingQueue'.

Looks like you cannot use a variable.

So i tried the following:

SELECT @SQL = N' WAITFOR

(

RECEIVE message_body, conversation_handle, message_type_name, message_sequence_number, conversation_group_id FROM @callingQueue INTO @msgTable WHERE conversation_group_id = @conversationGroup

), TIMEOUT 2000'

EXEC sp_executesql @SQL, N'@msgTable table output'

But i get the same error.

How do i receive of a queue using a vriable holding the queue name ?

Thanx

View 13 Replies View Related

Receive All Messages On Queue

Feb 12, 2007

Hi i am trying to create a batch process then commit for all messages on the queue. The problem i am having is when i run my query (As below) I only receive the first message and the corresponding end dialog for the message although i have 2000 records sitting in the queue. It is my understanding that receive without any criteria i.e top(1) or where clause should select everything of the queue. I tried receive top(100) expecting 100 records but still only got 2 back.

any help appreciated.



WAITFOR(RECEIVE

queuing_order,

conversation_handle,

message_type_name,

message_body

FROM [RMIS_COMMS_Queue]

INTO @tableMessages), TIMEOUT 2000;



View 4 Replies View Related

Unable To Pass A Parameter Via URL - It Doesn't Look Like Rocket Science...

May 21, 2007

Hi All,



I'm unable to pass a report a parameter via a URL and thoughts on what I'm messing up?



Browser is IE7



The following is my url... Report name is Report3 and the Parameter name is WONumber



http://report/Reports/Pages/Report.aspx?ItemPath=%2fOutage+Reporting%2fDevelopment%2fReport3&WONumber=264698

View 5 Replies View Related

SQL Server 2012 :: Create Variable In Select Query And Use It In Where Clause To Pass The Parameter

Sep 9, 2014

I am writing a stored procedure and have a query where I create a variable from other table

Declare @Sem varchar (12) Null
@Decision varchar(1) Null
Select emplid,name, Semester
Decision1=(select * from tbldecision where reader=1)
Decision2=(select * from tbldecision where reader=2)
Where Semester=@Sem
And Decision1=@Decision

But I am getting error for Decision1 , Decision2. How can I do that.

View 6 Replies View Related

Can't Receive Message From Queue (Async Trigger)

Sep 1, 2006

Hi Folks,

I've found a pretty good code example on http://www.dotnetfun.com for a Asynchronous Trigger.

I've parsed through the Code, to understand how to wirte my own Async Trigger with a Service Broker, but the Code isn't working! It seems that the stored procedure don't receive the messages in the queue, but the queue get's filled.

MessageType


 CREATE MESSAGE TYPE  myMsgXML
 VALIDATION = WELL_FORMED_XML;
Contract

CREATE CONTRACT myContractANY
 (myMsgXML SENT BY ANY)
Queue

CREATE QUEUE myQueue
 WITH STATUS = ON,
 RETENTION = ON,
 ACTIVATION
 (
  STATUS = ON,
  PROCEDURE_NAME = sp_myServiceProgram,
  MAX_QUEUE_READERS = 5,
  EXECUTE AS SELF
 )
Service

CREATE SERVICE myService ON QUEUE myQueue  (myContractANY)
Procedure (greped from http://www.dotnetfun.com/)

CREATE PROC sp_myServiceProgram
AS
-- This procedure will get triggered automatically
-- when a message arrives at the
-- Let's retrieve any messages sent to us here:
DECLARE @XML XML,
  @MessageBody VARBINARY(MAX),
  @MessageTypeName SYSNAME,
  @ID INT,
  @COL2 VARCHAR(MAX);
DECLARE @Queue TABLE (
  MessageBody VARBINARY(MAX),
  MessageTypeName SYSNAME);
WHILE (1 = 1)
BEGIN
 WAITFOR (
  RECEIVE message_body, message_type_name
  FROM myQueue  INTO @Queue
 ), TIMEOUT 5000;
 -- If no messages exist, then break out of the loop:
 IF NOT EXISTS(SELECT * FROM @Queue) BREAK;
 DECLARE c_Test CURSOR FAST_FORWARD
  FOR SELECT * FROM @Queue;
 OPEN c_Test;
 FETCH NEXT FROM c_Test
  INTO @MessageBody, @MessageTypeName;
 WHILE @@FETCH_STATUS = 0
 BEGIN
  -- Let's only deal with messages of Message Type
  -- myMsgXML:
  IF @MessageTypeName = 'myMsgXML'
  BEGIN
   SET @XML = CAST(@MessageBody AS XML);
   -- Now let's save the XML records into the
   -- historical table:
   INSERT INTO tblDotNetFunTriggerTestHistory
    SELECT tbl.rows.value('@ID', 'INT') AS ID,
     tbl.rows.value('@COL2', 'VARCHAR(MAX)') AS COL2,
     GETDATE() AS UPDATED
    FROM @XML.nodes('/inserted') tbl(rows);
  END
  FETCH NEXT FROM c_Test
   INTO @MessageBody, @MessageTypeName;
 END
 CLOSE c_Test;
 DEALLOCATE c_Test;
 -- Purge the temporary in-proc table:
 DELETE FROM @Queue;
END
Send Message in a Update Trigger

SELECT @XML = (SELECT * FROM inserted FOR XML AUTO);
  -- Send the XML records to the Service Broker queue:
  DECLARE @DialogHandle UNIQUEIDENTIFIER,
   @ConversationID UNIQUEIDENTIFIER;
  /*
   The target Service Broker service is the same
   service as the initiating service; however, you
   can set up this type of trigger to send messages
   to a remote server or another database.
  */
  BEGIN DIALOG CONVERSATION @DialogHandle
   FROM SERVICE myService
   TO SERVICE 'myService'
   ON CONTRACT myContractANY;
  SEND ON CONVERSATION @DialogHandle
   MESSAGE TYPE myMsgXML
   (@XML);
  -- Let's detect an error state for this dialog
  -- and rollback the entire transaction if one is
  -- detected:
  IF EXISTS(SELECT * FROM sys.conversation_endpoints
   WHERE conversation_handle = @DialogHandle
   AND state = 'ER')
   RAISERROR('Dialog in error state.', 18, 127);
  ELSE
  BEGIN
   --I want to list the queue after the trigger so I disabled
   --END CONVERSATION @DialogHandle;
   COMMIT TRAN;
  END
The Problem is, that the Procedure doesn't even get started! So I tried to receive the Queues manually

WAITFOR (
  RECEIVE message_body, message_type_name
  FROM myQueue  INTO @Queue
 ), TIMEOUT 5000;

and I run always into the timeout and get nothing back. A Select * FROM myQueue gives me some results back. Why I can't recevie?
Would be grateful for help, or at least a good tutorial, I haven't found one yet....
thx and greez
     Karsten

View 1 Replies View Related

Receive Messages From Queue Based On Message_type_name

Dec 15, 2006

I have 2 messages types for a queue and would like to use one application that receives messages of one type from the queue and another application that will receieve messages of a different type from the same queue.

Is that possible and if yes how?

SampK

View 1 Replies View Related

Unable To Pass Null Value With DropDownList Parameter In Reporting Services 2005

Dec 3, 2007



Hello,

I have a stored procedure that on two fields it allows null. On the report, I have two DropDownList boxes that are populated with data, however, I would like the user to be able to have the option of not selecting an item from these list, thus passing null to the stored procedure.

When I goto "Report | Report Parameters" I have set these fields to "allow null" and "allow blank" and at the bottom I also gave it the default value of null.

When I run the report in preview mode, those two dropdownlist have a <Select a Value> and my assumption is since I want them to pass null, I will just leave them that way. However, when the report is ran, I receive an error saying "Please select a value for the parameter: (my parameter)". So it forces me to select an option at which I don't want to do.

How can I set this to pass a null?

Thanks,
Flea#

View 11 Replies View Related

SQL 2012 :: Queue Activation Is Enabled But No Receive Executed

Sep 14, 2015

Our Sql server is not responding, So we restarted the server and modified one of the sp code. After that we are getting frequently every 2 min giving the below error

The queue 855365233 in database 9 has activation enabled and contains unlocked messages but no RECEIVE has been executed for 453199 seconds

View 0 Replies View Related

Pass Column Name Using Parameter In SQL Statement...

Oct 19, 2007

Hi,I am trying to Pass Column Name(FieldName) using Parameter in SQLStatement... But i am getting error...how can i pass Column name using parameter???Example:in table i have fieldname ECountry...Select @FName='ECountry'Select @FName from Table...How it works???Thanx in Advance,Regards,Raghu...

View 5 Replies View Related

T-SQL (SS2K8) :: Pass A Column Name Using Parameter In Select Statement

Sep 5, 2014

I have a temp table that hosts data from a MDX query, I want to select a column from that table by passing in a parameter and then insert to a new table.

Here's the table structure, let's call it #temp

[Product].[Product Hierarchy].[level 03].[Member_CAPTION], [Measures].[Gross Sales]
Bike, 200
Accessory , 100

I have a table in the DB created as [ProductSales]

Here's what works for me:

insert into [ProductSales](Product, Sales)
Select convert(varchar(20), "[Product].[Product Hierarchy].[level 03].[Member_CAPTION]") as 'Product' , convert(decimal(18,2), [Measures].[Data]) as 'Sales'
From #temp

But in reality the product level is not always on level 03, I want to define a parameter @Product and pass it to the select list.

Here's what I tried to do:

Declare @Product varchar(500) = convert(varchar(20), "[Product].[Product Hierarchy].[level 01].[Member_CAPTION]")
Declare @SQL varchar(MAX)
SET @SQL='insert into [ProductSales](Product, Sales)
Select '+@Product+' as 'Product' , convert(decimal(18,2), [Measures].[Data]) as 'Sales'
From #temp'
Exec @SQL

But it threw me error, what is the right way to do it, is it because the double quote or single quote thing?

View 1 Replies View Related

Case Statement On Where Clause If Parameter =NULL

Jun 3, 2008

I am working on a Function that takes multiple parameters. I have a query that populates a temporary table, and then it processes some logic. My question is, if the parameter is passed as null, I dont want the query to be affected by this null value. Rather, I would like to not pass it at all to the query. So if the parameter is NULL, dont pass it through the query. I have the following but its not compiling right:


SELECT bom.pEngr_BOM_ID , bom.fEngr_Item_ID, det.pEngr_BOM_Detail_ID, 1, bom.Bill_Type, bom.Rev_Ltr, bom.Series_Ltr
FROM dbo.Engr_BOM_Control bom WITH (nolock)
INNER JOIN dbo.Engr_BOM_Detail det WITH (nolock)
ON det.fEngr_BOM_ID=bom.pEngr_BOM_ID
WHERE bom.pEngr_BOM_ID=@v_pEngr_BOM_ID
AND det.fEngr_BOM_ID=@v_pEngr_BOM_ID
CASE WHEN @v_Bill_Type IS NOT NULL THEN
AND bom.Bill_Type=@v_Bill_Type
END

View 3 Replies View Related

How To Pass Pass The Parameter In SQL Command In SSIS Package

Jul 31, 2006

Hi

   We already used Oracle Datasatage Server the following Query statement for Source and Lookup.here there is parameter maping in the SQl Statement . How can achive in SSIS the Folowing Querystatment?

 

Query 1: (source View Query)
SELECT
V_RDP_GOLD_PRICE.GDR_PRODUCT_ID, V_RDP_GOLD_PRICE.ASSET_TYPE, V_RDP_GOLD_PRICE.PREFERENCE_SEQ, V_RDP_GOLD_PRICE.RDP_PRICE_SOURCE, TO_CHAR(V_RDP_GOLD_PRICE.PRICE_DATE_TIME,'YYYY-MM-DD HH24:MI:SS'), TO_CHAR(V_RDP_GOLD_PRICE.REPORT_DATE,'YYYY-MM-DD HH24:MI:SS'), V_RDP_GOLD_PRICE.SOURCE_SYSTEM_ID
FROM
V_RDP_GOLD_PRICE V_RDP_GOLD_PRICE
WHERE
REPORT_DATE = (select max(report_date) from V_RDP_GOLD_PRICE where source_system_id = 'RM' )



 

Query 2: (look up )

 


SELECT
GDR_PRODUCT_ID,
TO_CHAR(MAX(PRICE_DATE_TIME),'YYYY-MM-DD HH24:MI:SS') ,
TO_CHAR(REPORT_DATE,'YYYY-MM-DD HH24:MI:SS')
FROM
V_RDP_GOLD_PRICE
where
GDR_PRODUCT_ID = :1 and
report_date = TO_DATE(:2,'YYYY-MM-DD HH24:MI:SS')  AND
PRICE_DATE_TIME BETWEEN TO_DATE(:2,'YYYY-MM-DD HH24:MI:SS') - 7) AND TO_DATE(:2,'YYYY-MM-DD HH24:MI:SS')
GROUP BY GDR_PRODUCT_ID, TO_CHAR(REPORT_DATE,'YYYY-MM-DD HH24:MI:SS')



 

please anyone give the sample control flow  and how to pass the parameter?

 

Thanks & regards

Jeyakumar.M

 

View 1 Replies View Related

Unable To Turn On SSB Queue

Jul 17, 2007

Hi all:



I've been stress-testing SSQ queue by pumping a lot of data to it. For the most part, the queue is cleared out fairly quickly using the activation stored procedure. However, for a second time now, I encountered a strange problem. For some reason, one message got stucked in the queue and would not dequeue. The status of the queue is turned OFF somehow. So I ran:



ALTER QUEUE [dbo].[TestQueue] WITH STATUS = ON;



to turn the queue status back on, but it would not turn ON. The last time I had this problem, I ended up dropping and recreating everything.



Has anyone experienced this strange behavior? Please help.



Thanks,



TDev

View 4 Replies View Related

RECEIVE Statement Not Working

Nov 19, 2007

I followed an example using the AdventureWorks database to set up a simple messaging test on one database:




Code Block
-- We will use adventure works as the sample database
USE AdventureWorks
GO
-- First, we need to create a message type. Note that our message type is
-- very simple and allowed any type of content
CREATE MESSAGE TYPE JobRequest
VALIDATION = NONE
GO
-- Once the message type has been created, we need to create a contract
-- that specifies who can send what types of messages
CREATE CONTRACT JobRequestor
(JobRequest SENT BY INITIATOR)
GO
-- The communication is between two endpoints. Thus, we need two queues to
-- hold messages
CREATE QUEUE RequestorQueue
CREATE QUEUE ReceiverQueue
GO
-- Create the required services and bind them to be above created queues
CREATE SERVICE Requestor
ON QUEUE RequestorQueue
CREATE SERVICE Receiver
ON QUEUE ReceiverQueue (JobRequestor)
GO
-- At this point, we can begin the conversation between the two services by
-- sending messages
DECLARE @conversationHandle UNIQUEIDENTIFIER
DECLARE @message NVARCHAR(100)
BEGIN
BEGIN TRANSACTION;
BEGIN DIALOG @conversationHandle
FROM SERVICE Requestor
TO SERVICE 'Receiver'
ON CONTRACT JobRequestor
WITH ENCRYPTION=OFF, LIFETIME= 600;
-- Send a message on the conversation
SET @message = N'Hello, World';
SEND ON CONVERSATION @conversationHandle
MESSAGE TYPE JobRequest (@message)
COMMIT TRANSACTION
END
GO
-- Receive a message from the queue
RECEIVE CONVERT(NVARCHAR(max), message_body) AS message
FROM ReceiverQueue
-- Cleanup
DROP SERVICE Sender
DROP SERVICE Receiver
DROP QUEUE SenderQueue
DROP QUEUE ReceiverQueue
DROP CONTRACT HelloContract
DROP MESSAGE TYPE HelloMessage
GO


This all works fine but if I run the section that creates the message and then copy the RECEIVE section to a new query window and execute it, nothing is returned. If I run the RECEIVE section within the same query window it returns the 'Hello World' message as expected. I am new to Service Broker and so am assuming that I am missing something obvious!!

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

How To Pass Values For The In Clause To The Stored Procedure?

Apr 7, 2008

hi friends,i need to select some of the employees from the EmpMaster using in clause. I tried to pass a string with the comma delemeters. it didn't produce all the records except the first in that string.shall i try with string functions in TSQL or any other options? Thanks and Regads,Senthilselvan.D 

View 4 Replies View Related

SQL 2012 :: Pass Where Clause To A Store Procedure

Nov 2, 2015

From my one app, a dynamic where clause will generate like below.

//where ordercity='london' and orderby='smith'
//where orderamount > 100 and shipcity='new york'

From server, I created a store procedure as below.

SELECT * FROM [Order] WHERE @whereSql

How to complete the store procedure so that I don't need to pass parameters one by one...

View 1 Replies View Related

Queue Insert Statement What Is The Best SQL Server 2005 Feature To Use?

Apr 4, 2007

Hello everybody, I'm not completly aware of the SQL server 2005 possibilities so I'd need an hints from somebody with a wide knowledge to understand the direction to take!

This is what I have to do.



I insert into a table XML message. the messages are pushed automatically by an application I have no ""control" on and I get several messages "at the same time".

Everytime the message is inserted into the database I need to trasform the XML data into the correspondent relational value and I know already that in some cases it could take a while (1 second can be considered a while..)
My worry is that in the moment I process one message I loose the other one inserted after ,,,


There is some tool that helps me to handte the process as I would..

I was looking into SQL service broker?

It can be the right choice?



Thank you for any help!!



Marina B.

View 1 Replies View Related

Need To Pass 'UserName' To SQL Select WHERE Clause In The Data Source

May 30, 2007

Hi.I bet this is a 101 question, but i'd appreciate any help!I am in the 'where...' section of the configure data source wizzard .Column: I grab 'UserName' Operator: I select '='BUT how do I get the UserName (The user is signed into the app)  Is it from the Form? Profile? Session?Ive tried profile.name.....  THANKS In advance.... Dan 

View 4 Replies View Related

How To Pass Value For The “in� Clause In The SQL Server Stored Procedure?

Jan 31, 2006

How to pass value for the “in� clause in the SQL server stored procedure? Let us consider the following code.
 
declare @Country varchar(200)
set @CountryIds='1,11'
select CountryName from COUNTRY where CountryId in (@CountryIds)
GO
 
In the above code, the lists of country ids are needed to feed from the front end. In the above example, we need to select countries for 1 and 11. So, how to pass this from front end and what will be the data type of the parameter. I am using front end as .Net. Please help in this regard. The stored procedure what I wrote was.
 
CREATE PROCEDURE [cmp].[Events_By_Country]
@CountryIds varchar(200)
AS
select CountryName from COUNTRY where CountryId in (@CountryIds)
GO
 
Which is not working.

View 1 Replies View Related

Store Procedures: Pass Array Of Numbers For IN Clause?

May 24, 2006

How does one pass into a Stored Procedure an array of numbers to be used in an IN clause? If I pass "1,2" in a VARCHAR, the stored procedure sees only the first number (1 in this case).
I'm using VB and ADO.NET, but I don't know how to set up the stored procedure for an array. Is there a parsing function to do this?
CREATE PROCEDURE TestInClause( @TeamList VARCHAR)ASSELECT Name FROM Teams WHERE TeamID IN (@TeamList); /* sees only 1st number */GO

View 2 Replies View Related

How To Pass Multiple Values To An IN Clause Through Stored Procedure

Jun 11, 2004

I created a stored procedure like the following in the hope that I can pass mulitple company_id to the select statement:


CREATE PROC sp_test @in_company_code nvarchar(1024)
AS

select company_code, name, description
from member_company
where company_code in (@in_company_code)


However, I tried the following :

exec sp_test 'abc', 'rrd', 'bbc'

Procedure or function sp_test has too many arguments specified.

and SQLServer doesn't like it.

Did I specify this stored procedure correct?
If so, how can I can pass multiple values to the stored procedure then to the sql statement?
If not, is it possible to specify a stored procedure like this?

Thanks!

View 2 Replies View Related

Reporting Services :: Pass Parameters - Error In List Of Values In IN Clause

Nov 30, 2015

I have created a ssrs report which connects to vertica database through odbc connection. When I try to pass parameter value through parameter (e.g.:  column name  IN (@parameter) )  then getting error message in query designer prompting  "Error in list of values in IN clause.  Unable to parse query text. ". Using sql server 2012 , visual studio 2010 version and HP Vertica 7.1 . 

View 6 Replies View Related

How Can I Pass A Parameter To Use In An IN

Oct 31, 2007

I'm trying to pass a comma delimited list of numbers to a parameter to use in an IN of my Where clause.
        Dim MySqlParamSelected As New SqlParameter("@Selected", SqlDbType.Int)        Cmd.Parameters.Add(MySqlParamSelected)        MySqlParamSelected.Value = Session("intSelected")
 WHERE tblSelected.Selected_ID IN (@Selected)
It will work if I only pass it one number (e.g. 78), but when I pass it more than one (e.g. 78,79) it fails.
Here is the error:
Msg 119, Level 15, State 1, Line 4Must pass parameter number 7 and subsequent parameters as '@name = value'. After the form '@name = value' has been used, all subsequent parameters must be passed in the form '@name = value'.
Does anyone know how I can correctly pass multiple numbers to use in my IN?

View 11 Replies View Related

Pass Parameter To SP

Jan 29, 2008

How do i pass a parameter to a stored proc using this command:   
object SqlHelper.ExecuteScalar (SqlConnection connection, string spName, params object[] parameterValues)
let's say that my parameter name is @ID and the value is IDval ..
 
thanx

View 2 Replies View Related

How Do I Pass A Parameter To A DTS ?

Nov 7, 2007

HiWe still use SqlServer 2000 and DTSs.My question is: Can I pass a parameter to a DTS and if yes then how ?We would like to plan our screen like this.The user will input a parameter on the screen/form and then the DTS willbe activated using the value inputed.We do have how to work around it if parameters can't be passed but itwould make things a lot easier and straightforward if we could.Thanks !David Greenberg

View 2 Replies View Related

Cannot Pass Parameter Via URL

May 22, 2008

I see a lot of posts asking for help with this type of problem but cannot find an answer that works. After 24 hours of trying, using examples from the Microsoft documentation, it's been utterly impossible to pass a parameter to a report via URL.

To make sure I'm not fighting more than one problem at the same time, I've stepped away from the production report I was trying to produce and created a simple report with a parameter named "p1". The only field on this test report is a textbox that displays the value of the parameter "p1". If I set the report up so that the user is queried for a value for "p1", the report works as expected -- the parameter is echoed back on the report.

The same thing can't be done via the URL. If I follow the docs and tack something like &rs:Command=Render&p1=hello onto the URL, I'm prompted for a value and/or told 'p1 is missing a value', depending on the visibility and default options I set for the parameter in the report definition.

I've tried every possible combination of settings I can think of for a parameter in the report definition, and every single one fails. Is this a task that's beyond RS abilities?

View 1 Replies View Related

How To Pass Mdx Parameter

Oct 26, 2007

Hi,

Any body can help me on passing parameters in to an MDX query?

sample :


SELECT NON EMPTY { [Measures].[Gross Profit], [Measures].[Sales Amount] } ON COLUMNS, NON EMPTY { ([Employee].[Employee Department].[Employee].ALLMEMBERS ) } DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS FROM [Adventure Works] where [Employee].[Department Name].[engineering] CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS

instead of engineering i want to pass a parameter Department.
I created another dataset for it


WITH MEMBER [Measures].[ParameterCaption] AS '[Employee].[Department Name].CURRENTMEMBER.MEMBER_CAPTION' MEMBER [Measures].[ParameterValue] AS '[Employee].[Department Name].CURRENTMEMBER.UNIQUENAME' MEMBER [Measures].[ParameterLevel] AS '[Employee].[Department Name].CURRENTMEMBER.LEVEL.ORDINAL' SELECT {[Measures].[ParameterCaption], [Measures].[ParameterValue], [Measures].[ParameterLevel]} ON COLUMNS , [Employee].[Department Name].ALLMEMBERS ON ROWS FROM [Adventure Works]


Parameter is populating perfectly but how i edit my MDX to accept that parameter ?


Thanks in Advance...

View 6 Replies View Related

How To Pass Parameter

Sep 5, 2007

Hi Friends,

I have two reports, one master report & one child report. If I click a patricular value in Territory column, It should take me to the child report where only rows which matches with the territory should be displayed. Since I'm new to SSRS, Kindly some guide me.

Please note that, in the child report I should not get any dropdown boxes for selection.


Thanks in advance

Naveen

View 2 Replies View Related

Reporting Services :: Unable To Pass Parameters Dynamically In SSRS 2012

Oct 1, 2015

I am creating simple report in ssrs and pass one parameter only. It will work perfectly (here user enter the parameter value). but i need that i should select the value in drop down box. i had tried many time and did different ways but I am unable to do it.

First i gave the parameter in my sql query in Data set (like WHERE COUNTRY = @COUNTRY) and i checked the Parameters tab in the data set. Here by default comes the Parameter Name: COUNTRY and Parameter value: [@COUNTRY].

Next i select COUNTRY Parameter in the Report Data Pane. and go to properties Here in General Tab: Name COUNTRY Prompt: COUNTRY, Select Get values from query in available values Tab (and also i tried with Select Get values from query in Default Value Tab) and Select Data set: Data Set1, Value field: COUNTRY and Label Field COUNTRY. And Click Ok

And tried to preview the report, it throwing below error

"An error Occured during local report processing.  The definition of the report is invalid. The Report Parameter 'COUNTRY' has a DefaultValue or a ValidValue that depends on the report parameter "COUNTRY". Forward dependencies are not valid.

How can I achieve dropdown list.What i missed? Even i unable to do it Multi valued parameters and Cascading parameters.

Actually i am working on SQL Express 2012 version.

View 5 Replies View Related







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