I Want to return All table names from a use data base but this just return a char
declare @contador int
set @contador = 1
while (@contador<=(select count(table_name) from INFORMATION_SCHEMA.TABLES))
begin
declare @tableName varchar
set @tableName = (select top 1 * from (select top(@contador) table_name from INFORMATION_SCHEMA.TABLES order by table_name asc) as nombre order by table_name desc)
print @tableName
set @contador = @contador + 1
end
the output is s s s s s s
T-SQL (Transact-SQL) is a set of programming extensions from Sybase and Microsoft that add several features to the Structured Query Language (SQL), including transaction control, exception and error handling, row processing and declared variables.
Using @@ERROR to conditionally exit a procedure. The following example uses IF...ELSE statements to test @@ERROR after an DELETE statement in a stored procedure. The value of the @@ERROR variable determines the return code sent to the calling program, indicating success or failure of the procedure.
declare @tableName varchar(100)
You need to define the length of @tableName, by default it is set to 1 character.
try
declare @tableName varchar(100)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With