任何人都可以帮助制作商店程序吗? [英] Can anyone help to make store procedures?

查看:65
本文介绍了任何人都可以帮助制作商店程序吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨伙计们



我有两张桌子



AB

dbo.Items dbo.Staff

ItemID StaffID

StaffID姓氏

物品名字

单位城市

数量公司



我在dbo.Items中取得了一个关键来从dbo获取值.Staff

我想制作一个报告与商店程序,以便每个StaffID只需要他自己的物品。

参数公司,城市,姓氏



欢迎任何帮助

Hi guys

I have two tables

A B
dbo.Items dbo.Staff
ItemID StaffID
StaffID Lastname
Itemname Firstname
Unit City
Quantity Company

I made a key in dbo.Items to take values from dbo.Staff
I want to make a report with store procedure so that every StaffID to take
only his own items.
Parameters Company,City,Lastname

Please any help is welcome

推荐答案

使用加入





Use Join
as

Create proc usp_select_items
(
@ComanyName varchar(50),
@City varchar(50),
@LastName varchar(50)
)
as
begin
select *from dbo.Staff s inner join dbo.Items i on s.StaffID=i.StaffID where s.ComapnyName=@ComapnyName and s.City=@City and s.LastName=@LastName
end


这篇关于任何人都可以帮助制作商店程序吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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