Please help, I would appreciate it. Below I have a simple stored procedure to return the names of my databases.
I am getting a syntax error:
Msg 105, Level 15, State 1, Line 1
Unclosed quotation mark before the character string 'PASBA-DEV '.
Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near 'SERVER1-DEV
Some of my server names contain hyphens, thus the reason for using [ ]'s in the procedure.
Code for procedure begins here:
Declare @string2sql char(50)
Set @string2sql =
'Select name from ['+@ServerName+'].[master].dbo.sysdatabases order by name';
Free Guide: Managing storage for virtual environments
Complete a brief survey to get a complimentary 70-page whitepaper featuring the best methods and solutions for your virtual environment, as well as hypervisor-specific management advice from TechTarget experts. Don’t miss out on this exclusive content!