dbTalk Databases Forums  

Length of a varbinary type.

comp.databases.sybase comp.databases.sybase


Discuss Length of a varbinary type. in the comp.databases.sybase forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Matt Tyler
 
Posts: n/a

Default Length of a varbinary type. - 07-27-2004 , 03:21 AM






Hi,

I have been tasked with updating some stored procedures that take a
varbinary type as input.

In order to reject invalid input I need to calculate the length in
bytes of a varbinary type (I also need to take account of any trailing
zeros).

I have searched this group and the web for a T-SQL method to perform
the above but have drawn a blank so far. Does anyone have any ideas.

Thanks

Matt

Reply With Quote
  #2  
Old   
Rob Verschoor
 
Posts: n/a

Default Re: Length of a varbinary type. - 07-27-2004 , 04:24 AM






Use the 'datalength()' function:

create proc p
@b varbinary(10)
as
select datalength(@b)


HTH,

Rob
-------------------------------------------------------------
Rob Verschoor

Certified Sybase Professional DBA for ASE 12.5/12.0/11.5/11.0
and Replication Server 12.5

Author of various Sybase books. New book (coming soon): "The
Complete Sybase Replication Server Quick Reference Guide"
Online orders accepted at http://www.sypron.nl/shop

mailto:rob (AT) YOUR (DOT) SPAM.sypron.nl.NOT.FOR.ME
http://www.sypron.nl
Sypron B.V., P.O.Box 10695, 2501HR Den Haag, The Netherlands
-------------------------------------------------------------

"Matt Tyler" <matthew.tyler (AT) reuters (DOT) com> wrote

Quote:
Hi,

I have been tasked with updating some stored procedures that take a
varbinary type as input.

In order to reject invalid input I need to calculate the length in
bytes of a varbinary type (I also need to take account of any trailing
zeros).

I have searched this group and the web for a T-SQL method to perform
the above but have drawn a blank so far. Does anyone have any ideas.

Thanks

Matt



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.