I'm trying to figure out how to write this line in VBA so it doesn't comment out but comes up in my SQL query correct.
The line issue is this:
& "SELECT @cols = @cols + stuff((select '," ' + offer + '"' " _
after the the second ' is when it disables the rest of the code. Here is an example of the Code with more detail.
StrSQL = "SET NoCount ON " _
& "DECLARE @cols AS NVARCHAR(MAX)=''; " _
& "DECLARE @query AS NVARCHAR(MAX)=''; " _
& "SELECT @cols = @cols + stuff((select '," ' + offer + '"' " _
& "FROM catcov y join CatalogInfo z on (y.MailYear = z.mailyear) and (y.offer = z.catalog) " _
Any help would be appreciated.
EDIT: Solution to this issue was to add an extra " to my line so it looks like this.
& "SELECT @cols = @cols + stuff((select ',"" ' + offer + '""' " _
Thanks for the help all!