ExactTarget AMPscript – data extension stuff

Let’s say we want to read a data extension and get some data from it.

First we use the “LookupRows” function to get some data from the DE. We are going to assign the results to a variable (multiRows).

The first parameter of the LookupRows function is the name of the DE you want to connect to. In this example, “myDataExt”.

The next to parameters are comparing a value to a value in a particular field in the DE. It is looping through the records looking in the ID field for a value equal to “1234”. The value it’s looking for could of course be a variable. In this example, it’s just a string, “1234”.

SET @multiRows = LookupRows("myDataExt","ID","1234")

Now the variable @multiRows holds the records where the ID and “1234” match, if there were any.

You can now loop through those records and get the data in those records.

for @i = 1 to RowCount(@multiRows) do
  Set @row = Row(@multiRows,@i)
  Set @Fname = Field(@row,"Fname")
  Set @Phone = Field(@row,"Phone")
next @i
It's only fair to share...Tweet about this on TwitterShare on FacebookEmail this to someoneShare on Google+
This entry was posted in AmpScript, ExactTarget. Bookmark the permalink.