I need to know how to accomplishing something in SQL Server that I use macro expansion in VFP to accomplish.
I have a table CREATE TABLE TEST (column1 i(4), column2, i(4), .....)
IF I want to iterate thru say column8 thru 11 I use the following syntax in VFP:
PROCEDURE DoSomething
LOCAL c as STRING, lc_fieldname AS STRING
LOCAL i as INTEGER
FOR i = 8 TO 11
c = alltrim(str(i))
lc_fieldname = "column" + c
IF TEST->&lc_fieldname > 0
SELECT TEST
REPLACE &lc_fieldname WITH 888
ENDIF
ENDFOR
ENDPROC
My question is, How can I write the same algorithm as a SQL Server Stored Procedure where I loop thru certain columns in a SQL Server table without macro expansion?
I have a table CREATE TABLE TEST (column1 i(4), column2, i(4), .....)
IF I want to iterate thru say column8 thru 11 I use the following syntax in VFP:
PROCEDURE DoSomething
LOCAL c as STRING, lc_fieldname AS STRING
LOCAL i as INTEGER
FOR i = 8 TO 11
c = alltrim(str(i))
lc_fieldname = "column" + c
IF TEST->&lc_fieldname > 0
SELECT TEST
REPLACE &lc_fieldname WITH 888
ENDIF
ENDFOR
ENDPROC
My question is, How can I write the same algorithm as a SQL Server Stored Procedure where I loop thru certain columns in a SQL Server table without macro expansion?