Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 iteration through bytes of IMAGE (Why no reply !!)

Author  Topic 

Ahmad Farid
Starting Member

7 Posts

Posted - 2008-07-30 : 09:36:59
[code]CREATE FUNCTION dbo.BytesToString
(
@code Image
)
RETURNS NVARCHAR(100)

BEGIN
DECLARE @word NVARCHAR(100)
DECLARE @letter NVARCHAR(1)
DECLARE @index INT
DECLARE @pas IMAGE

SELECT @pas = @code

WHILE @index<DATALENGTH(@code)
BEGIN

SELECT @word = @word + CHAR(c)
FROM @pas
WHERE INDEX(c)=@index

SELECT @index = @index + 1
END

RETURN @word

END[/code]


Msg 137, Level 15, State 2, Procedure BytesToString, Line 20
Must declare the variable '@pas'.


I get that error that I have to declare the variable @pas which is alreay declared. Am I correct at first? Do you have any better suggestion to do that? Thank you :)

blindman
Master Smack Fu Yak Hacker

2365 Posts

Posted - 2008-07-30 : 11:21:22
Because you can't select from an Image. You can't select from any datatype. Only from Tables and Views.

e4 d5 xd5 Nf6
Go to Top of Page

Ahmad Farid
Starting Member

7 Posts

Posted - 2008-07-30 : 11:24:28
Thanks blindman. So is there any alternative solution for that?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-30 : 11:29:44
quote:
Originally posted by Ahmad Farid

Thanks blindman. So is there any alternative solution for that?


what are you trying to do inside loop?
Go to Top of Page

Ahmad Farid
Starting Member

7 Posts

Posted - 2008-07-30 : 11:33:43
I want to send an array of integers or bytes from .net C# code to a stored procedure. I want to change this array into the corresoponding string of characters through SQL. Thanks for your help :)
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-07-30 : 11:50:37
select convert(ntext, @code) ??

_______________________________________________
Causing trouble since 1980
Blog: http://weblogs.sqlteam.com/mladenp
Speed up SSMS development: www.ssmstoolspack.com <- version 1.0 out!
Go to Top of Page
   

- Advertisement -