Need help. | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Need help.

Hello, guys. I have been trying to execute the following getting only two letter as result.
Where is my mistake? declare @a varchar
declare @b varchar
declare abc cursor for select TABLE_Name, data_type
from information_schema.columns where table_name = ‘com_tv’
open abc
fetch abc into @a, @b
while @@fetch_status = 0
fetch abc into @a, @b
print space (10) + @a + space(10) + @b
close abc
deallocate abc Thanks in advance for your help. Thanks for help in advance.
Alex, You need to define the length of of the string variables, otherwise SQL defaults to too few characters. So in your variable declaration explicitly give them a length. e.g. declare @a varchar(255)
declare @b varchar(255) For something like this you will need to make sure that it is as long as the maximum SQL server allowed table name string length and maximum datatype name length. It is always good practice to define the string length when using varchar() or char(). Regards, Robert.