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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 inserting a letter every x places
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

pelegk2
Aged Yak Warrior

Israel
723 Posts

Posted - 11/27/2006 :  03:10:29  Show Profile  Visit pelegk2's Homepage  Send pelegk2 an ICQ Message  Reply with Quote
i make a query and i want on a certain col say called col1
to insert every x letter my own string for example :
col1
--------
dog
cat

afeter inset :
dAAAog
cAAAat
how can i do this?
thnaks in advance
peleg

Israel -the best place to live in aftr heaven 9but no one wan't to go there so fast -:)

SwePeso
Patron Saint of Lost Yaks

Sweden
30281 Posts

Posted - 11/27/2006 :  03:16:10  Show Profile  Visit SwePeso's Homepage  Reply with Quote
Use STUFF function

SELECT STUFF('dog', 2, 0, 'AAA'), STUFF('cat', 2, 0, 'AAA')


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

pelegk2
Aged Yak Warrior

Israel
723 Posts

Posted - 11/27/2006 :  03:22:42  Show Profile  Visit pelegk2's Homepage  Send pelegk2 an ICQ Message  Reply with Quote
thnaks alot
is there a way making it happen more thne once on a string likeL:
abracadabra ===>> abAAraAAcaAAdaAAbrAAa


Israel -the best place to live in aftr heaven 9but no one wan't to go there so fast -:)
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
30281 Posts

Posted - 11/27/2006 :  03:37:32  Show Profile  Visit SwePeso's Homepage  Reply with Quote
declare @s varchar(1000), @r varchar(1000)

select	@s = 'abracadabra',
	@r = ''

select	@r = @r + q.g
from	(
		select	substring(@s, 1 + 2 * number, 2) + CASE WHEN number < len(@s) / 2 THEN 'AA' ELSE '' END g
		from	master..spt_values
		where	name is null
			and number between 0 and len(@s) / 2
	) q

select	@r


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

pelegk2
Aged Yak Warrior

Israel
723 Posts

Posted - 11/27/2006 :  03:39:25  Show Profile  Visit pelegk2's Homepage  Send pelegk2 an ICQ Message  Reply with Quote
ok thnaks laot

Israel -the best place to live in aftr heaven 9but no one wan't to go there so fast -:)
Go to Top of Page

madhivanan
Premature Yak Congratulator

India
22769 Posts

Posted - 11/27/2006 :  07:46:02  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
quote:
Originally posted by pelegk2

thnaks alot
is there a way making it happen more thne once on a string likeL:
abracadabra ===>> abAAraAAcaAAdaAAbrAAa


Israel -the best place to live in aftr heaven 9but no one wan't to go there so fast -:)

Why do you need this?

Madhivanan

Failing to plan is Planning to fail
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.14 seconds. Powered By: Snitz Forums 2000