Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

tsql - Convert Varchar to Ascii -


i'm trying convert contents of varchar field unique number can referenced 3rd party.

how can convert varchar ascii string equivalent? in tsql? ascii() function converts single character can convert entire string?

i've tried using

cast(isnull(ascii(substring(rtrim(ltrim(primarycontactregion)),1,1)),'')as varchar(3)) + cast(isnull(ascii(substring(rtrim(ltrim(primarycontactregion)),2,1)),'')as varchar(3)) 

....but tedious, stupid looking, , doesn't work if had long strings. or if better how same thing in ssrs?

try this:

declare @yourstring   varchar(500)  select @yourstring='hello world!'  ;with allnumbers (     select 1 number     union     select number+1         allnumbers         number<len(@yourstring) ) select        (select             ascii(substring(@yourstring,number,1))             allnumbers             order number             xml path(''), type        ).value('.','varchar(max)') newvalue        --option (maxrecursion 500) --<<needed if have string longer 100 

output:

newvalue --------------------------------------- 72101108108111328711111410810033  (1 row(s) affected) 

just test out:

;with allnumbers (     select 1 number     union     select number+1         allnumbers         number<len(@yourstring) ) select substring(@yourstring,number,1),ascii(substring(@yourstring,number,1)),* allnumbers 

output:

                 number ---- ----------- ----------- h    72          1 e    101         2 l    108         3 l    108         4 o    111         5      32          6 w    87          7 o    111         8 r    114         9 l    108         10 d    100         11 !    33          12  (12 row(s) affected) 

also, might want use this:

right('000'+convert(varchar(max),ascii(substring(@yourstring,number,1))),3) 

to force ascii values 3 digits, i'm not sure if necessary based on usage or not.

output using 3 digits per character:

newvalue ------------------------------------- 072101108108111032087111114108100033  (1 row(s) affected) 

Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -