I would like to know the performance issues associated with running managed code through SQL Server 2008. I've heard about some memory and speed issues.
Specifically, I want to implement a SHA256 hashing DLL and execute it as a sproc with SQL Server 2008.
Alternately, I could simply execute the hashing from my .Net app, then pass the string to my sprocs.
Pros/cons?
Thanks.
SQLCLR is quite fast. Use it if you have a clear need to execute CLR code within T-SQL. For example, say you write a SQLCLR function with the signature:
SqlString Hash(SqlString input)
and you manage to get it all running the way it should. You could execute the following query:
IF EXISTS(SELECT * FROM Users WHERE HashedPassword = dbo.Hash(@userPassword) AND UserName = @userName)
BEGIN
SELECT 'You''re alright, Jack.';
END
ELSE
BEGIN
SELECT 'Bogus.';
END
If you can manage to hash the hypothetical password field in your app, you are better off to do so within the app and pass the hashed value into SQL Server to run a query like this:
SELECT *
FROM User
WHERE UserName = @userName AND HashedPassword = @hashedPassword
This is better for a few reasons: