>>>He-he <g> I also like to use long nice words especially if I don't know their meaning. :)
>>ROFL
>
>That's funny :)
>
>But can you please help me with the problem I posted, sorry for turning your thread into different direction?
>
>It looks to me that
>
>declare @counter int
>set @counter = 1
>while @counter < 100000
> begin
> insert into Test1 values (@counter, 'Counter' + cast(@counter as char(10))
>
> insert into Test2 values (@counter, @counter, @counter,'Counter' + cast(@counter as varchar(10))
>
> set @counter = @counter +1
>end
>
>after the first cast operation the type of the Counter variable actually changes from int to char and thus the second insert fails.
>
>Am I right? If yes, how this code should be re-written?
>
>Thanks a lot in advance.
declare @counter int
set @counter = 1
while @counter < 100000
begin
insert into Test1 values (@counter, 'Counter ' + convert(varchar(10),@counter))
insert into Test2 values (@counter, @counter, @counter,'Counter' + convert(varchar(10),@counter))
set @counter = @counter +1
end
I didn't knew about this behavior of CAST().
Unfortunately i can't test this in SQL Server 2000, but in SQL Server 2005 using CAST() function raise an error.
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.