SELECT 'INSERT INTO dbo.CMS_Transformation (   TransformationName ,
TransformationCode ,
TransformationType ,
TransformationClassID ,
TransformationVersionGUID ,
TransformationGUID ,
TransformationLastModified ,
TransformationIsHierarchical ,
TransformationHierarchicalXML ,
TransformationCSS ,
TransformationPreferredDocument
)
VALUES ('''+ TransformationName + ''')'
FROM dbo.CMS_Transformation
WHERE TransformationClassID=3452

2个单引号,代表一个字符

VALUES (|'+ TransformationName + '|)',用|替换掉上面的''

原始的sql是Values('+name+'),正常的情况拼接,拼接的时候,需要把原来的单引号,替换成两个单引号。

本来的','需要先转义成'',''来,然后再在外部分别加上'来表示

SELECT 'INSERT INTO dbo.CMS_Transformation (   TransformationName ,
TransformationCode ,
TransformationType ,
TransformationClassID ,
TransformationVersionGUID ,
TransformationGUID ,
TransformationLastModified ,
TransformationIsHierarchical ,
TransformationHierarchicalXML ,
TransformationCSS ,
TransformationPreferredDocument
)
VALUES ('''+ TransformationName +''','''+TransformationCode+ ''')'
FROM dbo.CMS_Transformation
WHERE TransformationClassID=3452
SELECT * FROM dbo.CMS_Transformation
WHERE TransformationClassID=3452
SELECT 'INSERT INTO dbo.CMS_Transformation ( TransformationName ,
TransformationCode ,
TransformationType ,
TransformationClassID ,
TransformationVersionGUID ,
TransformationGUID ,
TransformationLastModified ,
TransformationIsHierarchical ,
TransformationHierarchicalXML ,
TransformationCSS ,
TransformationPreferredDocument
)
VALUES (''' + TransformationName + ''',''' + TransformationCode + ''','''
+ TransformationType + ''',''' + TransformationClassID + ''','''
+ TransformationVersionGUID + ''',''' + TransformationGUID + ''','''
+ TransformationLastModified + ''',''' + TransformationIsHierarchical
+ ''',''' + TransformationHierarchicalXML + ''','''
+ TransformationCSS + ''',''' + TransformationPreferredDocument
+ ''')'
FROM dbo.CMS_Transformation
WHERE TransformationClassID = 3452;
SELECT 'exec lisa_pi_WebpartInit '''+convert(nvarchar(max), cms_webpartcategory.CategoryGUID)+''',
'''+ convert(varchar(400),WebpartGUID)+''',
'''+WebPartName+''',
'''+WebpartDisplayName+''',
'''+Replace(CONVERT(NVARCHAR(max),WebpartDescription),'''', '''''')+''',
'''+WebpartFileName+''', ',
''''+Replace(CONVERT(NVARCHAR(max),WebpartProperties),'''', '''''')+'''',
','+convert(varchar,isnull(WebpartType,0) )+','+convert(varchar,isnull(WebpartLoadGeneration,0))
FROM cms_webpart
JOIN cms_webpartcategory on (cms_webpart.WebpartCategoryID = cms_webpartcategory.CategoryID)
WHERE [WebPartCategoryID] IN
(SELECT [CategoryID] FROM [CMS_WebPartCategory]
WHERE [CategoryParentID] IN (SELECT [CategoryID] FROM [CMS_WebPartCategory] WHERE [CategoryName]='LISA')
AND [CategoryName]!='LISA_Animation'
AND [CategoryName]!='LISA_Custom'
AND [CategoryName]!='LISA_CustomerSupport'
AND [CategoryName]!='LISA_NoUse'
AND [CategoryName]!='LISA_Product')

用select拼接insert into,单引号转义的更多相关文章

  1. SQL拼接字符串时单引号转义问题 单引号转义字符

    要拼接一个单引号到已有字符串前后, 开始以为(错误)可以用  \ 转义,如下: '\''+ str+'\'' 看颜色就知道是不行的. 正确方法是两个单引号就转义为单引号,如下: ''''+str+'' ...

  2. 转://Oracle 单引号转义

    在ORACLE中,单引号有两个作用: 1:字符串是由单引号引用 2:转义. 单引号的使用是就近配对,即就近原则.而在单引号充当转义角色时相对不好理解 1.从第二个单引号开始被视为转义符,如果第二个单引 ...

  3. SQL 单引号转义

    declare @userNum varchar(50),@waterNum varchar(50),@tableName varchar(20),@sql varchar(max) select @ ...

  4. oracle excute immediate 单引号转义

    excute immedaite 后接单引号,但是遇到 add xxx default ' ' ,命令中还有单引号的情况,需要转义.这时候不是用传统的 \ 反斜杠来转义,而是用 单引号转义 execu ...

  5. php jsonp单引号转义

    php中jsonp输出时一般用下面的格式: callbackname('json string'); 如果中间的json string中含有单引号,这个输出就是有问题的,调用方一般是无法处理的,所以我 ...

  6. Oracle单引号转义符

    作用:Increase readability and usability (增加可读性和可用性) 用法:select  q'[ select * from ]'||table_name|| ';'  ...

  7. Oracle单引号双重角色——字符串引用与转义

    单引号双重角色——字符串引用与转义      在ORACLE中,单引号有两个作用,一是字符串是由单引号引用,二是转义,开始学习时动态构成SQL时经常不解.单引号的使用是就近配对,即就近原则.而在单引号 ...

  8. SQL语句中的单引号处理以及模糊查询

    为了防止程序SQL语句错误以及SQL注入,单引号必须经过处理.有2种办法: 1.使用参数,比如SELECT * FROM yourTable WHERE name = @name; 在C#中使用Sql ...

  9. JS中的单引号和双引号

    JS里面的单引号和双引号可以同时使用,但是要遵循一定的准则. 最外面用了双引号了,那么里面就不能再用双引号了,因为引号是成双对的,浏览器读到一个双引号后,到第2个双引号时才算结束:同理,浏览器读到一个 ...

随机推荐

  1. 24. Swap Nodes in Pairs[M]两两交换链表中的节点

    题目 Given a linked list, swap every two adjacent nodes and return its head. You may not modify the va ...

  2. JavaScript实现鼠标效果

    <html> <head> <meta charset="utf-8"> <title>无标题文档</title> &l ...

  3. junit使用第一弹

    知识点——断言 断言是编写测试用例的核心实现方式,即期望值是多少,测试的结果是多少,以此来判断测试是否通过. 1. 断言核心方法 assertArrayEquals(expecteds, actual ...

  4. 《SLIC Superpixels》阅读笔记

    原始链接:http://blog.csdn.net/jkhere/article/details/16819285 或许有改动,请参考原文! SLIC 超像素(SLICSuperpixels) Rad ...

  5. PhotoZoom Pro 7怎么进行参数设置

    每个用户在使用PhotoZoom时,在针对不同的图片,我们处理的方式也不同.所以在参数设置会因图片不同而不同.那么在PhotoZoom中参数究竟如何设置呢? 首先,我们先打开[参数设置],点击后会弹出 ...

  6. Python 数据清洗--处理Nan

    参考:http://blog.sina.com.cn/s/blog_13050351e0102xfis.html https://www.sogou.com/link?url=DOb0bgH2eKh1 ...

  7. SPOJ DISQUERY LCA + 倍增

    裸题,如此之水- Code: #include<cstdio> #include<algorithm> using namespace std; const int maxn ...

  8. 路飞学城Python-Day59(第五模块复习题)

    HTML div标签是块级标签,单独一行,可以作为其他标签的容器,没有特定含义 span是内联标签,可以作为文本内容的容器,没有特定含义 1. 查询一下对div和span标签的理解 不同的标签有自己含 ...

  9. html页面之间传值问题

    1.如再A页面(A.html)通过window.open(B.html?code=11)或者通过其他方式跳转到其它html页面时: 可通过以下方式进行传递参数. //B.html页面function ...

  10. 记Spring搭建功能完整的个人博客「Oyster」全过程[其一] 整体思路:需求、架构及技术要求

    一两个星期前正在了解Linux内核,看得有点累,突然想趁着五一放假写个博客学学spring. 由于没有在一开始下定决心写这个博客系统,所以我又没记录一开始的分析过程.这都是写了一个星期之后的思路了. ...