You are here: Re: Need to declare multiple values « MsSQL Server « IT news, forums, messages
Re: Need to declare multiple values

Posted by MC on 10/30/06 20:08

The problem is in the variable declaration. You stated DECLARE @Merchant
VARCHAR
which basically means varchar(1). That means your '1,2,3,4' got trimmed to
the '1'.
Try putting DECLARE @Merchant VARCHAR(100) or something like that.


MC



"Andrew Tatum" <andrew.tatum@gmail.com> wrote in message
news:1162238426.301761.85480@m7g2000cwm.googlegroups.com...
> Alright, so I have this problem. I want to make it easy for me and
> others to be able to run a query and easily choose whether we want
> Merchants or NonMerchants. Previously, we would have to comment out
> bits of code and would leave things messy (it would also leave room for
> error). So, I'm thought DECLARE and SET would work. Wrong.
>
> This is what I have....
>
> DECLARE @Merchant VARCHAR
>
> SET @Merchant = (Select CONVERT(VARCHAR, Id) + ','
> FROM AdminAdvertiserTypesDDL
> WHERE Id IN (1,3,4,5)
> ) // Includes Active, Out of Business, Cease to do business, Inactive
>
> I've also tried...
>
> SET @Merchant = '1,3,4,5'
>
> Then, in the query itself I try:
>
> WHERE AdminAdvertiserTypesDDL.Id = @Merchant
> or
> WHERE AdminAdvertiserTypesDDL.Id IN @Merchant
> or
> WHERE AdminAdvertiserTypesDDL.Id IN (@Merchant)
> or
> WHERE AdminAdvertiserTypesDDL.Id LIKE @Merchant
>
> Either way, it will ONLY show me the merchants whose Id is 1. When I
> make the query:
>
> WHERE AdminAdvertiserTypesDDL.Id IN (1,3,4,5)
>
> I finally get the desired results.
>
> Any ideas or tips?
>
> Thank you so much!
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация