I am trying to update a field in TblA based on the contents of a field in
TblB where 4 conditions match but I can't get it to work. ere is what I
tried:
Update TblA t Set [Show Name] =
(Select Contest From TblB s
Where s.Date = t.Date,
s.RegionalCode = t.Regional,
s.unit = t.unit,
s.PF = t.[P or F])
How should that be coded?Update TblA Set [Show Name] =
(Select Contest From TblB s
Where s.Date = TblA.Date and
s.RegionalCode = TblA.Regional and
s.unit = TblA.unit and
s.PF = TblA.[P or F])|||Thanks. I was off on the wrong track.
Wayne
<markc600@.hotmail.com> wrote in message
news:1144491686.935456.163560@.v46g2000cwv.googlegroups.com...
> Update TblA Set [Show Name] =
> (Select Contest From TblB s
> Where s.Date = TblA.Date and
> s.RegionalCode = TblA.Regional and
> s.unit = TblA.unit and
> s.PF = TblA.[P or F])
>|||You might want a where clause in your query:
Update TblA Set [Show Name] =
(Select Contest From TblB s
Where s.Date = TblA.Date and
s.RegionalCode = TblA.Regional and
s.unit = TblA.unit and
s.PF = TblA.[P or F])
where exists
(Select Contest From TblB s
Where s.Date = TblA.Date and
s.RegionalCode = TblA.Regional and
s.unit = TblA.unit and
s.PF = TblA.[P or F])sql
Showing posts with label contents. Show all posts
Showing posts with label contents. Show all posts
Friday, March 30, 2012
Monday, February 20, 2012
Multipe text file import to single table
All,
I need to import the contents of 1000+ text files into a single table
in SQL Server 7.0. The files are plain ascii, fields seperated by
"/".
Does anyone have ideas of how this can be achieved?
Regards,
A.Multiple BULK INSERT commands?
"Adrian Smith" <adriancsi@.aol.com> wrote in message
news:eb79b8a3.0311181012.76211750@.posting.google.com...
> All,
> I need to import the contents of 1000+ text files into a single table
> in SQL Server 7.0. The files are plain ascii, fields seperated by
> "/".
> Does anyone have ideas of how this can be achieved?
> Regards,
> A.|||Do they all have exactly the same format?
If so it may be easier to concatenate them into one single file... From a
DOS prompt you could use:
TYPE *.TXT > BIGFILE.TXT
(Assuming they all have .TXT extension and that they're the only files in
the folder with .TXT extension, of course)
From there you could then use either BULK COPY or BCP.
If for some reason you don't want to or can't concatenate them, you could
write a batch file that would call BCP, replacing the filename parameter in
the batch file with %1, then call the batch file for each file using (again
from a DOS prompt):
FOR %i IN (DIR *.TXT) DO INSERT.BAT %i
Or you could write the entire thing in a SQL script using a cursor and a
call to xp_cmdshell to get a list of the files... IMO the DOS methods are a
lot easier.
"Adrian Smith" <adriancsi@.aol.com> wrote in message
news:eb79b8a3.0311181012.76211750@.posting.google.com...
> All,
> I need to import the contents of 1000+ text files into a single table
> in SQL Server 7.0. The files are plain ascii, fields seperated by
> "/".
> Does anyone have ideas of how this can be achieved?
> Regards,
> A.
I need to import the contents of 1000+ text files into a single table
in SQL Server 7.0. The files are plain ascii, fields seperated by
"/".
Does anyone have ideas of how this can be achieved?
Regards,
A.Multiple BULK INSERT commands?
"Adrian Smith" <adriancsi@.aol.com> wrote in message
news:eb79b8a3.0311181012.76211750@.posting.google.com...
> All,
> I need to import the contents of 1000+ text files into a single table
> in SQL Server 7.0. The files are plain ascii, fields seperated by
> "/".
> Does anyone have ideas of how this can be achieved?
> Regards,
> A.|||Do they all have exactly the same format?
If so it may be easier to concatenate them into one single file... From a
DOS prompt you could use:
TYPE *.TXT > BIGFILE.TXT
(Assuming they all have .TXT extension and that they're the only files in
the folder with .TXT extension, of course)
From there you could then use either BULK COPY or BCP.
If for some reason you don't want to or can't concatenate them, you could
write a batch file that would call BCP, replacing the filename parameter in
the batch file with %1, then call the batch file for each file using (again
from a DOS prompt):
FOR %i IN (DIR *.TXT) DO INSERT.BAT %i
Or you could write the entire thing in a SQL script using a cursor and a
call to xp_cmdshell to get a list of the files... IMO the DOS methods are a
lot easier.
"Adrian Smith" <adriancsi@.aol.com> wrote in message
news:eb79b8a3.0311181012.76211750@.posting.google.com...
> All,
> I need to import the contents of 1000+ text files into a single table
> in SQL Server 7.0. The files are plain ascii, fields seperated by
> "/".
> Does anyone have ideas of how this can be achieved?
> Regards,
> A.
Subscribe to:
Posts (Atom)