Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old November 2nd, 2006, 01:11 PM
-Wing- -Wing- is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2006
Posts: 1 -Wing- User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 m 50 sec
Reputation Power: 0
Stored Procedure with String Manipulation

I am somewhat new to the world of programming with SQL Server and was wondering if this could be done. Well I know it can be done but was wondering how it might be done.

I have a DTS package created to import a table from and AS400 server. What I need to do is take one field and parse that field into 5 different values for 5 new fields.

Here is what I know needs to be done but not sure how to put into the procedure.

Code:
CREATE proc ChangeHIS

as
	--Declare Variables
	Declare @LastName varchar,
		@FirstName varchar,
		@MI varchar,
		@ID varchar,
		@Dept varchar,
		@intCount int,
		@UserName varchar,
		@strTemp varchar

--Create Temporary Table

CREATE TABLE [EmployeeAudit].[dbo].[tmpTable] (
[UPUPRF] varchar (10), 
[UPTEXT] varchar (50)
)

select [UPUPRF], [UPTEXT] from tblHIS into tmpTable

GO


Code:
@tmpString = RTRIM(LTRIM(@tmpString))

If charindex(@tmpString, ",") > 0 
	--'Manuel, Michael J - 78672 - SR MIS SUPPORT SPEC'    
	@LastName = Left(@tmpString, charindex(@tmpString, ","))
	@tmpString = RTRIM(LTRIM(Right(@tmpString, Len(@tmpString) - charindex(@tmpString, ",") + 1)))
	--'Michael J - 78672 - SR MIS SUPPORT SPEC'
	@FirstName = Left(@tmpString, charindex(@tmpString, " "))
	@tmpString = RTRIM(LTRIM(Right(@tmpString, Len(@tmpString) - charindex(@tmpString, " ") + 1)))
	If charindex(@tmpString, "-") > 1 
		--'J - 78672 - SR MIS SUPPORT SPEC'
		@MI = Left(@tmpString, 1)
		@tmpSting = RTRIM(LTRIM(Right(@tmpString, Len(@tmpString) - 2)
	End
	--'- 78672 - SR MIS SUPPORT SPEC'
	@ID = Left(@tmpString, charindex(@tmpString, " - "))
	@tmpString = RTRIM(LTRIM(Right(@tmpString, Len(@tmpString) - charindex(@tmpString, " - ") + 3)))
	--'SR MIS SUPPORT SPEC'
	@Dept = @tmpString
End


Hope someone can point me in the right direction

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft SQL Server > Stored Procedure with String Manipulation


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT