| Author |
Topic |
|
sent_sara
Constraint Violating Yak Guru
377 Posts |
Posted - 2009-06-22 : 07:07:34
|
when i try to execute the below query ,following error occurs.can anybody correct this problem..OLE DB provider "SQLNCLI" for linked server "(null)" returned message "Deferred prepare could not be completed.".Msg 8180, Level 16, State 1, Line 1Statement(s) could not be prepared.Msg 137, Level 15, State 2, Line 1Must declare the scalar variable "@a".declare @a nvarchar(max)set @a= 'fin_wh.dbo.Mis_allocation_main_sp ' +'''All'','+'''All'','+'''01 apr 2009'','+'''30 jun 2009'','++'''USD'','+'''All'','+'''All'''SELECT * FROM OPENROWSET ('SQLOLEDB','Server=(local);TRUSTED_CONNECTION=YES;','set fmtonly off exec @a')AS tbl |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2009-06-22 : 07:49:44
|
@a doesn't exist in the scope created by OPENROWSET.trydeclare @a nvarchar(max)set @a= 'fin_wh.dbo.Mis_allocation_main_sp ' +'''All'','+'''All'','+'''01 apr 2009'','+'''30 jun 2009'','++'''USD'','+'''All'','+'''All'''PRINT @aSELECT * FROM OPENROWSET ('SQLOLEDB','Server=(local);TRUSTED_CONNECTION=YES;','set fmtonly off exec (' + @a + ')')AS tblCharlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
 |
|
|
sent_sara
Constraint Violating Yak Guru
377 Posts |
Posted - 2009-06-23 : 01:13:37
|
when i try to execute the below query,i get the following error:Msg 102, Level 15, State 1, Line 8Incorrect syntax near '+'.quote: Originally posted by Transact Charlie @a doesn't exist in the scope created by OPENROWSET.trydeclare @a nvarchar(max)set @a= 'fin_wh.dbo.Mis_allocation_main_sp ' +'''All'','+'''All'','+'''01 apr 2009'','+'''30 jun 2009'','++'''USD'','+'''All'','+'''All'''PRINT @aSELECT * FROM OPENROWSET ('SQLOLEDB','Server=(local);TRUSTED_CONNECTION=YES;','set fmtonly off exec (' + @a + ')')AS tblCharlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
|
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-06-23 : 03:30:11
|
Try thisdeclare @a nvarchar(max)set @a= 'fin_wh.dbo.Mis_allocation_main_sp ' +'''''All'''','+'''''All'''','''+'''01 apr 2009'''','''+'''30 jun 2009'''','''+'''USD'''','''+'''All'''','''+'''All'''' 'PRINT @aset @a = 'exec ' + @aset @a = 'SELECT * FROM OPENROWSET(''SQLOLEDB'', ''Server=(local);TRUSTED_CONNECTION=YES;'', ''' + @a + ''') AS tbl'print @aexec (@a) E 12°55'05.63"N 56°04'39.26" |
 |
|
|
sent_sara
Constraint Violating Yak Guru
377 Posts |
Posted - 2009-06-23 : 03:44:57
|
while iam try to execute the below error occurred,exec fin_wh.dbo.Mis_allocation_main_sp ''All'',''All'',''01 apr 2009'',''30 jun 2009'',''USD'',''All'',''All'' SELECT * FROM OPENROWSET('SQLOLEDB', 'Server=ramcovm392;TRUSTED_CONNECTION=YES;', 'exec fin_wh.dbo.Mis_allocation_main_sp ''All'',''All'',''01 apr 2009'',''30 jun 2009'',''USD'',''All'',''All'' ') AS tblMsg 7357, Level 16, State 2, Line 1Cannot process the object "exec fin_wh.dbo.Mis_allocation_main_sp 'All','All','01 apr 2009','30 jun 2009','USD','All','All' ". The OLE DB provider "SQLNCLI" for linked server "(null)" indicates that either the object has no columns or the current user does not have permissions on that object.quote: Originally posted by Peso Try thisdeclare @a nvarchar(max)set @a= 'fin_wh.dbo.Mis_allocation_main_sp ' +'''''All'''','+'''''All'''','''+'''01 apr 2009'''','''+'''30 jun 2009'''','''+'''USD'''','''+'''All'''','''+'''All'''' 'PRINT @aset @a = 'exec ' + @aset @a = 'SELECT * FROM OPENROWSET(''SQLOLEDB'', ''Server=(local);TRUSTED_CONNECTION=YES;'', ''' + @a + ''') AS tbl'print @aexec (@a) E 12°55'05.63"N 56°04'39.26"
|
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-06-23 : 03:54:50
|
Do you have permission on the object?The account used for the linked server, that is. E 12°55'05.63"N 56°04'39.26" |
 |
|
|
sent_sara
Constraint Violating Yak Guru
377 Posts |
Posted - 2009-06-23 : 04:05:01
|
iam into sa[administrator].if i try to execute exec Mis_allocation_main_sp 'All','All','01 apr 2009',30 jun 2009','USD','All','ALL' its getting the resultset..quote: Originally posted by Peso Do you have permission on the object?The account used for the linked server, that is. E 12°55'05.63"N 56°04'39.26"
|
 |
|
|
|
|
|