Home Forums SQL Server 2005 T-SQL (SS2K5) TSQL Error using Cursor to loop through sysdatabases (Syntax Error) RE: TSQL Error using Cursor to loop through sysdatabases (Syntax Error)

  • Thanks for all the suggestions. Turns out for this application i just had a typo error.

    EXEC ('USE ' + @DataName +

    'INSERT INTO #TMP1 SELECT ' + @DataName + '.dbo.Sites.FullUrl,'

    + @DataName + '.dbo.UserInfo.tp_Login

    FROM ' + @DataName + '.dbo.Sites INNER JOIN

    UserInfo ON ' + @DataName + '.dbo.Sites.OwnerID = '

    + @DataName + '.dbo.UserInfo.tp_ID

    ')

    So putting in single quotes with the use statemnt fixed my problem. Just in case anyone wants to know.