Query and Result

  • i need storedprocedure for bind product with head product and child

    Ex:

    productId Name Desc Price

    --------- ----- ----- ------

    0 0 Furniture 0

    1235 Wood 50x100 cm plywood need 1000

    3421 Fevicol Fevicol 100gm 25

    0 0 DOOR o

    1674 Teak Wood Purchased from vendor. 10000

    here Furniture and Wood is Head and also those have Head id that referred in Child Table.

    Ex:

    productid head_id salesId

    --------- ------ --------

    2321 3 2345

    5453 3 2345

    65445 45 2345

  • Please read second link in my signature on posting code and data for the best help.

    Please supplied DDL of all tables, procedures, indexes etc being used along with sample data.

  • GO

    /****** Object: Table [dbo].[sales] Script Date: 02/07/2013 17:20:15 ******/

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    CREATE TABLE [dbo].[sales](

    [salesid] [int] IDENTITY(1,1) NOT NULL,

    [product_id] [int] NULL,

    [Quanity] [int] NULL,

    [HeadID] [int] NULL,

    PRIMARY KEY CLUSTERED

    (

    [salesid] ASC

    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

    ) ON [PRIMARY]

    GO

    SET IDENTITY_INSERT [dbo].[sales] ON

    INSERT [dbo].[sales] ([salesid], [product_id], [Quanity], [HeadID]) VALUES (1, 3, 5, 1)

    INSERT [dbo].[sales] ([salesid], [product_id], [Quanity], [HeadID]) VALUES (2, 2, 2, 1)

    INSERT [dbo].[sales] ([salesid], [product_id], [Quanity], [HeadID]) VALUES (3, 6, 10, 5)

    INSERT [dbo].[sales] ([salesid], [product_id], [Quanity], [HeadID]) VALUES (4, 7, 12, 5)

    SET IDENTITY_INSERT [dbo].[sales] OFF

    /****** Object: Table [dbo].[Product] Script Date: 02/07/2013 17:20:15 ******/

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    SET ANSI_PADDING ON

    GO

    CREATE TABLE [dbo].[Product](

    [Cust] [varchar](25) NULL,

    [Product] [varchar](20) NULL,

    [QTY] [int] NULL

    ) ON [PRIMARY]

    GO

    SET ANSI_PADDING OFF

    GO

    INSERT [dbo].[Product] ([Cust], [Product], [QTY]) VALUES (N'KATE', N'VEG', 2)

    INSERT [dbo].[Product] ([Cust], [Product], [QTY]) VALUES (N'KATE', N'SODA', 6)

    INSERT [dbo].[Product] ([Cust], [Product], [QTY]) VALUES (N'KATE', N'MILK', 1)

    INSERT [dbo].[Product] ([Cust], [Product], [QTY]) VALUES (N'KATE', N'BEER', 12)

    INSERT [dbo].[Product] ([Cust], [Product], [QTY]) VALUES (N'FRED', N'MILK', 3)

    INSERT [dbo].[Product] ([Cust], [Product], [QTY]) VALUES (N'FRED', N'BEER', 24)

    INSERT [dbo].[Product] ([Cust], [Product], [QTY]) VALUES (N'KATE', N'VEG', 3)

  • Please post the result set that is expected from the above data.

    Vinu Vijayan

    For better and faster solutions please check..."How to post data/code on a forum to get the best help" - Jeff Moden[/url] 😉

  • pls see the attachment image and query result.

  • Your sample data doesnt match the output, we need the output to be based on your sample data, so either change the data or change the output to match.

  • anthony.green (2/7/2013)


    Your sample data doesnt match the output, we need the output to be based on your sample data, so either change the data or change the output to match.

    +1

    Vinu Vijayan

    For better and faster solutions please check..."How to post data/code on a forum to get the best help" - Jeff Moden[/url] 😉

  • Also post the definition of prc_invoice_rmdetails

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply