The following bcp command from SSMS is not working. Can someone explain why? I've attached error message below also. Thanks.
declare @sql_varchar(8000)
select @sql = 'bcp master..sysobjects out
c:\bcp\sysobjects.txt -c -t -T -S' + @@servername
exec master..xp_cmdshell @sql
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '('.
Msg 137, Level 15, State 1, Line 3
Must declare the scalar variable "@sql".
Msg 137, Level 15, State 2, Line 5
Must declare the scalar variable "@sql".
declare @sql_varchar(8000)
select @sql = 'bcp master..sysobjects out
c:\bcp\sysobjects.txt -c -t -T -S' + @@servername
exec master..xp_cmdshell @sql
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '('.
Msg 137, Level 15, State 1, Line 3
Must declare the scalar variable "@sql".
Msg 137, Level 15, State 2, Line 5
Must declare the scalar variable "@sql".