Пример #1
0
		public void TestScript() {
			var f = new Routine("dbo", "udf_GetDate", null) {
				RoutineType = Routine.RoutineKind.Function,
				Text = ExampleFunc
			};
			Console.WriteLine(f.ScriptCreate());
			TestHelper.ExecBatchSql(f.ScriptCreate() + "\nGO", "");
			TestHelper.ExecSql("drop function [dbo].[udf_GetDate]", "");
		}
Пример #2
0
 public void TestScript()
 {
     var f = new Routine("dbo", "udf_GetDate");
     f.Text = @"
     CREATE FUNCTION [dbo].[udf_GetDate]()
     RETURNS DATETIME AS
     BEGIN
     RETURN GETDATE()
     END
     ";
     Console.WriteLine(f.ScriptCreate(null));
     TestHelper.ExecBatchSql(f.ScriptCreate(null) + "\nGO", "");
     TestHelper.ExecSql("drop function [dbo].[udf_GetDate]", "");
 }
Пример #3
0
		public void TestScript() {
			var t = new Table("dbo", "Address");
			t.Columns.Add(new Column("id", "int", false, null));
			t.Columns.Add(new Column("street", "varchar", 50, false, null));
			t.Columns.Add(new Column("city", "varchar", 50, false, null));
			t.Columns.Add(new Column("state", "char", 2, false, null));
			t.Columns.Add(new Column("zip", "char", 5, false, null));
			t.Constraints.Add(new Constraint("PK_Address", "PRIMARY KEY", "id"));

			var getAddress = new Routine("dbo", "GetAddress", null);
			getAddress.Text = @"
CREATE PROCEDURE [dbo].[GetAddress]
	@id int
AS
	select * from Address where id = @id
";

			TestHelper.ExecSql(t.ScriptCreate(), "");
			TestHelper.ExecBatchSql(getAddress.ScriptCreate() + "\nGO", "");

			TestHelper.ExecSql("drop table [dbo].[Address]", "");
			TestHelper.ExecSql("drop procedure [dbo].[GetAddress]", "");
		}