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
 SQL Server 2012 Forums
 Transact-SQL (2012)
 assembly with [SqlUserDefinedType]

Author  Topic 

NoamGr
Starting Member

12 Posts

Posted - 2014-12-08 : 02:43:45
namespace BooksMgr
{

[Serializable]
[SqlUserDefinedType(
Format.UserDefined,
IsByteOrdered = true,
ValidationMethodName = "Validation",
MaxByteSize = -1
)]
public struct TicketNum : INullable, IBinarySerialize
{
private SqlInt16 _Xnum;
private bool is_Null;

public TicketNum(SqlInt16 v)
{
_Xnum = v;

if (v.IsNull == true)
is_Null = true;
else
is_Null = false;

}
// ----------------------

public SqlInt16 Xnum
{
get { return _Xnum; }
set { _Xnum = value; }
}
// -----------------------

private bool Validation()
{
if ( _Xnum > 0 )
{
return true;
}
else
{
return false;
}
}
// -----------------------

public bool IsNull
{
get { return is_Null; }
}
// -----------------------

public static TicketNum Null
{
get
{
TicketNum pt = new TicketNum();
pt.is_Null = true;

return pt;
}
}
// -----------------------

public override string ToString()
{
if (this.IsNull)
{
return "NULL";
}
else
{
StringBuilder b = new StringBuilder();
b.Append(_Xnum);

return b.ToString();
}
}
// -----------------------

public static TicketNum Parse(SqlString s)
{

if (s.IsNull)
return Null;

TicketNum pt = new TicketNum();

pt.Xnum = Convert.ToInt16(s);

if (!pt.Validation())
throw new ArgumentException("Invalid value.");

return pt;
}
// -----------------

public void Write(System.IO.BinaryWriter w)
{

}
// -----------------------

public void Read(System.IO.BinaryReader r)
{

}
// -----------------------


}
// ---------------------


declare @p1 MyInt
set @p1 = ????

how to assign a value ?




Muj9
Yak Posting Veteran

75 Posts

Posted - 2014-12-08 : 10:58:00
declare @p1 Int
set @p1 = Yourvalue
Go to Top of Page

NoamGr
Starting Member

12 Posts

Posted - 2014-12-08 : 11:09:54
sorry, you miss the subject. read again
Go to Top of Page
   

- Advertisement -