在MS SQL 中可以用Stored Procedure來實現(如果是2000,還可以用UDF來實現)
Create Proc Test
@para int
AS
SELECT tblFactoryProduct.ProductPrice, tblFactoryProduct.ProductParSpecification, tblFactory.FID, tblFactory.FactoryName, tblFactory.FactoryAddress, tblFactory.FactoryZip, tblFactory.FactoryFax, tblFactory.FactoryPerson, tblFactory.FactoryTelephone, tblFactory.FactoryDNS, tblFactory.FactoryEmail
FROM tblFactory INNER JOIN tblFactoryProduct ON tblFactory.FiD=tblFactoryProduct.FactoryID
WHERE (((tblFactoryProduct.ProductID)=@para));
Create Proc Test
@para int
AS
SELECT tblFactoryProduct.ProductPrice, tblFactoryProduct.ProductParSpecification, tblFactory.FID, tblFactory.FactoryName, tblFactory.FactoryAddress, tblFactory.FactoryZip, tblFactory.FactoryFax, tblFactory.FactoryPerson, tblFactory.FactoryTelephone, tblFactory.FactoryDNS, tblFactory.FactoryEmail
FROM tblFactory INNER JOIN tblFactoryProduct ON tblFactory.FiD=tblFactoryProduct.FactoryID
WHERE (((tblFactoryProduct.ProductID)=@para));
上面的存储过程在Access可以顺利的执行。但是在Mssql里面却无法执行。所以请教
存储过程
create procedure aa
para integer --具体类型是啥
as SELECT tblFactoryProduct.ProductPrice, tblFactoryProduct.ProductParSpecification, tblFactory.FID, tblFactory.FactoryName, tblFactory.FactoryAddress, tblFactory.FactoryZip, tblFactory.FactoryFax, tblFactory.FactoryPerson, tblFactory.FactoryTelephone, tblFactory.FactoryDNS, tblFactory.FactoryEmail
FROM --tblFactory INNER JOIN tblFactoryProduct ON tblFactory.FiD=tblFactoryProduct.FactoryID
--左右连接用*实现,比如左连接就可以…… *= ……WHERE tblFactoryProduct.ProductID= @para