Donovan

Try this, Assumes you can type the PK (and it is a single field) but with a
little fiddling you could make that dynamic (use syscolums)
you can also get the PK Constrain field out of syscontraints, all depends on
how 'smart' you want to get

For eff reasons i'd submit the synch raw data to a proc that created a
'script' table and then submit the script

create proc spSynch @@TableName sysname,
                                  @@PKColName sysname,
                                  @@PKValue sysname
as begin
  declare
    @SQL varchar(1000),
    @RecCount int
  create table #RecCount (Record integer)
  set @SQL = 'select count(*) from '+@@TableName+'   where '+@@PKColName+' =
'+@@PKValue
  insert into   #RecCount execute(@SQL)
  select @RecCount = Record from #RecCount
  if @RecCount >= 1
  begin
     print "update"
  end
  else begin
    print "insert"
  end
  drop table #RecCount
end


---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"

Reply via email to