Professional Web Applications Themes

Passing contents of a flat file to an internal variable - Microsoft SQL / MS SQL Server

I want to do something like this inside a sproc: DECLARE internalText VARCHAR(8000) SET internalText="c:\myTestXML.XML" QUESTION: Assuming the contents of myTestXML.XML is <=8000K, how do I pass the contents of that file to the variable I declared? Thanks! /Ty...

  1. #1

    Default Passing contents of a flat file to an internal variable

    I want to do something like this inside a sproc:


    DECLARE internalText VARCHAR(8000)
    SET internalText="c:\myTestXML.XML"

    QUESTION:

    Assuming the contents of myTestXML.XML is <=8000K, how do I pass the
    contents of that file to the variable I declared?

    Thanks!
    /Ty



    Ty Guest

  2. #2

    Default Re: Passing contents of a flat file to an internal variable

    You might want to look at BULK INSERT or BCP to import the file contents
    into a table first, and then process the rows.

    --
    HTH,
    Vyas, MVP (SQL Server)
    [url]http://vyaskn.tripod.com/[/url]
    What hardware is your SQL Server running on?
    [url]http://vyaskn.tripod.com/poll.htm[/url]




    "Ty" <tybala on the server at hotmail.com> wrote in message
    news:#tqZfvyPDHA.1552TK2MSFTNGP10.phx.gbl...
    I want to do something like this inside a sproc:


    DECLARE internalText VARCHAR(8000)
    SET internalText="c:\myTestXML.XML"

    QUESTION:

    Assuming the contents of myTestXML.XML is <=8000K, how do I pass the
    contents of that file to the variable I declared?

    Thanks!
    /Ty





    Narayana Vyas Kondreddi Guest

  3. #3

    Default Re: Passing contents of a flat file to an internal variable

    Ty,
    > I want to do something like this inside a sproc:
    >
    > DECLARE internalText VARCHAR(8000)
    > SET internalText="c:\myTestXML.XML"
    >
    > QUESTION:
    >
    > Assuming the contents of myTestXML.XML is <=8000K, how do I pass
    > the contents of that file to the variable I declared?
    You can use the bulk insert statement.

    create table #File (Body varchar(8000))

    bulk insert #File from c:\myTestXML.XML'
    with (fieldterminator = '', rowterminator = '\0')

    declare internalText varchar(8000)
    set internalText = (select top 1 Body from #File)
    select internalText

    drop table #File


    Linda
    lindawie Guest

  4. #4

    Default Re: Passing contents of a flat file to an internal variable

    Thanks so much for the tip. I modified it slightly and ended up with just
    what I needed. :-)

    /Ty


    "lindawie" <lindawiemy-deja.com> wrote in message
    news:#NR7OU0PDHA.3664tk2msftngp13.phx.gbl...
    > Ty,
    >
    > > I want to do something like this inside a sproc:
    > >
    > > DECLARE internalText VARCHAR(8000)
    > > SET internalText="c:\myTestXML.XML"
    > >
    > > QUESTION:
    > >
    > > Assuming the contents of myTestXML.XML is <=8000K, how do I pass
    > > the contents of that file to the variable I declared?
    >
    > You can use the bulk insert statement.
    >
    > create table #File (Body varchar(8000))
    >
    > bulk insert #File from c:\myTestXML.XML'
    > with (fieldterminator = '', rowterminator = '\0')
    >
    > declare internalText varchar(8000)
    > set internalText = (select top 1 Body from #File)
    > select internalText
    >
    > drop table #File
    >
    >
    > Linda

    Ty Guest

Similar Threads

  1. variable contents problem
    By mix-tape developer in forum Macromedia ColdFusion
    Replies: 6
    Last Post: May 11th, 01:55 PM
  2. passing a variable in flash to another flash file
    By haegrrl in forum Macromedia Flash
    Replies: 1
    Last Post: June 8th, 04:15 PM
  3. Passing request.form contents to a class
    By Stu in forum ASP.NET General
    Replies: 1
    Last Post: August 11th, 01:25 PM
  4. Replies: 7
    Last Post: July 17th, 04:54 AM
  5. Replies: 1
    Last Post: June 30th, 12:47 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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