How to select a list of values without adding into table

  • I want to generate a dynamic query by selecting a list of values. The list is generated by a dot net application.

    ex: list

    1. a.txt

    2. b.txt

    3. c.txt

    using this list i want to generate the dynamic quer insert into test ('a.txt'),insert into test ('b.txt'), insert into test ('c.txt') so on.

    is there any options available?

  • You can create procedure and list value pass to procedure as comm delimited

    create USP_Insert_table (@list varchar(8000)='a.txt,b.txt,c.txt')

    as

    begin

    insert into #table (text_name)

    select data from dbo.f_Split(',',@list) where data<>''

    end

    function dbo.f_Split will split the list data in tabular format

Viewing 2 posts - 1 through 1 (of 1 total)

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