· 8 years ago · Jul 26, 2018, 12:28 PM
1Dynamically Create SQL in C# from file
2public void createDatabase(string dbName)
3 {
4 connectionString = string.Format("DataSource="{0}"; Password='{1}'", dbName, password);
5 SqlCeEngine en = new SqlCeEngine(connectionString);
6 en.CreateDatabase();
7 }
8
9if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Tb_Transactions]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
10drop table [dbo].[Tb_Transactions]
11GO
12
13CREATE TABLE [dbo].[TB_Transactions] (
14 [Supp_ID] [int] NOT NULL ,
15 [Prod_ID] [int] NOT NULL ,
16 [Price] [money] NULL ,
17 [Quantity] [float] NULL
18) ON [PRIMARY]
19GO