Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Question on how to assign multiple values passed

Author  Topic 

sqlnovice123
Constraint Violating Yak Guru

262 Posts

Posted - 2010-04-16 : 11:03:50

Hi ,

I have declared the below parameters:

DECLARE

@ClientType varchar(200)
@Client varchar(30),


SET @ClientType = '154246'
SET @Client = '15'


I input the below values which will be displayed in another reporting fron end:

INSERT MARPTGEN_PARAMLIST

VALUES
(
'15','Broker-Dealer: Pershing Group LLC',1)



INSERT MARPTGEN_PARAMLIST

VALUES
(
'15','Insurance/Reinsurance Co.: The Travelers Companies Inc',1)


Users will have the ability to multi select via a combo box:
ClientType: Broker-Dealer
ClientType: Insurance/Reinsurance Co.

I try and select the passed paramter with multiple values in order to get an output as 'Avg of Peer Group ' + @ClientType + ' Clients',

example Avg of Peer Group.Broker-DealerInsurance/Reinsurance Co. Clients

I get the below error because I am trying to assign multiple values to a variable.

How can I achieve this differently?

Msg 512, Level 16, State 1, Line 261
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2010-04-16 : 11:18:22
First, Check out thie link. It'll help you with using arrays in SQL. I'm not 100% sure that using an array is the best solution, but I do not fully understand your requirements:
http://www.sommarskog.se/arrays-in-sql.html

For future reference, and even for this issue, check out the link below. It will help you set up your schema (DDL) and data (DML) so that we can write queries against it and help you solve your issue better:
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Go to Top of Page

sqlnovice123
Constraint Violating Yak Guru

262 Posts

Posted - 2010-04-16 : 11:20:01
So if I have a column ClientType with values

as below
Broker-Dealer
InvestmentManager

Can I make the values as column names instead and then all i need to do is concatenate? But I am not sure how to do this if it is possible?

Column1 Column2
Broker-Dealer InvestmentManager
Go to Top of Page

sqlnovice123
Constraint Violating Yak Guru

262 Posts

Posted - 2010-04-16 : 11:31:15
Or I could use pivot?
Go to Top of Page
   

- Advertisement -