Stock Control, Procedures


I have a table like this:

thing, size, color, type_mov, vary
1, s, red, sell, 1
1, s, red, buy, 2
1, m, green, return, 10

and the question is how I can see the total number of products by size
and color having in mind that some type of movement are + and other
are -.

in other words, like stock control.

how I can control this in sql server?
code, procedures?


View Replies


Moved Stock Minus In Item Table To Stock In Itemmoment Table

 helo all...,i want to make procedure like:examplei have table: item (itemid,itemname,stock)orderdetail(no_order,itemid,quantity)itemmoment(itemid,itemname,stock)item table itemid    itemname    stock  c1        coconut         2  p1         peanut          2orderdetail tableno_order        itemid        quantity   1                  c1                5itemmoment tableitemid    itemname    stock  c1       coconut          0  p1       peanut            0 when customer paid, his quantity in orderdetail decrease stock in item stock in item table became:itemid        itemname    stock  c1            coconut         -3  p1            peanut           2it's not good, because stock may not i want to move -3 to itemmoment stock in item table became:itemid        itemname    stock  c1            coconut          0  p1            peanut           2and in itemmoment table became:itemid        itemname    stock  c1             coconut        3  p1             peanut          0my store procedure like:ALTER PROCEDURE [dbo].[orders](    @no_order as integer,    @itemid AS varchar(50),    @quantity AS INT)ASBEGIN    BEGIN TRANSACTION            DECLARE @currentStock AS INT                SET @currentStock = (SELECT [Stok] FROM [item] WHERE [itemid] = @itemid)        UPDATE [item]        SET            [Stock] = @currentStock - @quantity        WHERE            [itemid] = @itemid    COMMIT TRANSACTIONENDit's only decrease stock with quantity. i want move stock minus from item to itemmoment..can anyone add code to my store procedure?plss.. helpp.thxx....

View Replies View Related

Stored Procedures And Source Control

We have a large team working on applications to support our internal sales and our public dotcom site.  In the process, as you can imagine, we generate a lot of stored procedures and sql scripts going to our dba's for our staging,qa and production environments- but we don't have a solid way to manage it yet.  Some people use Source Safe?  Does anyone have any successes in this area or recomendations?Thanks!s!Stephen Rylander

View Replies View Related

Stored Procedures Under Version Control

Is there a way to put stored procedures under version control using SourceSafe with SQL Server 7? I do not wish to use Visual InterDev with this.

View Replies View Related

Control Access To SQL Server 2005 Database Only Through Stored Procedures Issue


I have a database (SQL 2005) with two schemas (dbo and s1) and with tables defined in dbo and tables defined in s1. The stored procedures are also defined in both schemas, some of them in dbo some of them in s1. Some of the stored procedures query tables from dbo and s1 at the same time.
I want to have a new db role with access to the database only through sps and no other access read/write to the tables. I created a new db role and granted execute permission to it and assigned a user to it.
When I execute stored procedure defined in dbo with query against dbo tables, it works as expected.
However, if I run stored procedure defined in s1 with query to table in dbo, I receive error about missing select permission for the table in dbo. I am not sure why, but I can assume there is an issue with the ownership chain.
I can grand read/write permission for the tables, but this will break our original requirement for limited access to the db only through sp.
The other option is to have another role r2, with read/write, privilege and to use EXECUTE AS r2 in the sp.

I would like to ask first why the error for missing select permission happens and is there another way to have role restricted to only execute permission for all stored procedures.


View Replies View Related

Stock Inventory Diagram

Hi all, i don't know where to post these, and so i posted in here about sql stuff... I want to do a stock inventory for my restaurant, and i don't know how to start building the database, so, I want to ask if anyone knows if they have a database diagram for stock inventory... any kind of database diagram will helps, so I get and Idea how to start... thanks... 

View Replies View Related

Complex Stock Query

Well probably not that complex for some of you out there!

I need to work out the amount of stock which was sold between @datefrom and @dateto and how much we currently have on hand (to work out if we are over ordering etc). That's the pretty easy part but I also need to include a column which works out how many items have been sold 3 months prior to @datefrom (from invoiceline). The proc I have so far works out the items sold between 2 dates so basically what I need is another column which is the amount sold (QtySold) in the 3 months prior to datefrom

This is the basic part I have so far:

ALTER PROCEDURE [dbo].[rptstockholdinglevel]
-- Add the parameters for the stored procedure here
@datefrom datetime,
@dateto datetime,
@periodname varchar(50),
@percentage int
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.

-- Insert statements for procedure here
@periodname AS periodname,
isnull(SUM(invoiceline.qty),0) AS QtySold,
products.qtyonhand AS OnHand,
productmanufacturers RIGHT OUTER JOIN
invoices INNER JOIN
invoiceline ON invoices.invoiceid = invoiceline.invoiceid RIGHT OUTER JOIN
products ON invoiceline.productid = products.productid ON productmanufacturers.manufacturerid = products.manufacturerid LEFT OUTER JOIN
nominals INNER JOIN
productcategories ON nominals.nominalid = productcategories.salesnominal ON products.categoryid = productcategories.productcategoryid
(invoices.invoicedate BETWEEN @datefrom AND @dateto)
(invoices.invoicedate is null)
HAVING (SUM(isnull(invoiceline.qty,0)) < products.qtyonhand)

I'd be really grateful for any pointers as I'm just going round in circles on this one.

Thanks in advance as usual all :)


View Replies View Related

Make Procedure For Stock-quantity

 helo alll...,this is my data:my table is item(productid,stock) ,order(customerid,no_order), and orderdetail (no_order,productid,quantity) example: order and orderdetail displayed in gridview....order is displayed like this:                 customerid            no_orderdetail                  A                        1detail                  B                        2  when i click detail in row 2, it's display orderdetail:no_order               productid              quantity       2                            c1                       2  2                            p1                       3 i have make all this is ok. but i want to decrease stok in item with quantity in code in procedure like:CREATE PROCEDURE [dbo].[order_item](@productid AS varchar,@quantity AS INT)ASBEGINBEGIN TRANSACTIONDECLARE @no_order AS INTDECLARE @stock AS INTINSERT INTO [Orderdetail]([ProductId],[Quantity])VALUES(@productId,@quantity)SET @no_order = SCOPE_IDENTITY()SET @Stock = (SELECT [Stock] FROM [item] WHERE [ProductId] = @productId)UPDATE [item]SET[Stock] = @Stock - @quantityWHERE[ProductId] = @productIdCOMMIT TRANSACTIONENDreturn it can't about his true code in store procedure?ok..., thx.. 

View Replies View Related

Inventory Stock, Triggers Vs Views/SP


I am designing a Database Application that covers Inventory System. And I am now in a dilemma of chosing which design to track Inventory stock better, in performance, reliability, and error free?

1st Design

..and other unique info of the product..






Tracking Inventory stock is done by using (update, insert and delete) triggers in each of the DETAILS to update the QtyOnHand in the PRODUCT TABLE

2nd Design






The later design does not hold QtyOnHand, but only save QtyBegin instead. To get the QtyOnHand, it uses views/stored procedure with Union Query, so it looks like this:

QtyOnHand = QtyBegin + Sum(QtySold) + Sum(QtyPurchase) + Sum(QtySalesReturn) + ........

And at the end of a accounting period, the calculation of the QtyOnHand will be the QtyBegin of the next accounting period.

According to you guys, which way is better in PERFORMANCE, RELIABILITY, ERROR FREE, and why? What are the pros and cons of these two?

Thanks a lot.

View Replies View Related

Changing Timeframes With Stock Data

I have stock data in 1 min intervals and would like to convert it into other timeframes (e.g., 10 min, daily, monthly).

Here's is some sample data and my final goal:

[DateTime] [Open] [High] [Low] [Close] [Volume]
10-Feb-05 12:10:00 3.88 3.88 3.87 3.87 10
10-Feb-05 12:11:00 3.87 3.87 3.87 3.87 2
10-Feb-05 12:12:00 3.86 3.86 3.86 3.86 1
10-Feb-05 12:13:00 3.85 3.87 3.84 3.85 23
10-Feb-05 12:14:00 3.85 3.85 3.85 3.85 6
10-Feb-05 12:15:00 3.86 3.86 3.86 3.86 1
10-Feb-05 12:16:00 3.85 3.85 3.85 3.85 1
10-Feb-05 12:18:00 3.85 3.85 3.85 3.85 3
10-Feb-05 12:19:00 3.85 3.85 3.85 3.85 3

[DateTime] [Open] [High] [Low] [Close] [Volume]
10-Feb-05 12:10:00 3.88 3.88 3.84 3.85 50 *


View Replies View Related

Conditional Predictions On Stock Prices?

I would like to use analysis services to analyze stock prices.

I want to find conditional probabilities:
P (YpriceChg >= 10% s.t. Ydate between A and B| X Price Chg >= 20%)?

Like given a price change of X percent or greater, predict the probability of a price change of Y percent or greater, within a specified time window (like 2 days, 3 months etc.).

I also want to add a support filter, like:

N > 30 cases (i.e., there have been at least 10 instances of a 10% or greater price change, for the chosen time window)

I have a database of prices, monthly, daily, etc. I also have a number of cols that compute statistics such as pChg1M, pChg-1M, vChg1d. Like price chg 1 month forward, price change 1 month backward, volumeChg1d forward. Ideally, I would like to minimize the column flags necessary for the experiment. Can you offer some hints, as far as setting up appropriate columns/flags and choosing a algorithm (maybe decision trees, association rules, or NB)?

View Replies View Related

The Logic Of Sample Notification Service(Stock)

 hi allin the sample of sqlserver2005(notification service(stock))this is code sample in :appADF.xml(stock) -------------------------- --       Update value in the chronicle if event price greater than value in the chronicle                        UPDATE    StockEventsChron                        SET        StockPrice = E.StockPrice                        FROM    StockEvents E, StockEventsChron C                        WHERE    E.StockSymbol = C.StockSymbol AND E.StockPrice &gt; C.StockPrice.for scenario: +  the first SubscriberId(Stephanie)  set :StockTriggerValue=20, and stockPrice changge =50  -> one notification for Stephanie and in the table StockEventsChron the value field :StockPrice = 50,  + the next :  stockPrice changge  = 25. the field value StockPrice  of table StockEventsChron is still 50 +  then second  SubscriberId(Scott) set StockTriggerValue=30 but---------------- Insert Into StockNotifications    (    S.SubscriberId,                        S.DeviceName,                        S.SubscriberLocale,                        E.StockSymbol,                        E.StockPrice                        )                        SELECT                                S.SubscriberId,                        S.DeviceName,                        S.SubscriberLocale,                        E.StockSymbol,                        E.StockPrice                        FROM   StockSubscriptions S JOIN StockEvents E                        ON   S.StockSymbol = E.StockSymbol                        LEFT OUTER JOIN StockEventsChron c                        ON   S.StockSymbol = c.StockSymbol                        WHERE  S.StockTriggerValue &lt;= E.StockPrice                        AND    (S.StockTriggerValue &gt; c.StockPrice OR c.StockPrice IS NULL)   here :StockTriggerValue=30 &lt; c.StockPrice=50 so no notification for Scott,  why ?can anyone help me?   

View Replies View Related

Urgent Stock Options/org Chart Query

Okay, here's an algorithm question for you TSQL gurus out there...

Due to circumstances beyond our control, our group has been tasked with a massive project and a very short timeline. And of course, timely completion is needed because our STOCK OPTIONS grants depend on this! And of course board meetings are always scheduled sooner than you expect.

Here's one of the killer questions we're trying to solve...

Given a table of employee ID's, associated supervisor ID's, and the amount of stock options given, how would you write a stored procedure to return, for any branch of the organizational tree, the sum of all the stock options in a particular branch?


1 2 100
2 30 500
3 2 150
30 50 1000
50 60 5000

What we need is something like : "sp_StockOptionsPerDepartment @SUPERVISORID=30"
with a result : "1750".

Basically we're building an organizational chart of our company from this table, on the fly, and also counting up for certain branches of the org chart, the total stock options.

If a manager has two managers under him, and each sub-manager has three employees, then we want to know the total stock options that all 3+3+2+1 = 9 people possess. Basically it's the total pool of stock options for a department, or work group, or division, etc.

Got this to work for a small set of employees, but when we begin to scale up to entire departments, the query times out because it takes tooooo long...

Any ideas? ANY ideas at ALL would be helpful...

(1) This is basically a tree-traversal algorithm, but conversion into SQL is not always so straightforward. Starting from an arbitrary root node, we must visit every child node underneath, walking all the way down to the leaves.

(2) We tried a brute force algorithm which is fast for smaller sets, but impossibly long for sets where we're dealing with hundreds of employees. Any cheats? Caching results as we go? Any ideas out there?


View Replies View Related

What's Differences In CLSID, PROGID, Stock Moniker And Creation Name?

Dear Experts,

when I define a component with IDTSComponentMetaData90 , must choose the type of component, for example DerivedColumn.

I can individualize it with:

Stock Moniker
Creation Name

Can you give me a definition of these identifications? 

what differences are there in these identifications?


thanks a lot




View Replies View Related

SSRS :Generate Live Data Report (Example Stock)


I have requirement to cache report server as soon as data get refreshed in datbase.My database get refreshed every 10 minutes.
I am working in stock and bond domain were data changes very frequently.My user want to see almost live data whenever accessing report in report manager.they also want to cache some data for better performance.Can any one tell me step's to improve performance of reporting services .
Kindly suggest me.

Monika Singh

View Replies View Related

Shopping Cart, How Do I Subtract The Quantity Purchased From The Stock In Database?

Im making a shopping cart website for a school project in with VB. I need help subtracting the quantity purchased (its saved in a session) from the stock number saved in a database.I know this:UPDATE inventory SET stock = stock - <quantity_purchased> WHERE id = <inventory_id>But I dont understand how to get the quantity purchased from the session to <quantity_purchased>. I tried putting the name of the session there and I got an error, i tried saving the session into a dim didnt work either.
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [stock] FROM [product]" InsertCommand="INSERT INTO [product] ([stock]) VALUES (@stock)" UpdateCommand="UPDATE product SET stock = (stock - @Quantity) WHERE (productID = @productID)">
<asp:Parameter Name="stock" Type="Int16" />
<asp:SessionParameter Name="Quantity" SessionField="Quantity" Type="Int32" />
<asp:SessionParameter Name="productID" SessionField="productID" Type="Int32" />
 and I have than in my VB code on submit : SqlDataSource1.Update()

View Replies View Related

Issue With SSRS Report Exporting To Excel With The Matrix Control Inside The Table Control

Hi All,
I am placing a Matrix inside the table control for grouping requirements,but when we export the report to the Excel, the contents inside the table cell are ignored. Is there any way to get the full report exported, as per the Requirement.Please help me with this issue.

With Thanks

View Replies View Related

An Error Has Occurred Because A Control With Id 'ctl162$ctl00$ctl03$ctl01' Could Not Be Located Or A Different Control Is Assign


I am getting the above error while running the report in the production server. I didn't got this error when I ran teh report in the report in test and UAT environment. Please anyone can help me on this issue.

Also when I am trying to run the report for the first time I can view the report, but again when I am trying to re-open the same reprot I am getting the above error. Please let me know.


View Replies View Related

Is It Possible To Embbed And Ocx Control On A Report Or Some Sort Of Interactive Control Like A Flash.ocx?

does any one have and example of how to embedd a flash swf file onto a report.??? Is it possable? any examples would be helpful.

View Replies View Related

Item Master And Office Stock Details (was &"Query Problem&")


I am having problem in getting result out of two table, one table is Item Mater which stores global items for all offices and other is stock file which stores office wise stock items as follows:

1 A
2 B
3 C
4 D
5 E

1 1 1
2 2 1
3 3 1
4 1 2
5 2 2
6 4 2
7 5 3

I want office wise stock details which inludes items found in stock file and remaining itmes from item master. example for office 1

1 A 1
2 B 1
3 C 1

i want a single view from which i can select data like i shown above, any kind of help is highly appriciated, what i tried is , i created union of both tables and tried to get data out of union view but result is not up to desire.

Thanks in advance

View Replies View Related

Developing Custom Components By Extending The SSIS Stock Data Flow Components

Everything I've read says that custom data flow components are built by inheriting from the Microsoft.SqlServer.Dts.Pipeline.PipelineComponent class.

But the stock components such as the Derived Column data flow transformation must each be implemented by their own class. So how do I base my custom components on those classes? The documentation for the PipelineComponent class doesn't list any such subclasses.

View Replies View Related

Convert Tick-by-tick Stock Price Time Series Data Grouped As High, Low, Open And Close Prices

I am working on a stock price analysis project. Stock prices are stored in SQL Server as tick by tick data (that means in a high frequency) and need to be grouped by minutes in order to display them as as high, low, open and close prices in a candlestick or similar chart.

The fields in the table are:

Time (for every stock price tick)
Price (stock price)
Symbol (of the stock)

A sample time series would look like this:

11:45:01 $22.11 MSFT
11:45:02 $22.10 MSFT
11:45:04 $22.25 MSFT
11:45:58 $22.45 MSFT
11:46:03 $22.22 MSFT
11:46:08 $22.25 MSFT
11:46:59 $22.45 MSFT

The result of the SQL query should be:

Symbol Time Open High Low Close
MSFT 11:45 $22.11 $22.45 $22.10 $22.45
MSFT 11:46 $22.22 $22.45 $22.22 $22.45

This is the SQL statement I came up with but obviously doesn't work:

SELECT DATEPART(Minute,Time), MIN(Price), MAX(Price) FROM dbo.TimeSales WHERE Symbol='MSFT' GROUP BY DATEPART(Minute,Time)

I would appreciate any suggestions.

Thank you!

View Replies View Related

Reporting Services From WebBrowser Control - Print = &&"unable To Load Client Print Control&&"

UPDATE #2: When it said "Do you want to install Microsoft SQL Server" I said "yes" and that caused it to work. I exited and re-ran and now the print runs w/o the "install SQL Server" (If the prompt had said "Do you want to install the print dialog" we wouldn't be having this discussion...) 

UPDATE: After posting this i discovered that the same thing occurs when attempting to print the report direct from IE6: First a dialog pops up "Do you want to install this software?" Name: Microsoft SQL Server. When I click "Don't Install" I get the dialog "unable to load client print control." Since this happens direct from IE6 I suspect it's browser settings. I'll resume tomorrow and post a followup.

My WinForm C# app integrates Reporting Services by calling them from WebBrowser controls. The problem is attempts to print cause a dialog: "unable to load client print control."

I've read prior posts that say "enable Active-X in your browser" - I don't know how to do that from a WebBrowser control.

Any ideas how to support Reporting Services "Print" from within a WebBrowser control?




View Replies View Related

Question About Procedures To Create Procedures In A Different Database

I'm trying to write a procedure that having created a new database,will then create within that new database all the tables andprocedures that go with it.In doing this I'm hitting the problem that you can't issue a USEcommand within a procedure.So my question is either- how do I get around this?- if I can't, how can I create procedures etc in a *different*(i.e. the newly created) databaseor- is there a better way to do all this (*)I have SQL files that do this currently, but I need to edit in thename of the database each time before execution, so I thought aprocedure would be better. Also I'd like eventually to expose someof this functionality via a web interface.Although I'm a newbie, I feel I'm diving in the deep end. Any goodpointers to all the issues involved in this aspect of databasemanagement would be appreciated.(*) One thought that occurs to me is to have a "template" database,and to then somehow copy all procedures, tables, view etc from that.--HTML-to-text and markup removal with Detagger

View Replies View Related

All My Stored Procedures Are Getting Created As System Procedures!

Using SQL 2005, SP2. All of a sudden, whenever I create any stored procedures in the master database, they get created as system stored procedures. Doesn't matter what I name them, and what they do.

For example, even this simple little guy:





Gets created as a system stored procedure.

Any ideas what would cause that and/or how to fix it?


View Replies View Related

Oracle Stored Procedures VERSUS SQL Server Stored Procedures

I want to know the differences between SQL Server 2000 storedprocedures and oracle stored procedures? Do they have differentsyntax? The concept should be the same that the stored proceduresexecute in the database server with better performance?Please advise good references for Oracle stored procedures also.thanks!!

View Replies View Related

OLE DB Source Task In The Second Control Flow Data Task Fails After The Same Task Succeeds In The First Control Flow Data Task

I am trying to run a SSIS package as an agent job.

The package has several control flow data tasks. Each of the control flow data tasks uses a OLEDB source task to connect to the same SQL 2005 database(defined by a single connection manager) using SQL server authentication and basically pulls some data.

The first control flow data task succeeds, but the second one fails and so he package errors out.

My question is why would the second OLEDB task be failing when it uses the same connection manager as the frist one?

Here are some facts
1) the package runs fine in BIDS from my development wkstation.
2) the package uses an XML configuration file which specifies the sql server password and connectionstring
3) the package runs on a 64 bit sql server box with SP1.
4) the job is running under sql agent service account.
5) I created the package as well as the agent job.
6) the ole db source is a sql 2005 server.
7) the error message generated by the second task(oledb source) is
"The AcquireConnection method call to the connection manager "Source" failed with error code 0xC0202009."

I have read about some issues running SQL authenticated ssis packages running under job agent but i wonder if this is related.


View Replies View Related

Stored Procedures 2005 Vs Stored Procedures 2000


This Might be a really simple thing, however we have just installed SQL server 2005 on a new server, and are having difficulties with the set up of the Store Procedures. Every time we try to modify an existing stored procedure it attempts to save it as an SQL file, unlike in 2000 where it saved it as part of the database itself.

Thank you in advance for any help on this matter

View Replies View Related

Job Control(T-SQL)

MS-SQL7 is failing on T-SQL set-up of scheduled job.
-It works when I go into Enterprise Manager, edit the job(change nothing),
and click OK.

Here's the T-SQL Script:
USE msdb
EXEC sp_add_job @job_name = 'Daily', @enabled = 1
EXEC sp_add_jobstep @job_name = 'Daily', @step_name = 'Run the Daily reports',
@subsystem = 'CMDEXEC', @cmdexec_success_code = 1,
@command = 'G:
EXEC sp_add_jobschedule @job_name = 'Daily',
@name = 'Scheduled Daily',
@freq_type = 4, -- daily
@freq_interval = 1,
@active_start_time = 142600

View Replies View Related

T-SQL Control Of DTS


I want to be able to alter the filename that my DTS package imports programmactically with a T-SQL stored procedure.

Is this possible, I really dont want to write a VB/COM package just to do this!


View Replies View Related

Copyrights 2005-15, All rights reserved