-2

how can I pass the parameter to view in sql server.I have a stok which contain stok info including the quantity.I have a form and via this form I added the quatitiy to the stok . what I need is get the form value of quatitiy and add the the stok quantity which is available values.for this that I need the pass parameter to the view which automatically add this value to current value in the stok, thank you all for help

sakir
  • 3,391
  • 8
  • 34
  • 50

2 Answers2

6

you can use a table function such as:

CREATE FUNCTION [dbo].[TblFunc_AAA]
(
@ID BIGINT
)
RETURNS TABLE
AS
RETURN
(
SELECT *
FROM MyTable 
where aaa = @ID
)
asafrob
  • 1,838
  • 13
  • 16
2

Actually views are only stored as SELECTs on a database, so you can't pass a parameter to it.

A stored procedure / function will fit right in. Declare one taking a parameter and only do a SELECT ... WHERE val = @paramval

CREATE PROCEDURE myproc
@in_quantity int
AS
SELECT * FROM tbl1
WHERE val = @in_quantity
GO;
makciook
  • 1,537
  • 10
  • 19