Monday, March 26, 2012
multi from multi
in the select i got a cell with strings like Jhon#@.#Yos#@.#Rami and i want to
check in the where cluase if one of the names (jhon, Yos or Rami) is in
(Rami, Mos, Dave (not a close list, i get it from another cell). is that
possible?
can i split the string and check for the name in one select statment?
What do i need to use? can i use decode or case?
SagiHere is an example form Anith
--Modify it for your needs
SELECT IDENTITY(INT) "n" INTO Numbers
FROM sysobjects s1
CROSS JOIN sysobjects s2
GO
DECLARE @.Ids VARCHAR(200)
SET @.Ids = '5,33,229,1,22'
SELECT SUBSTRING(@.Ids, n, CHARINDEX(',', @.Ids + ',', n) - n)
from numbers where substring(','+@.Ids,n,1)=','
AND n < LEN(@.Ids) + 1
drop table Numbers
"sagi aviram" <crisrobin@.013.net.il> wrote in message
news:440530d7$1@.news.barak.net.il...
> Hi,
> in the select i got a cell with strings like Jhon#@.#Yos#@.#Rami and i want
> to check in the where cluase if one of the names (jhon, Yos or Rami) is in
> (Rami, Mos, Dave (not a close list, i get it from another cell). is that
> possible?
> can i split the string and check for the name in one select statment?
> What do i need to use? can i use decode or case?
> Sagi
>|||I'm trying to do this like that:
SELECT request_id REQUEST_ID, parameter6 NO__OF_DAYS, parameter13 TEAM
FROM KCRT_REQUEST_DETAILS
WHERE request_type_id=30132
and (SUBSTR(replace(CONCAT(parameter13, '#@.#'), '#@.#' , ' in
([p.MULTI].TO_STRING) or '), 1, length(replace(CONCAT(parameter13, '#@.#'),
'#@.#' , ' in ([p.MULTI].TO_STRING) or '))-4) )
p.MULTI resolve to ('jhon', 'Yos', 'Rami')
the string in parameter13 is something like Jhon#@.#Yos#@.#Rami and changing.
i was thinking to add #@.# to the end of the string, replace the #@.# with the
string ' in ([p.MULTI]) or ' and then cut the 4 last letters from the end
and get (after the system will resolve the [p.MULTI] token) this:
and ('Jhon' in ('Jhon', 'Yos', 'Rami') or 'Yos' in ('Jhon', 'Yos', 'Rami')
and that will be great but the [p.MULTI] token include ' so it make it
wrong.
any help in here?
Sagi
"Uri Dimant" <urid@.iscar.co.il> wrote in message
news:OqTIZNPPGHA.812@.TK2MSFTNGP10.phx.gbl...
> Here is an example form Anith
> --Modify it for your needs
> SELECT IDENTITY(INT) "n" INTO Numbers
> FROM sysobjects s1
> CROSS JOIN sysobjects s2
> GO
> DECLARE @.Ids VARCHAR(200)
> SET @.Ids = '5,33,229,1,22'
> SELECT SUBSTRING(@.Ids, n, CHARINDEX(',', @.Ids + ',', n) - n)
> from numbers where substring(','+@.Ids,n,1)=','
> AND n < LEN(@.Ids) + 1
> drop table Numbers
>
>
> "sagi aviram" <crisrobin@.013.net.il> wrote in message
> news:440530d7$1@.news.barak.net.il...
>
Monday, February 20, 2012
MS-SQL Related
What is uniqueidentifier as a data type?
Also what is the data type for setting unique STRINGS ((nchar,
nvarchar), for example to be used for emails and user names in a user
registration system).
SQL Server does not allow me set primary keys for columns where data
types are not INT.
Thanks in advance.A uniqueidentifier is equivelent to a GUID, if you've ever used it in
any other programming language. As for SQL Server not allowing you to
use other data types than int, you must be misinterpreting the errror
message. What error message do you see?
Dot Net Daddy wrote:
Quote:
Originally Posted by
Hello,
>
What is uniqueidentifier as a data type?
>
Also what is the data type for setting unique STRINGS ((nchar,
nvarchar), for example to be used for emails and user names in a user
registration system).
>
SQL Server does not allow me set primary keys for columns where data
types are not INT.
>
Thanks in advance.
Quote:
Originally Posted by
What is uniqueidentifier as a data type?
A uniqueidentifier is a 128-bit value, which is generated in such a way
that it is guaranteed to be unique in the whole universe. (Well, at least
this planet.) They are not specific to SQL Server, but Windows has them
all over the place, but calls them GUIDs.
Quote:
Originally Posted by
Also what is the data type for setting unique STRINGS ((nchar,
nvarchar), for example to be used for emails and user names in a user
registration system).
>
SQL Server does not allow me set primary keys for columns where data
types are not INT.
Huh? You can use almost any data type for primary keys. Since a primary
key is an index, the total key size may not execeed 900 bytes, so you
cannot use things like text or nvarchar(MAX).
--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||Great. It has done it. I was using nvarchar(MAX) as you told.
Now it is ok.
Thank you very much for your help guys.
Erland Sommarskog wrote:
Quote:
Originally Posted by
Dot Net Daddy (cagriandac@.gmail.com) writes:
Quote:
Originally Posted by
What is uniqueidentifier as a data type?
>
A uniqueidentifier is a 128-bit value, which is generated in such a way
that it is guaranteed to be unique in the whole universe. (Well, at least
this planet.) They are not specific to SQL Server, but Windows has them
all over the place, but calls them GUIDs.
>
Quote:
Originally Posted by
Also what is the data type for setting unique STRINGS ((nchar,
nvarchar), for example to be used for emails and user names in a user
registration system).
SQL Server does not allow me set primary keys for columns where data
types are not INT.
>
Huh? You can use almost any data type for primary keys. Since a primary
key is an index, the total key size may not execeed 900 bytes, so you
cannot use things like text or nvarchar(MAX).
>
>
--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
>
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx