Tuesday, February 14, 2012

data transformation

I have data that is listed in a number of formats (nvchar).
It needs to look like 000000-00-0 or N/A
It looks like any combination
999999999
99-99-9
9999 99 9
and similar
And ideas?
If you are talking about formatting the number for display, that is often
left to the front end...
However you can create a UDF which accepts the value as input, formats it
and returns it as output...
If I were writing such a function I would probably check the input for
hyphens, spaces or neither and format accordingly..
In the Books On Line, start by searching for and reading about all of the
string functions in SQL...
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"bhoweaz" <bhoweaz@.discussions.microsoft.com> wrote in message
news:2BA9CE10-B0B7-4EB5-A0CA-53C5A82CF070@.microsoft.com...
> I have data that is listed in a number of formats (nvchar).
> It needs to look like 000000-00-0 or N/A
> It looks like any combination
> 999999999
> 99-99-9
> 9999 99 9
> and similar
> And ideas?

No comments:

Post a Comment