Abstraction of table variable declaration

Ask a Question related to Microsoft SQL / MS SQL Server, Design and Development.

  1. #1

    Default Abstraction of table variable declaration

    Hi all,

    I'm trying to simplify the maintenance of my stored procedures using SQL
    Server 2000's table variables.

    Currently each sp returns multiple result sets (1 to 4) that were using
    a large SELECT statement (with multiple table joins) to query the same
    subset of data in different ways.

    I've managed to abstract the creation of the data subset by using a
    table valued udf and I intend to use this in the sp's to simplify the
    SELECT statements. My problem is I can't work out how to abstract the
    creating of the table variable itself.

    Ideally I'd like to do something like:

    CREATE PROCEDURE dbo.usp_TheSPName AS
    DECLARE @WorkingTable TABLE (dbo.udf_CreateTable())
    INSERT INTO @WorkingTable SELECT * FROM dbo.FillTable()

    -- run SELECTS here...

    This would mean I could maintain the structure and contents of the data
    subset in two places rather than 500+!

    Any ideas (I'm not dead set on using udf's either..)?
    Thanks
    SiWhite

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    SiWhite Guest

  2. Similar Questions and Discussions

    1. Insert ASP variable into SQL table
      Hi, I have a variable called 'pSKU' (without quotes) that holds the SKU of a product. When someone visits a product page, I would like it to...
    2. One line variable declaration with multiple conditions
      Howdy list. I'm trying to one lineify this: my $guts = $firstchoice || ''; if(!$guts && $use_second_choice_if_first_is_empty) { $guts =...
    3. Looking for Abstraction Plugin
      I saw a plugin that took an image and textured it with a modern art lighting affect. Sort of fuzzed the shapes and added color to them. I can't...
    4. dbx Database abstraction layer
      Martin Lucas-Smith <mvl22@cam.ac.uk> wrote in message news:<Pine.SOL.4.44.0308291546440.17650-100000@green.csi.cam.ac.uk>... According to tests...
    5. Global Variable declaration
      For some reason this wont compile, it says that i need to declare the variable before using it on prepareMovie global sm204
  3. #2

    Default Re: Abstraction of table variable declaration

    Thanks for the advice Jacco.
    My profiling would have picked up the performance hit but you've saved
    me some pointless work.



    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    SiWhite Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139