[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

4.2

Trouble with dynamic SQL: Unclosed quotation mark before the character string

Asked by dkohel in Databases Miscellaneous

Tags: quotation, mark, character, unclosed, string

PROBLEM:  Receive error message:
Server: Msg 105, Level 15, State 1, Line 128
Unclosed quotation mark before the character string 'Un
 into NewTable FROM (select tbl_ecom_productdescriptor_idvaluepairs.product, tlkp_ecom_productdescriptor.dscname, tbl_ecom_productdescriptor_idvaluepairs.dscval from tbl_ecom_productdescriptor_idvaluepairs inner join tlkp_ecom_productdescriptor on tbl_ecom_productdescriptor_idvaluepairs.dscid = tlkp_ecom_productdescriptor.dscid) a
GROUP ...
Server: Msg 170, Level 15, State 1, Line 128
Line 128: Incorrect syntax near 'Un
 into NewTable FROM (select tbl_ecom_productdescriptor_idvaluepairs.product, tlkp_ecom_productdescriptor.dscname, tbl_ecom_pr'.
----------------------------
----------------------------

I am running the following dynamic sql:
declare
        @table       as varchar(500),
        @onrows      as varchar(128),
        @onrowsalias as sysname ,
        @oncols      as varchar(128),
        @sumcol      as sysname

        set @table=
                '(select tbl_ecom_productdescriptor_idvaluepairs.product, tlkp_ecom_productdescriptor.dscname, tbl_ecom_productdescriptor_idvaluepairs.dscval ' +
                'from tbl_ecom_productdescriptor_idvaluepairs inner join '+
                'tlkp_ecom_productdescriptor on tbl_ecom_productdescriptor_idvaluepairs.dscid = tlkp_ecom_productdescriptor.dscid) a '                
        set @onrows ='product'
        set @onrowsalias= null;
        set @oncols='dscname'
        set @sumcol='dscval'

declare
        @sql as varchar(8000),
        @newline as char(1)

        set @newline = char(10)

        -- step 1: beginning of sql string
        set @sql =
                'select' + @newline +
                '  ' + @onrows +
                case
                        when @onrowsalias is not null then ' as ' + @onrowsalias
                        else ''
                end

        create table #keys(keyvalue nvarchar(100) not null primary key)

--declare  @keys table(keyvalue varchar(100) not null primary key)
declare @keyssql as varchar(1000)
        set @keyssql =
                'insert into #keys ' +
                'select distinct cast(' + @oncols + ' as nvarchar(100)) ' +
                'from ' + @table
exec (@keyssql)

declare @key as nvarchar(100)
        select @key = min(keyvalue) from #keys

        while @key is not null
                begin
                        set @sql = @sql + ',' + @newline +
                        '  max(case cast(' + @oncols +
                                     ' as nvarchar(100))' + @newline +
                        '        when N''' + @key +
                           ''' then ' + case
                                                when @sumcol is null then '1'
                                                else @sumcol
                                        end + @newline +
                        '        else null' + @newline +
                        '      end) as ' + @key
                       
                        select @key = min(keyvalue) from #keys
                        where keyvalue > @key
                end


SET @sql = @sql         + @NEWLINE +
  ' into NewTable FROM ' + @table      + @NEWLINE +
  'GROUP BY ' + @onrows + @NEWLINE +
  'ORDER BY ' + @onrows
--         set @sql = @sql         + @newline +
--                 'from ' + @table      + @newline +
--                 'group by ' + @onrows + @newline +
--                 'order by ' + @onrows

-- for debugging...this information will print into the messages section
-- of query analyzer...prints information to the messages window at the
-- bottom of the screen...
print @sql  + @newline
exec (@sql)
[+][-]11/17/05 03:27 PM, ID: 15316330Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/17/05 03:29 PM, ID: 15316337Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/17/05 03:57 PM, ID: 15316484Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/17/05 04:01 PM, ID: 15316502Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/17/05 04:21 PM, ID: 15316662Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/17/05 05:54 PM, ID: 15317030Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/17/05 06:05 PM, ID: 15317061Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/18/05 05:41 AM, ID: 15319318Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/18/05 07:25 AM, ID: 15320136Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/18/05 09:12 AM, ID: 15321251Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/18/05 09:27 AM, ID: 15321384Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/18/05 10:41 AM, ID: 15321964Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/18/05 10:50 AM, ID: 15322022Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/18/05 12:09 PM, ID: 15322698Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/18/05 12:42 PM, ID: 15322933Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/18/05 02:55 PM, ID: 15323753Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/30/05 07:52 AM, ID: 15389036Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/30/05 08:06 AM, ID: 15389179Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/30/05 08:07 AM, ID: 15389193Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/30/05 08:09 AM, ID: 15389205Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/30/05 09:05 AM, ID: 15389735Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/30/05 09:10 AM, ID: 15389786Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/30/05 09:18 AM, ID: 15389851Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/30/05 09:23 AM, ID: 15389882Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/12/05 09:24 AM, ID: 15467837Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/12/05 09:57 AM, ID: 15468110Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: Databases Miscellaneous
Tags: quotation, mark, character, unclosed, string
Sign Up Now!
Solution Provided By: Steven_W
Participating Experts: 4
Solution Grade: A
 
[+][-]12/12/05 10:36 AM, ID: 15468391Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/12/05 12:28 PM, ID: 15469226Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12/12/05 01:55 PM, ID: 15469934Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/12/05 03:25 PM, ID: 15470526Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12/12/05 03:32 PM, ID: 15470562Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/12/05 03:44 PM, ID: 15470629Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12/13/05 09:38 AM, ID: 15475638Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/13/05 11:33 AM, ID: 15476571Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12/13/05 12:49 PM, ID: 15477244Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/13/05 01:01 PM, ID: 15477367Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091021-EE-VQP-81