/*
UpdateUnitPriceProductTrigger.sql creates a trigger
that fires after an UPDATE statement is performed on the
the UnitPrice column of the Products table.
If the reduction of the unit price of a product is
greater than 25% then a row is added to the ProductAudit table
to audit the change.
*/
CREATE TRIGGER UpdateUnitPriceProductTrigger
ON Products
AFTER UPDATE
AS
-- don't return the number of rows affected
SET NOCOUNT ON
-- only run the code if the UnitPrice column
-- was modified
IF UPDATE(UnitPrice)
BEGIN
-- declare an int variable to store the
-- ProductID
DECLARE @MyProductID int
-- declare two money variables to store the
-- old unit price and the new unit price
DECLARE @OldUnitPrice money
DECLARE @NewUnitPrice money
-- declare a float variable to store the price
-- reduction percentage
DECLARE @PriceReductionPercentage float
-- get the ProductID of the row that
-- was modified from the inserted table
SELECT @MyProductID = ProductID
FROM inserted
-- get the old unit price from the deleted table
SELECT @OldUnitPrice = UnitPrice
FROM deleted
WHERE ProductID = @MyProductID
-- get the new unit price from the inserted table
SELECT @NewUnitPrice = UnitPrice
FROM inserted
-- calculate the price reduction percentage
SET @PriceReductionPercentage =
((@OldUnitPrice - @NewUnitPrice) / @OldUnitPrice) * 100
-- if the price reduction percentage is greater than 25%
-- then audit the change by adding a row to the PriceAudit table
IF (@PriceReductionPercentage > 25)
BEGIN
-- add a row to the ProductAudit table
INSERT INTO ProductAudit (
Action
) VALUES (
'UnitPrice of ProductID #' +
CONVERT(nvarchar, @MyProductID) +
' was reduced by ' +
CONVERT(nvarchar, @PriceReductionPercentage) +
'%'
)
END
END
没有合适的资源?快使用搜索试试~ 我知道了~
C#数据库编程源代码_
共226个文件
cs:82个
sql:27个
pdb:14个
5星 · 超过95%的资源 需积分: 10 14 下载量 155 浏览量
2008-12-07
00:03:07
上传
评论
收藏 482KB RAR 举报
温馨提示
C#数据库编程源代码,有具体的连接数据库的c#源代码,适合写代码的人做为参考也作为学习的参考。
资源推荐
资源详情
资源评论
收起资源包目录
C#数据库编程源代码_ (226个子文件)
WebForm1.aspx 2KB
CookieTest.aspx 1KB
ApplicationObjectTest.aspx 952B
SessionObjectTest.aspx 934B
ViewStateTest.aspx 879B
MyDataSet.cs 25KB
DataSet1.cs 25KB
Form1.cs 18KB
WebForm1.aspx.cs 18KB
DataSet1.cs 15KB
MyDataSet.cs 15KB
ModifyingRelatedData2.cs 13KB
ModifyingRelatedData.cs 13KB
UsingEvents.cs 12KB
HandlingUpdateFailures.cs 11KB
Form1.cs 11KB
UsingIdentityColumn.cs 10KB
AddModifyAndRemoveDataRows.cs 9KB
PushChangesUsingProcedures.cs 9KB
Form1.cs 9KB
Form1.cs 8KB
UsingCommandBuilder.cs 7KB
AddRestrictions.cs 5KB
TransactionIsolation.cs 5KB
CreateDataRelation.cs 4KB
Deadlock.cs 4KB
AddModifyAndRemoveDataRowViews.cs 4KB
Block.cs 4KB
UsingXmlDataDocument.cs 4KB
FindFilterAndSortDataRows.cs 4KB
Form1.cs 4KB
StronglyTypedColumnValues.cs 3KB
AddConstraints.cs 3KB
Form1.cs 3KB
Form1.cs 3KB
Savepoint.cs 3KB
FillSchema.cs 3KB
SelectIntoDataSet.cs 3KB
UsingXmlDocument.cs 3KB
ExecuteAddProduct3.cs 3KB
ExecuteInsertUpdateDelete.cs 3KB
FirstExample.cs 2KB
AssemblyInfo.cs 2KB
AssemblyInfo.cs 2KB
AssemblyInfo.cs 2KB
AssemblyInfo.cs 2KB
AssemblyInfo.cs 2KB
AssemblyInfo.cs 2KB
AssemblyInfo.cs 2KB
WriteAndReadXML.cs 2KB
FindingDataRowViews.cs 2KB
CreateChildDataView.cs 2KB
OleDbConnectionAccess.cs 2KB
ExecuteAddProduct.cs 2KB
ExecuteAddProduct2.cs 2KB
NestedXml.cs 2KB
StronglyTypedColumnValuesSql.cs 2KB
Merge.cs 2KB
ExecuteDDL.cs 2KB
PopulateDataSetUsingSelect.cs 2KB
OleDbConnectionOracle.cs 2KB
UsingColumnOrdinals.cs 2KB
ExecuteTransaction.cs 2KB
ExecuteSelect.cs 2KB
MultipleDataTables3.cs 2KB
UsingDataViewManager.cs 2KB
Mappings.cs 2KB
MultipleDataTables2.cs 2KB
MultipleDataTables.cs 2KB
ExecuteMultipleSQL.cs 2KB
UsingDefaultSort.cs 2KB
MySqlConnection.cs 2KB
UsingDataView2.cs 2KB
PopulateDataSetUsingRange.cs 2KB
UsingDataView.cs 2KB
ExecuteMultipleSelects.cs 2KB
SchemaOnlyCommandBehavior.cs 2KB
ExecuteTableDirect.cs 2KB
UsingParameters.cs 2KB
ConnectionPooling.cs 1KB
PopulateDataSetUsingProcedure.cs 1KB
SingleRowCommandBehavior.cs 1KB
InfoMessage.cs 1KB
ExecuteXmlReader.cs 1KB
StateChange.cs 1KB
ExecuteScalar.cs 861B
CustomersWebService.cs 707B
WindowsApplication4.csproj 5KB
WindowsApplication4.csproj 5KB
WindowsApplication4.csproj 4KB
DataView.csproj 4KB
WindowsApplication4.csproj 4KB
WindowsApplication4.csproj 4KB
WindowsApplication4.csproj 4KB
MyDataSet.cs.dll 16KB
DataSet1.cs.dll 16KB
MyDataSet.cs.dll 16KB
MyDataSet.cs.dll 16KB
MyDataSet.cs.dll 16KB
MyDataSet.cs.dll 16KB
共 226 条
- 1
- 2
- 3
资源评论
- qq_334430422015-12-27很好的资源,多谢楼主
Mifer
- 粉丝: 0
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 使用Dockerfile配置Springboot应用服务发布Docker镜像-源码
- 万维考试系统-C语言题库-含题目-程序设计题导出-113道.doc
- Alibaba SpringCloud集成Nacos、openFeign实现负载均衡-源码
- 用户研究系列之Persona介绍(用户画像)
- Image_1715110604427.jpg
- mYzh..trashed-1716951334-.jpg
- Alibaba SpringCloud集成nacos实现配置中心
- 那些好的不像话的心流体验
- 基于pytorch的卷积神经网络识别是否为奥特曼的项目python源码+文档说明+数据集(课程设计)
- 基于卷积神经网络的图像风格迁移python源码+文档说明+界面图片(课程设计)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功