Home > database >  Navicat run the SQL command an error?
Navicat run the SQL command an error?

Time:11-19

Navicat run the SQL command error, but the same command in SQL running normally, specific how? Thank you

 declare @ QQNum int=40002336 
Declare @ SQL varchar (8000)
Declare @ dbIdx int=1

If OBJECT_ID (' tempdb for. Dbo. # QunList ') is not null
Drop table # QunList
If OBJECT_ID (' tempdb for. Dbo. # QunDetail ') is not null
Drop table # QunDetail

The create table # QunList
(
QQNum int,
Nick varchar (20),
The Age int,
Gender int,
Auth int,
QunNum int,
The Title varchar (22),
QunText varchar (80)
)
The create table # QunDetail
(
QunNum int,
The Title varchar (22),
QunText varchar (80)
)

- Search QunList

While @ dbIdx & lt; 11=
The begin
Declare @ tblIdx int=1
Declare @ tblName varchar (50)

While @ tblIdx & lt;=100
The begin
Set @ tblName='GroupData + CONVERT (varchar (2), @ dbIdx) +'. The dbo. The Group '
The set @ tblName +=the CONVERT (varchar (5), (@ dbIdx - 1) * 100 + @ tblIdx)

The set @ SQL='select QQNum, Nick, Age, Gender, Auth, QunNum from'
SQL +=set @ @ tblName + 'where QQNum=' + CONVERT (varchar (15), @ QQNum)

Insert into # QunList (QQNum, Nick, Age, Gender, Auth, QunNum) exec (@ SQL)

Print @ tblname + 'OK'

The set @ tblIdx +=1
End

The set @ dbIdx +=1
End

- Search QunDetail

Declare @ QunNum int
Declare cur_Qun cursor
For the select QunNum from # QunList

The open cur_Qun
The fetch next from cur_Qun into @ QunNum

While @ @ FETCH_STATUS=0
The begin
SQL=set @ 'select QunNum, Title, QunText from QunInfo' + CONVERT (varchar (5), @ QunNum/10000000 + 1) + 'on. Dbo.'
Set @ SQL +='QunList + CONVERT (varchar (10), @ QunNum/1000000 + 1) +' where QunNum='+ CONVERT (varchar (20), @ QunNum)

Insert into # QunDetail exec (@ SQL)

The fetch next from cur_Qun into @ QunNum
End

The close cur_Qun
Deallocate cur_Qun

- combine QunList with QunDetail

Update # QunList set Title=# QunDetail. Title, QunText=# QunDetail. QunText
The from # QunDetail
Where # QunList. QunNum=# QunDetail. QunNum

Select * from # QunList



Error: [42 s02] [Microsoft] [10.0] SQL Server Native Client/SQL Server object name 'QunInfo1on. Dbo. QunList3' invalid, (208).

CodePudding user response:

Alright with the 2 other mosaics
SQL=set @ 'select QunNum, Title, QunText from QunInfo' + CONVERT (varchar (5), @ QunNum/10000000 + 1) + 'on. Dbo.'
Set @ SQL +='QunList + CONVERT (varchar (10), @ QunNum/1000000 + 1) +' where QunNum='+ CONVERT (varchar (20), @ QunNum)

CodePudding user response:

reference 1st floor shoppo0505 response:
alright with the 2 other mosaics
SQL=set @ 'select QunNum, Title, QunText from QunInfo' + CONVERT (varchar (5), @ QunNum/10000000 + 1) + 'on. Dbo.'
Set @ SQL +='QunList + CONVERT (varchar (10), @ QunNum/1000000 + 1) +' where QunNum='+ CONVERT (varchar (20), @ QunNum)
but essentially normal can query, don't know why

CodePudding user response:

refer to the second floor qq_26831091 response:
Quote: refer to 1st floor shoppo0505 response:

Alright with the 2 other mosaics
SQL=set @ 'select QunNum, Title, QunText from QunInfo' + CONVERT (varchar (5), @ QunNum/10000000 + 1) + 'on. Dbo.'
Set @ SQL +='QunList + CONVERT (varchar (10), @ QunNum/1000000 + 1) +' where QunNum='+ CONVERT (varchar (20), @ QunNum)
but essentially normal can query, don't know why

Data table with the data?

CodePudding user response:

reference shoppo0505 reply: 3/f
Quote: refer to the second floor qq_26831091 response:

Quote: refer to 1st floor shoppo0505 response:

Alright with the 2 other mosaics
SQL=set @ 'select QunNum, Title, QunText from QunInfo' + CONVERT (varchar (5), @ QunNum/10000000 + 1) + 'on. Dbo.'
Set @ SQL +='QunList + CONVERT (varchar (10), @ QunNum/1000000 + 1) +' where QunNum='+ CONVERT (varchar (20), @ QunNum)
but essentially normal can query, don't know why

Data table with the data?
you, it is normal, Navicat error, : [42 s02] [Microsoft] [10.0] SQL Server Native Client/SQL Server object name 'QunInfo1on. Dbo. QunList3' invalid, (208)

CodePudding user response:

reference 4 floor qq_26831091 response:
Quote: reference shoppo0505 reply: 3/f

Quote: refer to the second floor qq_26831091 response:

Quote: refer to 1st floor shoppo0505 response:

Alright with the 2 other mosaics
SQL=set @ 'select QunNum, Title, QunText from QunInfo' + CONVERT (varchar (5), @ QunNum/10000000 + 1) + 'on. Dbo.'
Set @ SQL +='QunList + CONVERT (varchar (10), @ QunNum/1000000 + 1) +' where QunNum='+ CONVERT (varchar (20), @ QunNum)
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related