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.
| Author |
Topic |
|
UnathiM
Starting Member
8 Posts |
Posted - 2006-07-13 : 05:21:34
|
| HiI need to create a stored procedure which take info entered by a user and splits it into four variables. e.g. I have data made up of 1024 characters and want to split that into four variables of 256 characters each. How do I go about doing this SQL? |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2006-07-13 : 05:32:05
|
| Have a look at substring and charindex - depends on the ofrmat of the string.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
Q
Yak Posting Veteran
76 Posts |
Posted - 2006-07-13 : 05:37:03
|
| You can use something like@totalLen = Len(YOURDATA)@tmpLen = 0 while @tmpLen<@totalLen dataField+[@tmpLen] = substring(YOURDATA, @tmpLen+1, 256) wendAt the moment I'm not able to test it. But it's an idea you can continue with I hope... |
 |
|
|
ditch
Master Smack Fu Yak Hacker
1466 Posts |
Posted - 2006-07-13 : 05:37:39
|
Please Excuse my Variable Names (FIFA World Cup still on my mind --Info enterd by user = variable name @VCDECLARE @LeftWing VARCHAR(256)DECLARE @InsideLeft VARCHAR(256)DECLARE @InsideRight VARCHAR(256)DECLARE @RightWing VARCHAR(256)SELECT @LeftWing = LEFT(@VC, 256), @InsideLeft = SUBSTRING(@VC, 257, 256), @InsideRight = SUBSTRING(@VC, 513, 256), @RightWing = RIGHT(@VC, 256)SELECT @LeftWing, @InsideLeft, @InsideRight, @RightWingDuane. |
 |
|
|
|
|
|
|
|