mardi 12 juillet 2016

Loop for where clause sql

I need to build the where clause in an update statement dynamic out of a result from one table

The result looks like this: ID, ReferenceID, RefererenceNumber

This is the columns I will have in the where clause.

And in Another table I have the values for every column: 1,2,3 2,3,4

And my update statement looks like this:

set @sqlstring = 'update '+ @table +' set V = 1
WHERE  ;'

I Think I have to do a varaiable which holds the where statement, but how will I build it up?

I'm new to sql and I don't know where to start here

Aucun commentaire:

Enregistrer un commentaire