Unix Technical Forum

format data before being inserted into a column

This is a discussion on format data before being inserted into a column within the SQL Server Data Warehousing forums, part of the Microsoft SQL Server category; --> I am trying to manipulate data before it is inserted into a column. For instance I am reading in ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server Data Warehousing

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-27-2008, 06:22 PM
=?Utf-8?B?ZGVoZWluejE=?=
 
Posts: n/a
Default format data before being inserted into a column

I am trying to manipulate data before it is inserted into a column. For
instance
I am reading in a MAC addreess which looks like '00DE0B16AA99' and when I
do an insert into the column I want it to be '00E:0B:16:AA:99' In other
words I am trying to insert the semicolons. I thought I was on to something
with the sp_bindrule but have not had sucess with it yet. I am pretty sure
that you can set up some sort of formattting on a column maybe when creating
the table but have not figured it out. Any help is appreciated.

Thanks in Advance

Dave
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-27-2008, 06:22 PM
MPS
 
Posts: n/a
Default Re: format data before being inserted into a column

Probably you can create a User Defined Function (named MyFunction, that
takes a string as parameter and generates a string as result) in that SQL
database, in order to convert the string from

00DE0B16AA99
to
00E:0B:16:AA:99

I think that a SQL sentence like

Insert into TABLE values (... MyFUnction('00DE0B16AA99')


and MyFUnction should be like:

CREATE FUNCTION dbo.MyFunction (@MAC varchar(12))
RETURNS varchar(17)
AS
BEGIN
declare @NEWMAC varchar(17)
....
....your conversion code here
....
return (@NEWMAC)
END

Hope it helps

Michael Prendergast

"deheinz1" <deheinz1@discussions.microsoft.com> escribió en el mensaje
news:8F622015-658D-4C83-8F85-6B4797FB78AE@microsoft.com...
>I am trying to manipulate data before it is inserted into a column. For
> instance
> I am reading in a MAC addreess which looks like '00DE0B16AA99' and when I
> do an insert into the column I want it to be '00E:0B:16:AA:99' In other
> words I am trying to insert the semicolons. I thought I was on to
> something
> with the sp_bindrule but have not had sucess with it yet. I am pretty
> sure
> that you can set up some sort of formattting on a column maybe when
> creating
> the table but have not figured it out. Any help is appreciated.
>
> Thanks in Advance
>
> Dave
>




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 12:54 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com