Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Binary or blob data type
Message
De
10/04/2019 01:46:17
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01668007
Message ID:
01668038
Vues:
75
J'aime (2)
>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,
----------------------------------
António Tavares Lopes
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform