Author |
Topic |
arkiboys
Master Smack Fu Yak Hacker
1433 Posts |
Posted - 2008-01-08 : 10:27:55
|
hi,I receive a string into a stored procedure with machinename/domain/loginHow do I get the login out of the above string please?Thanks |
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2008-01-08 : 10:33:44
|
checkout PARSENAME in Books Online.Be One with the OptimizerTG |
|
|
arkiboys
Master Smack Fu Yak Hacker
1433 Posts |
Posted - 2008-01-08 : 10:39:37
|
I have tried it but it seems the parse name only works with . and not /Any other way?Thanks |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2008-01-08 : 10:45:48
|
wow, all the parsing routines out there and we picked the same one Be One with the OptimizerTG |
|
|
arkiboys
Master Smack Fu Yak Hacker
1433 Posts |
Posted - 2008-01-08 : 10:46:30
|
quote: Originally posted by arkiboys I have tried it but it seems the parse name only works with . and not /Any other way?Thanks
Solved.Thanks |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-01-08 : 10:49:14
|
quote: Originally posted by TG wow, all the parsing routines out there and we picked the same one Be One with the OptimizerTG
I have the most efficient one bookmarked KH[spoiler]Time is always against us[/spoiler] |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2008-01-08 : 11:20:21
|
What am I missing? I was actually looking at this function we both referenced and I noticed:CREATE FUNCTION dbo.fnParseString( ... @Text TEXT)RETURNS VARCHAR(8000)ASBEGIN .... IF @Section > 0 SELECT @Text = REVERSE(@Text) I thought you couldn't set a TEXT datatype value using t-sql. And sure enough, I get that error when I try to compile the function in 2000. and in 2005 I get:"Argument data type text is invalid for argument 1 of reverse function."I was going to reply to the function thread but I'm sure it's me...what is my problem?Be One with the OptimizerTG |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-01-08 : 18:40:28
|
quote: I was going to reply to the function thread but I'm sure it's me...what is my problem?
Oh, i changed to varchar(max) in my environment, prefer not to work in text KH[spoiler]Time is always against us[/spoiler] |
|
|
saurabh122
Starting Member
16 Posts |
Posted - 2008-01-09 : 00:27:21
|
See whether the following code helps:-----declare @data varchar(1000)declare @login varchar(100)set @data = 'domain/machine/login'set @login = substring(@data,(charindex('/',@data,(charindex('/',@data,1)+1))+1),(len(@data)-charindex('/',@data,(charindex('/',@data,1)+1))))print @login |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-01-09 : 01:49:24
|
quote: Originally posted by saurabh122 See whether the following code helps:-----declare @data varchar(1000)declare @login varchar(100)set @data = 'domain/machine/login'set @login = substring(@data,(charindex('/',@data,(charindex('/',@data,1)+1))+1),(len(@data)-charindex('/',@data,(charindex('/',@data,1)+1))))print @login
ordeclare @data varchar(1000)declare @login varchar(100)set @data = 'domain/machine/login'set @login=right(@data,charindex('/',reverse(@data))-1)print @loginMadhivananFailing to plan is Planning to fail |
|
|
|