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 2000 Forums
 Transact-SQL (2000)
 Issue in String manipulation

Author  Topic 

sqllearner
Aged Yak Warrior

639 Posts

Posted - 2006-11-02 : 16:57:13
[code]

DECLARE @sys_value VARCHAR(200)
SET @sys_value= '1;45;56;657;67;67;78'

DECLARE @create_user_id INT
SET @create_user_id = 56
SET @sys_value = REPLACE(@sys_value,';',',')
PRINT @sys_value

IF CONVERT(varchar,@create_user_id) IN (@sys_value)
BEGIN
RETURN 1
END
ELSE
RETURN 0

[/code]

Iam trying to return 1 or 0 based on the if condition.Though @create_user_id is available in the @sys_value its not giving the correct return value.Please help me with the query.

sqllearner
Aged Yak Warrior

639 Posts

Posted - 2006-11-02 : 17:31:00
Please help me with this query
Go to Top of Page

jhocutt
Constraint Violating Yak Guru

385 Posts

Posted - 2006-11-02 : 18:02:18
DECLARE @sys_value VARCHAR(200)
SET @sys_value= '1;45;56;657;67;67;78'

DECLARE @create_user_id INT
SET @create_user_id = 56

IF @sys_value like '%;'+cast(@create_user_id as varchar)+';%'
BEGIN
RETURN 1
END
ELSE
RETURN 0


"God does not play dice" -- Albert Einstein
"Not only does God play dice, but he sometimes throws them where they cannot be seen."
-- Stephen Hawking
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-11-02 : 20:19:57
Search for Where @mycsv in this topic for more details

http://sqlteam.com/forums/topic.asp?TOPIC_ID=55210

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -