SQL Server 2005 语法错误
这是 SQL:
CREATE TABLE dbo.TmpFeesToRules1(Name varchar, LookupId int)
INSERT INTO dbo.TmpFeesToRules1(Name, LookupId)
SELECT DISTINCT Name, 0 FROM Lending.Fee
UNION SELECT DISTINCT Name, 0 FROM Lending.ApplicationFee
INSERT INTO dbo.tblLookup (LookupType, LookupCode, LookupDesc, EditFlag, DeletedFlag, DefaultFlag)
SELECT 'FEE_CODE', Name, Name, 0, 0, 0
FROM dbo.TmpFeesToRules1
UPDATE dbo.TmpFeesToRules1
SET
LookupId = L.LookupID
FROM
dbo.tblLookup L
INNER JOIN dbo.TmpFeesToRules1 T ON T.Name = L.LookupDesc
WHERE
L.LookupType = 'FEE_CODE'
CREATE TABLE dbo.TmpFeesToRules2(FeeId int, Name varchar)
INSERT INTO dbo.TmpFeesToRules2(FeeId, Name)
SELECT FeeId, Name FROM Lending.ApplicationFee
GO
UPDATE Lending.ApplicationFee
SET Lending.ApplicationFee.FeeTypeId = T.LookupId
FROM dbo.TmpFeesToRules2 TT
INNER JOIN dbo.TmpFeesToRules1 T ON T.Name = TT.Name
WHERE Lending.ApplicationFee.FeeId = TT.FeeId
DROP TABLE dbo.TmpFeesToRules1
DROP TABLE dbo.TmpFeesToRules2
这是错误:
对象名称“dbo.TmpFeesToRules2”无效。
执行失败,返回码:1
有什么想法吗?
Here is the SQL:
CREATE TABLE dbo.TmpFeesToRules1(Name varchar, LookupId int)
INSERT INTO dbo.TmpFeesToRules1(Name, LookupId)
SELECT DISTINCT Name, 0 FROM Lending.Fee
UNION SELECT DISTINCT Name, 0 FROM Lending.ApplicationFee
INSERT INTO dbo.tblLookup (LookupType, LookupCode, LookupDesc, EditFlag, DeletedFlag, DefaultFlag)
SELECT 'FEE_CODE', Name, Name, 0, 0, 0
FROM dbo.TmpFeesToRules1
UPDATE dbo.TmpFeesToRules1
SET
LookupId = L.LookupID
FROM
dbo.tblLookup L
INNER JOIN dbo.TmpFeesToRules1 T ON T.Name = L.LookupDesc
WHERE
L.LookupType = 'FEE_CODE'
CREATE TABLE dbo.TmpFeesToRules2(FeeId int, Name varchar)
INSERT INTO dbo.TmpFeesToRules2(FeeId, Name)
SELECT FeeId, Name FROM Lending.ApplicationFee
GO
UPDATE Lending.ApplicationFee
SET Lending.ApplicationFee.FeeTypeId = T.LookupId
FROM dbo.TmpFeesToRules2 TT
INNER JOIN dbo.TmpFeesToRules1 T ON T.Name = TT.Name
WHERE Lending.ApplicationFee.FeeId = TT.FeeId
DROP TABLE dbo.TmpFeesToRules1
DROP TABLE dbo.TmpFeesToRules2
Here is the error:
Invalid object name 'dbo.TmpFeesToRules2'.
Execute failed, return code: 1
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
与
Go
或分号无关,您正在更新
Lending.ApplicationFee
,但它没有出现在FROM
子句中。我想这应该是这样的
Nothing to do with
Go
or semicolons,You are updating
Lending.ApplicationFee
but it doesn't appear in theFROM
clause.I guess this should be something like
而不是
你可以这样做:
这将一步创建并填充表
Instead of
you could just do:
That will create and populate the table in one step