在主机上创建一个包含一个表的数据库 [英] Create a database with one table on the host

查看:74
本文介绍了在主机上创建一个包含一个表的数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在主机上创建一个带有一个表的数据库。


我不能用SQL Server Management Studio这样做,所以我想我必须这样做/>
它以编程方式。


我记得在会话开始时(或者应用程序启动会更好)b $ b更好)我'' d检查数据库是否存在,如果没有创建它。


问题是我不知道该怎么做。


你能否指出一些文件可能会显示一个如何做到的例子?

谢谢

解决方案

什么是 ;主持人?

AAaron123" < aa ******* @ roadrunner.com写信息

新闻:OG ************** @ TK2MSFTNGP04.phx.gbl ...


>我想创建一个主机上有一个表的数据库。


我不能用SQL服务器管理工​​作室这样做,所以我想我必须以编程方式执行




我记得在会话开始时(或者可能是应用程序启动)将

更好)我会检查数据库是否存在,如果没有创建它。


问题是我不知道如何要做到这一点。


你能指出一些文件可能会展示一个如何做的例子吗?


谢谢





" sloan" < sl *** @ ipass.netwrote in message

news:%2 **************** @ TK2MSFTNGP05.phx.gbl ...


什么是主持人?


" AAaron123" < aa ******* @ roadrunner.com写信息

新闻:OG ************** @ TK2MSFTNGP04.phx.gbl ...


>>我想在主机上创建一个包含一个表的数据库。

我无法使用SQL Server管理工作室,所以我想我必须以编程方式进行。

我记得在会话开始(或者应用程序开始
会更好)我'检查一下,数据库是否存在,如果没有,请创建它。

问题是我不知道该怎么做。

你能不能指向文档可能会显示如何操作
那个?

谢谢




如果您在开发工作站上安装了SSMS,则可以执行以下操作:

在测试SQL Server上创建数据库。

在测试中创建表SQL Server

使用SSMS编写数据库脚本(创建选项)

脚本使用SSMS的表(创建选项)


首先使用ADO.NET创建数据库,然后再创建

表。您还必须ATTACH新创建的数据库。另请注意,脚本创建的
会有很多GO'。你将不得不在GO之间执行

每组命令,因为SQL Server不知道GO $ / $
是什么。


您可能还需要设置权限并确保

数据库文件的位置有效且可由SQL Server访问。


希望这有助于

LS


Laneware free

" sloan" < sl *** @ ipass.netwrote in message

news:%2 **************** @ TK2MSFTNGP05.phx.gbl ...


什么是主持人?


" AAaron123" < aa ******* @ roadrunner.com写信息

新闻:OG ************** @ TK2MSFTNGP04.phx.gbl ...


>>我想在主机上创建一个包含一个表的数据库。

我无法使用SQL Server管理工作室,所以我想我必须以编程方式进行。

我记得在会话开始(或者应用程序开始
会更好)我'检查一下,数据库是否存在,如果没有,请创建它。

问题是我不知道该怎么做。

你能不能指向文档可能会显示一个如何做的示例
$

谢谢




I want to create a database with one table on the host.

I can''t user SQL Server Management Studio to do it so I guess I have to do
it programmatically.

I have in mind that in the session start (or maybe application start would
be better) I''d check to see it the database exists and if not create it.

The problem is that I have no idea how to do that.

Can you point to documentation of maybe show an example of how to do that?
Thanks

解决方案

What is "The Host"?
"AAaron123" <aa*******@roadrunner.comwrote in message
news:OG**************@TK2MSFTNGP04.phx.gbl...

>I want to create a database with one table on the host.

I can''t user SQL Server Management Studio to do it so I guess I have to do
it programmatically.

I have in mind that in the session start (or maybe application start would
be better) I''d check to see it the database exists and if not create it.

The problem is that I have no idea how to do that.

Can you point to documentation of maybe show an example of how to do that?
Thanks




"sloan" <sl***@ipass.netwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...

What is "The Host"?
"AAaron123" <aa*******@roadrunner.comwrote in message
news:OG**************@TK2MSFTNGP04.phx.gbl...

>>I want to create a database with one table on the host.

I can''t user SQL Server Management Studio to do it so I guess I have to
do it programmatically.

I have in mind that in the session start (or maybe application start
would be better) I''d check to see it the database exists and if not
create it.

The problem is that I have no idea how to do that.

Can you point to documentation of maybe show an example of how to do
that?
Thanks


If you have SSMS on your development workstation you can do the following:

Create your database on your test SQL Server.
Create your table on your test SQL Server
Script the database using SSMS (create option)
Script the table using SSMS (create option)

Use those scripts thru ADO.NET to create the database first and then the
table. You will also have to ATTACH the newly created database. Also note
that the script created will have lots of GO''s. You will have to execute
each set of commands between the GO''s as SQL Server does not know what GO
is.

You might also have to set permissions and ensure that the location of the
database file is valid and accessable by SQL Server.

Hope this helps
LS


Laneware free
"sloan" <sl***@ipass.netwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...

What is "The Host"?
"AAaron123" <aa*******@roadrunner.comwrote in message
news:OG**************@TK2MSFTNGP04.phx.gbl...

>>I want to create a database with one table on the host.

I can''t user SQL Server Management Studio to do it so I guess I have to
do it programmatically.

I have in mind that in the session start (or maybe application start
would be better) I''d check to see it the database exists and if not
create it.

The problem is that I have no idea how to do that.

Can you point to documentation of maybe show an example of how to do
that?
Thanks




这篇关于在主机上创建一个包含一个表的数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆