-
-
Thanks MAk !! But nothing like that seems to work and now i am just creating a dynamic query after reading the text file. I am having problems building the insert query ...
is it possible to supply less number of values than the table columns .
The problem is that the text file might contain values for 3 columns, or 5 columns or 6 columns and the table has 18 columns . I built my dynamic query as
insert into phonebook values ('test','test','test')
and i get an error -- the values supplied so not match the column count))) Pls help me build this dynamic query !!!
Regards
Last edited by monikan; 06-21-2004 at 10:53 AM.
-
insert into phonebook(column3, column5, column6) values ('test','test','test')
-
I guess u didn't understand my question ..Its a dynamic query that i need to generate, the column 3, cloumn 5 were just an exapmle of what i might get from the file !!! i don't know how many columns values will be there in the text text !!
I am reading the text file and building the insert query !!
Regards
monika
-
--you have to use EXEC or sp_executesql
create table tb (c1 int, c2 int, c3 int, c4 int, c5 int)
declare @var varchar(100)
set @var ='c3,c2,c5'
declare @query varchar(1000)
set @query ='insert into tb (' + @var + ')' + ' values (100,200,203)'
print @query
exec (@query)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|