Wednesday, March 28, 2012

Running VB Function in SQL?

Hello,

I have a VB Function that I'd like to run in SQL Server. Is that possible?

Thanks!Jozef (SPAM_O_NATOR@.telus.net) writes:
> I have a VB Function that I'd like to run in SQL Server. Is that
> possible?

In SQL 2000, only with quite some pain. If you make into an OLE object
you can.

In SQL 2005 you can implement stored procedures and functions in any
..Net languages. (Not VB6.)

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Tell us what the function does. Maybe it is possible to do the same in
Transact SQL.

--
David Portas
SQL Server MVP
--|||Hi David,

The function cycles through a string and modifies it, formatting characters
after a space or special character. I also have other functions that do
some encryption decryption and things like that.

Thanks!

"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message
news:AKednbQ1A_L3xinfRVn-tg@.giganews.com...
> Tell us what the function does. Maybe it is possible to do the same in
> Transact SQL.
> --
> David Portas
> SQL Server MVP
> --|||Jozef (SPAM_O_NATOR@.telus.net) writes:
> The function cycles through a string and modifies it, formatting
> characters after a space or special character. I also have other
> functions that do some encryption decryption and things like that.

Look up Functions/String funtiosn in the T-SQL reference. Admittedly,
string manipulation is not what T-SQL is best at, but there are some
possibilities.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||You can drive yourself nuts doing string manipulation in SQL; you are
far better off leaving string maniupulation to the business object or
presentation layer, rather than trying to bubble up from the bottom.
If you are looking to update your data, you can do that as well on a
higher level, rather than attempting to gnosh the data from below.

If you want to do this for an academic exercise, look at the CHARINDEX
and PATINDEX functions. And then drink heavily.

Stu|||Stu (stuart.ainsworth@.gmail.com) writes:
> You can drive yourself nuts doing string manipulation in SQL; you are
> far better off leaving string maniupulation to the business object or
> presentation layer, rather than trying to bubble up from the bottom.

Depends on what you want to do. Some things are easy to do in T-SQL. But
admittedly it easily becomes cluttered and complex, and some stuff is
about impossible.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Formatting of results is best done client-side. However, if you want to
manipulate and store strings in the database then it maybe worthwhile
re-writing your functions in TSQL. Take a look at the range of string
functions in SQL Server Books Online.

..NET and the MS CryptoAPI should provide all the crypto functions you will
need. Although it can make sense to put encryption in the database, doing it
in the client or middle tier will serve most applications just as well or
even better.

--
David Portas
SQL Server MVP
--|||I agree; I wish SQL had a RegEx function to easily search for patterns
and split it into smaller pieces. We have to maintain a syslog
database for our clients, and it would be nice if I could chop that up
into usable chunks on the fly, rather than through an import process.
But, c'est la vie.

Stu|||Stu (stuart.ainsworth@.gmail.com) writes:
> I agree; I wish SQL had a RegEx function to easily search for patterns
> and split it into smaller pieces. We have to maintain a syslog
> database for our clients, and it would be nice if I could chop that up
> into usable chunks on the fly, rather than through an import process.

Well in SQL2005 you can use the RegEx class in the CLR.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.aspsql

No comments:

Post a Comment