我有一个 SellerProduct 表。表格中的每一行代表卖家提供的产品信息。SellerProduct 表包含以下列:
id (serial, pk)
productName (nvarchar(50))
productDescription (ntext)
productPrice (decimal(10,2))
sellerId (int, fk to Seller table)
Run Code Online (Sandbox Code Playgroud)
不同卖家的产品可能相同,但每个卖家的 productName、productDescription 和 productPrice 可能不同。
例如,考虑产品 TI-89。卖家 A 可能拥有产品的以下信息:
productName = TI-89 Graphing Calc
productDescription = A graphing calculator that...
productPrice 65.12
Run Code Online (Sandbox Code Playgroud)
卖家 B 可能拥有以下产品信息:
productName = Texas Instrument's 89 Calculator
productDescription = Feature graphing capabilities...
productPrice 66.50
Run Code Online (Sandbox Code Playgroud)
管理员用户需要确定不同卖家的产品是相同的。
我需要一种方法来捕获这些信息(即卖家的产品是相同的)。我可以创建另一个名为 SellerProductMapper 的表,如下所示:
sellerProductId1 (int, pk, fk to SellerProdcut table)
sellerProductId2 (int, pk, fk to SellerProdcut table)
Run Code Online (Sandbox Code Playgroud)
这种方法的问题在于它允许对给定行的 SellerProductId1 和 SellerProductId2 来自同一个卖家。这不应该被允许。 …
在 SQL Server 2005 和 2008 R2 中,我调用了一个存储过程,该存储过程的 out 参数定义为varbinary(max)
. 根据 .out 参数返回 10020 字节DATALENGTH
。
但是,如果我尝试定义大于 8000 字节的 varbinary,例如 varbinary(10000),则 SQL Server 会出错。例如
The size (10000) given to the type 'varbinary' exceeds the maximum allowed for any data type (8000).
Run Code Online (Sandbox Code Playgroud)
这里发生了什么?SQL Server 如何返回超过数据类型允许的字节数?SQL Server 是否在幕后使用其他一些数据类型来保存 > 8000 字节?