November 3, 2003 at 8:03 am
Hello everybody.
What i have is a bulk insert procedure that imports the data in a table. So far so good. What i want to do is to check that all data comes in groups like:
field1, field2, id
a,a,1
a,a,2
a,a,3
a,b,4
b,b,5
a,a,6 <----- this record should not appear here.
Is there any way doing so ?without using cursors please
Thanks in advance.
November 3, 2003 at 8:52 am
...why?
Frank
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
November 3, 2003 at 9:13 am
There is an aggreement specifying the grouping of the file, thus all groups must be together and in order.
November 3, 2003 at 7:26 pm
If you are concerned with the way the data is ordered when you retrieve it then use an order by clause in the select statement. You can NEVER garantee that your records are going to come out ordered the way you want without it.
Gary Johnson
Microsoft Natural Language Group
DBA, Sr. DB Engineer
Gary Johnson
Microsoft Natural Language Group
DBA, Sr. DB Engineer
This posting is provided "AS IS" with no warranties, and confers no rights. The opinions expressed in this post are my own and may not reflect that of my employer.
November 3, 2003 at 11:33 pm
I must export the data just the way they imported. The one that sents me the file has to pefrorm the group by and order clause.The question is how can i check that the imported data are grouped and in order ?
November 4, 2003 at 7:10 am
If id is sequential, then try this
select a.field1, a.field2, a.id
from table a
left outer join table b
on b.id = (a.id -1)
and (b.field1 > a.field1 or b.field2 > a.field2)
where b.id is not null
Far away is close at hand in the images of elsewhere.
Anon.
November 4, 2003 at 11:04 am
the best way would be to add an identity column to the table so that when you import the data you can preserve the ordering. Then use an order by clause on the export so that you have the same order as the import.
Gary Johnson
Microsoft Natural Language Group
DBA, Sr. DB Engineer
Gary Johnson
Microsoft Natural Language Group
DBA, Sr. DB Engineer
This posting is provided "AS IS" with no warranties, and confers no rights. The opinions expressed in this post are my own and may not reflect that of my employer.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply