cerate view for sql205

  • I tell you my problem in one line

    tell me can we give multiple search queary to one table and display output in one table or report or any other platform.

    other wise can we display multiple views in crystal report. because i know for the tables.multiple tables can display in crystal report but for view i use that code but it display blank report.

    if this is possible then my problem is solved.

    if you have any idea please tell me...

  • I keep asking you for a little information but you don't provide and you keep comming back with questions.

    Are you pulling my leg?:w00t:

    http://www.sqlservercentral.com/articles/Best+Practices/61537

    For better, quicker answers on T-SQL questions, click on the following...
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • I don't want to make u confuse. I was trying to solve the problem in any other ways. I was just thinking for another solutions. I dont know how to explain the problem. and which information i should post. I have given u all information about my table and data.

    sorry...:blush:

  • prashantcomp90 (5/20/2011)


    I dont know how to explain the problem. and which information i should post. I have given u all information about my table and data.

    ok, could we do this one step at a time.

    Script out your table(s), that is easy. If you do you not know how to do this let me know but hopefully you can find that out on your own

    Write a script to populate your table(s) with data.

    Post this and we will go from there.

    For better, quicker answers on T-SQL questions, click on the following...
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • This is the queary to populate data from table.

    SELECT l1.grpnm AS Assets, SUM(l1.deb) AS [Debit A], SUM(l1.crd) AS [Credit A], l2.grpnm AS Liability, SUM(l2.deb) AS [Debit L], SUM(l2.crd) AS [Credit L]

    FROM dbo.ledger AS l1 INNER JOIN

    dbo.ledger AS l2 ON l1.grpnm = l2.grpnm

    WHERE (l1.supgrp IN ('Assets', ' Liability'))

    GROUP BY l1.grpnm, l2.grpnm

  • prashantcomp90 (5/20/2011)


    This is the queary to populate data from table.

    SELECT l1.grpnm AS Assets, SUM(l1.deb) AS [Debit A], SUM(l1.crd) AS [Credit A], l2.grpnm AS Liability, SUM(l2.deb) AS [Debit L], SUM(l2.crd) AS [Credit L]

    FROM dbo.ledger AS l1 INNER JOIN

    dbo.ledger AS l2 ON l1.grpnm = l2.grpnm

    WHERE (l1.supgrp IN ('Assets', ' Liability'))

    GROUP BY l1.grpnm, l2.grpnm

    No, start out by scripting your table.

    I need the DDL.

    For better, quicker answers on T-SQL questions, click on the following...
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • do u mean the table details like feilds name in the table. that was i have posted yesterday.

    what is DDL i realy dont know.

  • prashantcomp90 (5/20/2011)


    do u mean the table details like feilds name in the table. that was i have posted yesterday.

    what is DDL i realy dont know.

    In SSMS, select the table, right click and select Script Table as >> Create to>> New Query Window>> Copy & Paste into your post.

    Now we have your Data Definination Language which is a description of your table that we can use to help you.

    For better, quicker answers on T-SQL questions, click on the following...
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • USE [bank]

    GO

    /****** Object: Table [dbo].[ledger] Script Date: 05/21/2011 01:41:25 ******/

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    SET ANSI_PADDING ON

    GO

    CREATE TABLE [dbo].[ledger](

    [vec] [numeric](25, 0) IDENTITY(1,1) NOT NULL,

    [id] [varchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,

    [grpnm] [varchar](800) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,

    [supgrp] [varchar](500) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,

    [payby] [varchar](500) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,

    [accnm] [varchar](500) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,

    [date] [varchar](500) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,

    [deb] [numeric](35, 0) NULL,

    [crd] [numeric](35, 0) NULL,

    CONSTRAINT [PK_ledger] PRIMARY KEY CLUSTERED

    (

    [vec] 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 ANSI_PADDING OFF

  • prashantcomp90 (5/20/2011)


    USE [bank]

    GO

    /****** Object: Table [dbo].[ledger] Script Date: 05/21/2011 01:41:25 ******/

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    SET ANSI_PADDING ON

    GO

    CREATE TABLE [dbo].[ledger](

    [vec] [numeric](25, 0) IDENTITY(1,1) NOT NULL,

    [id] [varchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,

    [grpnm] [varchar](800) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,

    [supgrp] [varchar](500) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,

    [payby] [varchar](500) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,

    [accnm] [varchar](500) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,

    [date] [varchar](500) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,

    [deb] [numeric](35, 0) NULL,

    [crd] [numeric](35, 0) NULL,

    CONSTRAINT [PK_ledger] PRIMARY KEY CLUSTERED

    (

    [vec] 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 ANSI_PADDING OFF

    Great the next step is to create a prodcure to load the data into the table.

    Hint create another DB and execute your commands to load the table.

    For better, quicker answers on T-SQL questions, click on the following...
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • do u mean now i have to create stored procedure.

  • Perhaps I was not clear on what you need to do but you need to create a script to load your test data into the table that you defined.

    For better, quicker answers on T-SQL questions, click on the following...
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • One god news,

    my problem is solved. how I tell u.

    after so long discussion between us. I thought that if we can combine multiple tables in sql and create view. then i create multiple views and then combine them in one view. and it display the final output as I want. Thank you so much.

    thanks for your support and reply.

    I hope if i have other problems then also u will help me to solve them.

    thanks.....

  • prashantcomp90 (5/22/2011)


    I thought that if we can combine multiple tables in sql and create view. then i create multiple views and then combine them in one view. and it display the final output as I want.

    Why do you need to create multiple views and then combine them?;-)

    Can you reveal your solution?

    For better, quicker answers on T-SQL questions, click on the following...
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • prashantcomp90 (5/22/2011)


    One god news,

    my problem is solved. how I tell u.

    after so long discussion between us. I thought that if we can combine multiple tables in sql and create view. then i create multiple views and then combine them in one view. and it display the final output as I want. Thank you so much.

    thanks for your support and reply.

    I hope if i have other problems then also u will help me to solve them.

    thanks.....

    This is probably not a good idea - as views of views are generally performance killers. Not necessarily with how you used them in this particular case, but in the future someone will use one or more of your views in ways that were not intended.

    Jeffrey Williams
    “We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs

Viewing 15 posts - 31 through 45 (of 52 total)

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