Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / General / Data Warehousing / March 2005

Tip: Looking for answers? Try searching our database.

format data before being inserted into a column

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
deheinz1 - 23 Mar 2005 22:55 GMT
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 '00:DE: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
MPS - 23 Mar 2005 23:10 GMT
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
00:DE: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

>I am trying to manipulate data before it is inserted into a column.  For
> instance
[quoted text clipped - 11 lines]
>
> Dave
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.