C# 应用程序中的 SQL 查询
我需要创建以下查询
CREATE TABLE [dbo].[soft] (
[img_pk] [int] IDENTITY (1, 1) NOT NULL ,
[name] [varchar] (50) NULL ,
[img_data] [image] NULL ,
[img_contenttype] [varchar] (50) NULL,
[file_data] [image] NULL ,
[file_contenttype] [varchar] (50) NULL
)
ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
ALTER TABLE [dbo].[soft] WITH NOCHECK ADD
CONSTRAINT [PK_image] PRIMARY KEY NONCLUSTERED
(
[img_pk]
) ON [PRIMARY]
GO
第一部分没有问题,它的解决方式类似于
string query1 = "CREATE TABLE soft" +
"(pk int IDENTITY (1, 1) NOT NULL," +
"name VARCHAR(50) NULL, img_data IMAGE NULL, img_contenttype VARCHAR(50) NULL, file_data IMAGE NULL, file_contenttype VARCHAR(50) NULL)"
但不知道如何使用下一部分。谁能帮助我吗?
I need to create the following query
CREATE TABLE [dbo].[soft] (
[img_pk] [int] IDENTITY (1, 1) NOT NULL ,
[name] [varchar] (50) NULL ,
[img_data] [image] NULL ,
[img_contenttype] [varchar] (50) NULL,
[file_data] [image] NULL ,
[file_contenttype] [varchar] (50) NULL
)
ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
ALTER TABLE [dbo].[soft] WITH NOCHECK ADD
CONSTRAINT [PK_image] PRIMARY KEY NONCLUSTERED
(
[img_pk]
) ON [PRIMARY]
GO
No problem with the first part, it's solved like
string query1 = "CREATE TABLE soft" +
"(pk int IDENTITY (1, 1) NOT NULL," +
"name VARCHAR(50) NULL, img_data IMAGE NULL, img_contenttype VARCHAR(50) NULL, file_data IMAGE NULL, file_contenttype VARCHAR(50) NULL)"
But no ideas how to work with the next part. Can anyone help me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以组合表和主键定义:
如果这是您的默认文件组,则可以省去额外的“ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]”,这在许多(大多数?)情况下也是如此
此外,我已将 PK 创建为集群,这对于自动增量列来说更常见。
另外:
You can combine the table and primary key definitions:
You can dispense with the extra 'ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] ' if that's your default FileGroup, which it is in many (most?) cases
Also, I have created the PK as Clustered, which is more usual for an auto-inc column.
Also:
您的意思是只是将查询加载到字符串中?您可以使用 @"" 多行字符串语法:(
顺便说一句,“ON PRIMARY .. GO”是第一个查询的一部分。)
要执行此操作,您将像往常一样使用类似的内容
。
You mean just load the query into a string? You can use the @"" multi-line string syntax:
(The 'ON PRIMARY .. GO' is part of the first query, by the way.)
To execute this you'd use something like
as usual.
使用单行查询时遇到任何问题吗?
Any problems you face when you use single line queries ??