1

我在 SQL Server 2008r2 的 SQL 中使用 LOWER 时遇到问题 我想我对 lower 的用法有误解,我总是遇到同样的错误 Incorrect syntax near ','

INSERT INTO [ch-s-0008180].HolidayTracker.dbo.HtUser(FirstName,LastName,Email,UserName,AdAccount,AdDomain)
SELECT u1.firstName,u1.lastName,u1.email,'CH'+(LOWER(LEFT(u1.firstName,2))+(LOWER(LEFT(u1.lastName,3)),'EUROPE\'+(LOWER(LEFT(u1.firstName,2))+(LOWER(LEFT(u1.lastName,3)),''
FROM HolidayTracker.dbo.HTUser u1
    LEFT JOIN HolidayTracker.dbo.HtUser u2 ON u1.firstName = u2.FirstName AND u1.lastName = u2.LastName AND u1.email = u2.Email

感谢您的帮助和快速答复

4

2 回答 2

3

(你之前有多余的LOWER。这是修改后的查询。

INSERT  INTO [ch-s-0008180].HolidayTracker.dbo.HtUser(FirstName,LastName,Email,UserName,AdAccount,AdDomain)
SELECT  u1.firstName, 
        u1.lastName, 
        u1.email, 
        'CH' + LOWER(LEFT(u1.firstName,2)) + LOWER(LEFT(u1.lastName,3)), 
        'EUROPE\' + LOWER(LEFT(u1.firstName,2)) + LOWER(LEFT(u1.lastName,3)),
        ''
FROM    HolidayTracker.dbo.HTUser u1
        LEFT JOIN HolidayTracker.dbo.HtUser u2 
            ON  u1.firstName = u2.FirstName AND 
                u1.lastName = u2.LastName AND 
                u1.email = u2.Email

代码的颜色搞砸了。\EUROPE不逃避'

于 2013-04-02T08:50:38.950 回答
0

您没有正确关闭支架。

'CH'+(LOWER ...,'' FROM

于 2013-04-02T08:52:27.800 回答