SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 sting parse
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

pnpsql
Posting Yak Master

India
246 Posts

Posted - 02/07/2012 :  04:24:16  Show Profile  Reply with Quote
hi team, i have string like '111111~2222~klk' ~ sign is seprator for each item, i need to set values of each item in
variables @v1 , @v2 , @v3 , plese help

challenge everything

webfred
Flowing Fount of Yak Knowledge

Germany
8679 Posts

Posted - 02/07/2012 :  04:31:22  Show Profile  Visit webfred's Homepage  Reply with Quote
declare @v1 varchar(10)
declare @v2 varchar(10)
declare @v3 varchar(10)
declare @test varchar(255)
set @test = '111111~2222~klk'
select
@v1=parsename(replace(@test,'~','.'),3),
@v2=parsename(replace(@test,'~','.'),2),
@v3=parsename(replace(@test,'~','.'),1)

select @v1,@v2,@v3



No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

pnpsql
Posting Yak Master

India
246 Posts

Posted - 02/07/2012 :  04:45:21  Show Profile  Reply with Quote
may contain any null value then


challenge everything
Go to Top of Page

webfred
Flowing Fount of Yak Knowledge

Germany
8679 Posts

Posted - 02/07/2012 :  05:01:25  Show Profile  Visit webfred's Homepage  Reply with Quote
If you can give better examples then maybe we can give better solutions...


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

pnpsql
Posting Yak Master

India
246 Posts

Posted - 02/07/2012 :  05:02:12  Show Profile  Reply with Quote
'111111~2222~klk' IS NOW '111111~2222~'

challenge everything
Go to Top of Page

webfred
Flowing Fount of Yak Knowledge

Germany
8679 Posts

Posted - 02/07/2012 :  05:08:40  Show Profile  Visit webfred's Homepage  Reply with Quote
declare @v1 varchar(10)
declare @v2 varchar(10)
declare @v3 varchar(10)


declare @test varchar(255)
set @test = '111111~2222~'
select
@v1=replace(parsename(replace(@test,'~','.~'),3),'~',''),
@v2=replace(parsename(replace(@test,'~','.~'),2),'~',''),
@v3=replace(parsename(replace(@test,'~','.~'),1),'~','')


select @v1,@v2,@v3



No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

pnpsql
Posting Yak Master

India
246 Posts

Posted - 02/07/2012 :  05:50:46  Show Profile  Reply with Quote
gr8, now there is more than one row seprated by ^ like 'dsdsds~sdsds~fsdsd^sdsd~dsds~^dsds~hdjfhjdh~dsd' then i need to get each row how can this be possible


challenge everything
Go to Top of Page

webfred
Flowing Fount of Yak Knowledge

Germany
8679 Posts

Posted - 02/07/2012 :  06:47:52  Show Profile  Visit webfred's Homepage  Reply with Quote
What is "spoon feeding"?

Most often on the forums, "spoon feeding" refers to posters who ask questions, and refuse to put any effort or thought into their questions, as well as the answers they receive. They expect every answer to be dumbed down to the last detail, and expect that everyone else do their research for them.

This is usually a characteristic of laziness, and not capability. Hence the saying, "I'm not handicapped, I'm just lazy."


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

pnpsql
Posting Yak Master

India
246 Posts

Posted - 02/07/2012 :  09:11:34  Show Profile  Reply with Quote
HOW CAN U DEFINE THE LAZYNESS, WHEN PEOPLE HAVE NO ANSWER THEN THEY TALK LIKE THAT..

AND THE WAY THE FORUM IS ABOUT THE EXPERIENCE SHARING, AND NOT FOR RESEARCH.

challenge everything
Go to Top of Page

webfred
Flowing Fount of Yak Knowledge

Germany
8679 Posts

Posted - 02/07/2012 :  09:21:56  Show Profile  Visit webfred's Homepage  Reply with Quote
Please don't shout at me...

I am not in the mood to answer a question again and again if it will be expanded after each given answer.
Please don't be too lazy to describe your problem in a way that we don't have to guess about so many things.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

GilaMonster
Flowing Fount of Yak Knowledge

South Africa
4507 Posts

Posted - 02/07/2012 :  14:06:38  Show Profile  Visit GilaMonster's Homepage  Reply with Quote
Do bear in mind that we are all unpaid volunteers posting in our spare time. If you want a useful solution, post the full description of the problem. Adding in complications again and again works fine in a mystery novel, but not when you're asking people for free help.

--
Gail Shaw
SQL Server MVP
Go to Top of Page

madhivanan
Premature Yak Congratulator

India
22713 Posts

Posted - 02/13/2012 :  12:57:08  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
What are you going to do with splitted values? You may need something like this
http://beyondrelational.com/blogs/madhivanan/archive/2008/09/11/splitting-delimited-data-to-columns-set-based-approach.aspx

If you are passing delimited values as parameter, you may need to use a differenct approach

Madhivanan

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

X002548
Not Just a Number

15586 Posts

Posted - 02/13/2012 :  13:18:09  Show Profile  Reply with Quote
Did you design this "database"?



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.11 seconds. Powered By: Snitz Forums 2000