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 |
|
hong_ma
Starting Member
37 Posts |
Posted - 2006-02-10 : 14:13:06
|
| Declare @F_ID int DECLARE @CNT INTSET @CNT = 1while @CNT <5BeginSELECT @F_ID= [EntityID]FROM [FACT].[dbo].[adReportingRequirement]SET @CNT = @CNT + 1print @F_IDendafter runing, only print one value four time. why not is four different value? |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2006-02-10 : 14:37:05
|
| You have no WHERE clause in your statement so the value of @f_id is being calculated 4 times each with the same result.Be One with the OptimizerTG |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2006-02-10 : 14:37:43
|
| Because the value of @F_ID is not modified in your code. You need to add a WHERE clause to your query that reflects @CNT's changing value.SELECT @F_ID= [EntityID]FROM [FACT].[dbo].[adReportingRequirement]WHERE SomeColumn = @CNTTara Kizeraka tduggan |
 |
|
|
hong_ma
Starting Member
37 Posts |
Posted - 2006-02-10 : 14:44:47
|
| Thanks you guys. I got it |
 |
|
|
|
|
|