I normally do this sort of thing without a cursor while still using a loop but I don't have time to play with it right now.
Since you mentioned being new, It helps when you post code on here to put the IFCode Shortcuts from the left of the messagebox around your code to format it.
Doing it the same way you could do the following:
SET NOCOUNT ON
GO
DECLARE updatestats CURSOR FOR
SELECT table_schema, table_name
FROM information_schema.tables
where TABLE_TYPE = 'BASE TABLE'
OPEN updatestats
DECLARE @tableSchema NVARCHAR(128)
DECLARE @tableName NVARCHAR(128)
DECLARE @Statement NVARCHAR(300)
FETCH NEXT FROM updatestats INTO @tableSchema, @tableName
WHILE (@@FETCH_STATUS = 0)
BEGIN
PRINT N'UPDATING STATISTICS ' + '[' + @tableSchema + ']' + '.' + '[' + @tableName + ']'
SET @Statement = 'UPDATE STATISTICS ' + '[' + @tableSchema + ']' + '.' + '[' + @tableName + ']' + ' WITH FULLSCAN'
--PRINT @Statement
EXEC sp_executesql @Statement
FETCH NEXT FROM updatestats INTO @tableSchema, @tableName
END
CLOSE updatestats
DEALLOCATE updatestats
GO
SET NOCOUNT OFF
GO
Also, have a look at this page for some of the normal maintenance procedures including another way of doing this.
MCITP, Database Administrator
A hodgepodge of Information Technology and Life
LinkedIn Profile
My Twitter