|
using System;
using System.Collections.Generic;
using System.Text;
namespace JocysCom.Sql.ScriptsGenerator
{
class SqlObjectsToString
{
public static bool HaveSize(Microsoft.SqlServer.Management.Smo.DataType type)
{
string name = type.SqlDataType.ToString().ToLower();
return name.Contains("char") || name.Contains("binary");
}
public static string GetDataType(Microsoft.SqlServer.Management.Smo.DataType type)
{
StringBuilder text = new StringBuilder();
text.Append(" " + type.SqlDataType.ToString());
if (SqlObjectsToString.HaveSize(type))
{
text.Append("(" +type.MaximumLength.ToString() + ")");
}
return text.ToString();
}
public static string GetParameterWithType(Microsoft.SqlServer.Management.Smo.Column column)
{
StringBuilder text = new StringBuilder();
text.Append("@" + column.Name);
text.Append(GetDataType(column.DataType));
if (column.Identity)text.Append(" OUT");
return text.ToString();
}
public static string GetParameterWithType(Microsoft.SqlServer.Management.Smo.StoredProcedureParameter parameter)
{
StringBuilder text = new StringBuilder();
text.Append(parameter.Name);
text.Append(GetDataType(parameter.DataType));
if (parameter.IsOutputParameter) text.Append(" OUT");
return text.ToString();
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.