Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Da_Retina
Posting Yak Master
109 Posts |
Posted - 2002-03-05 : 06:30:47
|
| SELECT @AccountTotalId=AccountTotalId FROM GLR_AccountsTotals,GLR_PayrollGroups Where GroupId=@GroupId AND GLR_AccountsTotals.AccountId=GLR_PayrollGroups.AccountId1 AND ISNULL(Total1,-1)<>-1 If @@RowCount=1Begin -- First TotalSELECT @AccountTotalId=AccountTotalId, @ValueDb=Total1, @ValueCr = 0FROM GLR_AccountsTotals,GLR_PayrollGroups WHERE GroupId=@GroupId and GLR_AccountsTotals.AccountId=GLR_PayrollGroups.AccountId1SELECT @SystemTransId=SystemId From GLR_Accounts,GLR_PayrollGroups Where GroupId=@GroupId and GLR_Accounts.AccountId=GLR_PayrollGroups.AccountId1Endok..I need to REPEAT that block 14 times for every balded field I need to change the (1) to 2 ,3,4,...14In other words I need to make the column name variable !!..Can I do that??..Please HELP ME!Salute Pals..------------------If I am to do it,I will, and NOW .. |
|
|
Nazim
A custom title
1408 Posts |
Posted - 2002-03-05 : 07:35:31
|
| You can use dynamic Sql. Merkin has written a two part article on using Dynamic Sqlhttp://www.sqlteam.com/item.asp?ItemID=4619.HTH-------------------------------------------------------------- |
 |
|
|
|
|
|