Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Binary or blob data type
Message
 
 
To
10/04/2019 01:46:17
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01668007
Message ID:
01668040
Views:
49
>>One more question on the varbinary column/field in the SQL Server
>>
>>If I want the default of the varbinary field to be empty but not null, would the value of 0 (zero) be the right type of default? That is, when a user retrieves the value in the varbinary field and cast it to a char type, the result is an empty string (of course if there was never a value set in the field).
>>
>>TIA
>
>Dmitry,
>
>On the SQL Server side, you should use 0x, which is the equivalent of VFP's 0h (the representation of an empty binary string).
>
>Let m.ODBC be an active connection handle to your server:
>
>
>CURSORSETPROP("MapBinary",.T.,0)
>
>LOCAL SQLStmt AS String
>
>TEXT TO m.SQLStmt NOSHOW
>DECLARE @Tmp TABLE (Col1 Int, Col2 Varbinary(10) not null default 0x);
>
>insert into @Tmp (Col1) values (1);
>insert into @Tmp (Col1, Col2) values (2, 0xffff);
>
>select * from @Tmp;
>ENDTEXT
>
>SQLEXEC(m.ODBC, m.SQLStmt, "curResult")
>
>SELECT *, LEN(Col2) FROM curResult INTO CURSOR curInspect
>
>BROWSE
>
>
>The result will be as you can see in the attached image,

Antonio,
Thank you very much!
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Reply
Map
View

Click here to load this message in the networking platform