Showing posts with label select. Show all posts
Showing posts with label select. Show all posts

Friday, March 23, 2012

Error when importing data from Excel File

Hi!

This is what i'm doing:

IF EXISTS (SELECT srvname FROM master.dbo.sysservers srv WHERE srv.srvid !=

0 AND srv.srvname = N'ExcelSource')

EXEC master.dbo.sp_dropserver @.server=N'ExcelSource', @.droplogins='droplogins';
-
EXEC master.dbo.sp_addlinkedserver
@.server = 'ExcelSource',
@.srvproduct = 'Excel',
@.provider = 'Microsoft.Jet.OLEDB.4.0',
@.datasrc = @.Chemin,
@.provstr = 'Excel 8.0';

EXEC master.dbo.sp_addlinkedsrvlogin
@.rmtsrvname = 'ExcelSource',
@.useself = false,
@.locallogin = NULL,
@.rmtuser ='ADMIN',
@.rmtpassword = NULL;

set @.NomServ = 'ExcelSource';

This create a linkedServer to read my ExcelFile.

Then i'm doing this:

EXEC ('Insert into Elements (No_element, Nom_elem, Desc_elem, Code_grpe_classe, Tps_elem, Code_sgrpe, Code_produit)
Select No_element, Nom_elem, Desc_elem, Code_grpe_classe, Tps_elem, Code_sgrpe, Code_produit
from ' + @.NomServ + '...[Elements$];')

This is where i got an error. The error is:
The OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "ExcelSource" does not contain the table "Elements$". The table either does not exist or the current user does not have permissions on that table.

I can't figure out what i'm missing. I've add permissions for EVERYONE on the file and on the folder just to be sure and i still have the same error. How can i check if the table [Elements$] exist ?
I've forgot to mention that my excel spreadsheet name is Elements.|||I finally found what the problem was. One of my column name had the wrong Column name. Now it's working fine !

Wednesday, March 21, 2012

Error when field in ORDER BY does not match SELECT DISTINCT fields

This error crept up in SQL 2005 and does not appear in earlier versions of
SQL Server. The below code looks like:
SELECT DISTINCT 'Test' As TestName, ...
FROM ...
ORDER BY 'Test'
I had to change the ORDER BY to the alias TestName to get is to compile and
run in SQL2005. Is there a SQL command I can run to prior to adding my view
to prevent these messages? Or do I lump it and change all occurrences to us
e
the alias in the ORDER BY?
Thanks for your help,
TomOn Mon, 20 Mar 2006 10:27:30 -0800, Tom Kelley <Tom
Kelley@.discussions.microsoft.com> wrote:

>This error crept up in SQL 2005 and does not appear in earlier versions of
>SQL Server. The below code looks like:
>SELECT DISTINCT 'Test' As TestName, ...
>FROM ...
>ORDER BY 'Test'
>I had to change the ORDER BY to the alias TestName to get is to compile and
>run in SQL2005.
Hi Tom,
SQL Server 2000 was very forgiving WRT what it allowed you to put in an
ORDER BY clause. That had some great advantages, but some divantages
as well, since it allowed you to write rather ambiguous things, and it
would often interpret it different from what you meant. For instance, if
you still have access to a SQL Server 2000 installation, run the code
below and try to explain the results.
CREATE TABLE Persons
(FirstName varchar(20) NOT NULL,
LastName varchar(20) NOT NULL
)
go
INSERT INTO Persons (FirstName, LastName)
SELECT 'Hugo', 'Kornelis'
UNION ALL
SELECT 'Tom', 'Kelly'
go
SELECT LastName
FROM Persons
ORDER BY FirstName
go
SELECT LastName AS FirstName, FirstName AS LastName
FROM Persons
ORDER BY FirstName
go
SELECT LastName AS FirstName
FROM Persons
ORDER BY FirstName
go
SELECT LastName AS FirstName
FROM Persons
ORDER BY Persons.FirstName
go
SELECT LastName AS FirstName
FROM Persons
ORDER BY FirstName + ''
go
DROP TABLE Persons
go
Anyway, SQL Server 2005 is more strict (though not nearly as strict as
what the official ANSI standards for SQL allow <g> ). You might have to
change some ORDER BY clauses.

> Is there a SQL command I can run to prior to adding my view
>to prevent these messages? Or do I lump it and change all occurrences to u
se
>the alias in the ORDER BY?
The ORDER BY clause doesn't only accept the alias - it accepts column
names and expressions as well (though apparently not an "expression"
that is a string constant).
Though I personally fail to see ANY reason why you would want to include
a constant value in your ORDER BY list.
Hugo Kornelis, SQL Server MVPsql

Monday, March 12, 2012

Error when checking if column exists before running query.

I am getting this error when the below query is run "Invalid column
name 'CellPhone'"
if exists (select * from information_schema.columns where table_name
='Customers' AND COLUMN_NAME = 'CellPhone')
UPDATE Customers SET PhoneNumber = CellPhone
GO
The Customers table exists but the column CellPhone doesn't.
SQL seems to try to validate the update query even if its not going to
be run.
If I change the table to something that doesn't exist, it will skip
over the line without any errors.
eg. UPDATE CustomersXXX SET PhoneNumber = CellPhone
So if the table does exist it must try to validate the columns against
the table.
Any ideas on how to get around this? I don't want it to run the query
if the column doesn't exist.
ThanksThere might be better ways but this splits the statement into two compiles:
if exists (select * from information_schema.columns where table_name
='Customers' AND COLUMN_NAME = 'CellPhone')
EXEC ('UPDATE Customers SET PhoneNumber = CellPhone')
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
<focus.nz@.gmail.com> wrote in message
news:1151547434.570100.97390@.m73g2000cwd.googlegroups.com...
>I am getting this error when the below query is run "Invalid column
> name 'CellPhone'"
>
> if exists (select * from information_schema.columns where table_name
> ='Customers' AND COLUMN_NAME = 'CellPhone')
> UPDATE Customers SET PhoneNumber = CellPhone
> GO
>
> The Customers table exists but the column CellPhone doesn't.
> SQL seems to try to validate the update query even if its not going to
> be run.
> If I change the table to something that doesn't exist, it will skip
> over the line without any errors.
> eg. UPDATE CustomersXXX SET PhoneNumber = CellPhone
> So if the table does exist it must try to validate the columns against
> the table.
> Any ideas on how to get around this? I don't want it to run the query
> if the column doesn't exist.
> Thanks
>|||There might be better ways but this splits the statement into two compiles:
if exists (select * from information_schema.columns where table_name
='Customers' AND COLUMN_NAME = 'CellPhone')
EXEC ('UPDATE Customers SET PhoneNumber = CellPhone')
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
<focus.nz@.gmail.com> wrote in message
news:1151547434.570100.97390@.m73g2000cwd.googlegroups.com...
>I am getting this error when the below query is run "Invalid column
> name 'CellPhone'"
>
> if exists (select * from information_schema.columns where table_name
> ='Customers' AND COLUMN_NAME = 'CellPhone')
> UPDATE Customers SET PhoneNumber = CellPhone
> GO
>
> The Customers table exists but the column CellPhone doesn't.
> SQL seems to try to validate the update query even if its not going to
> be run.
> If I change the table to something that doesn't exist, it will skip
> over the line without any errors.
> eg. UPDATE CustomersXXX SET PhoneNumber = CellPhone
> So if the table does exist it must try to validate the columns against
> the table.
> Any ideas on how to get around this? I don't want it to run the query
> if the column doesn't exist.
> Thanks
>|||Thanks, that did the trick.

Error when checking if column exists before running query.

I am getting this error when the below query is run "Invalid column
name 'CellPhone'"
if exists (select * from information_schema.columns where table_name
='Customers' AND COLUMN_NAME = 'CellPhone')
UPDATE Customers SET PhoneNumber = CellPhone
GO
The Customers table exists but the column CellPhone doesn't.
SQL seems to try to validate the update query even if its not going to
be run.
If I change the table to something that doesn't exist, it will skip
over the line without any errors.
eg. UPDATE CustomersXXX SET PhoneNumber = CellPhone
So if the table does exist it must try to validate the columns against
the table.
Any ideas on how to get around this? I don't want it to run the query
if the column doesn't exist.
ThanksThere might be better ways but this splits the statement into two compiles:
if exists (select * from information_schema.columns where table_name
='Customers' AND COLUMN_NAME = 'CellPhone')
EXEC ('UPDATE Customers SET PhoneNumber = CellPhone')
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
<focus.nz@.gmail.com> wrote in message
news:1151547434.570100.97390@.m73g2000cwd.googlegroups.com...
>I am getting this error when the below query is run "Invalid column
> name 'CellPhone'"
>
> if exists (select * from information_schema.columns where table_name
> ='Customers' AND COLUMN_NAME = 'CellPhone')
> UPDATE Customers SET PhoneNumber = CellPhone
> GO
>
> The Customers table exists but the column CellPhone doesn't.
> SQL seems to try to validate the update query even if its not going to
> be run.
> If I change the table to something that doesn't exist, it will skip
> over the line without any errors.
> eg. UPDATE CustomersXXX SET PhoneNumber = CellPhone
> So if the table does exist it must try to validate the columns against
> the table.
> Any ideas on how to get around this? I don't want it to run the query
> if the column doesn't exist.
> Thanks
>|||Thanks, that did the trick.

Error when changing job owner

When I change one of my job owners on a job that does a simple select, from
sa to a domain account, the job fails giving me the following error:
Could not obtain information about Windows NT group/user 'MyDomain\ADUser'
Error 8198.
I verified this login was a part of the Pre-Windows 2000 Compatible Access
Group (kb 241643). Next I tried using xp_logininfo with this login, and I
got the same error. Then I took out the select from the xp and ran it
separately (select distinct domain+N'\'+name, sid, sidtype from
OpenRowset(NetUserGetGroups, 'mydomain\aduser') and got the same error.
When I ran the above select statement with unknow domain\login, I got the
same error.
Any help would be appreciated.
Paul
You might want to have a look at
How to troubleshoot a SQL Server 8198 error
http://support.microsoft.com/default...b;en-us;834124
and
FIX: You Receive an Error Message When the xp_logininfo Extended Stored
Procedure Runs
http://support.microsoft.com/default.aspx?kbid=830596
Also make sure you are on the latest windows service pack
HTH
Jasper Smith (SQL Server MVP)
http://www.sqldbatips.com
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
"Paul Bergstedt" <Paul@.nospam.com> wrote in message
news:uLmmgm4XEHA.3664@.TK2MSFTNGP12.phx.gbl...
> When I change one of my job owners on a job that does a simple select,
from
> sa to a domain account, the job fails giving me the following error:
> Could not obtain information about Windows NT group/user 'MyDomain\ADUser'
> Error 8198.
> I verified this login was a part of the Pre-Windows 2000 Compatible Access
> Group (kb 241643). Next I tried using xp_logininfo with this login, and I
> got the same error. Then I took out the select from the xp and ran it
> separately (select distinct domain+N'\'+name, sid, sidtype from
> OpenRowset(NetUserGetGroups, 'mydomain\aduser') and got the same error.
> When I ran the above select statement with unknow domain\login, I got the
> same error.
> Any help would be appreciated.
> Paul
>
|||After trying everying under the sun, I tried putting the server name into
the Pre-Windows 2000 Access Group, and that fixed the problem. I got this
idea after noticing that the service account that the SQL Server services
ran under was the local System Account. I would imagine if I were running
the services under a domain account that it too would need to be added. I
have a case open with Microsoft on this, so I will ask them to suggest
putting this info into the KB article listed below.
Paul
"Jasper Smith" <jasper_smith9@.hotmail.com> wrote in message
news:eybsju6XEHA.1764@.TK2MSFTNGP10.phx.gbl...[vbcol=seagreen]
> You might want to have a look at
> How to troubleshoot a SQL Server 8198 error
> http://support.microsoft.com/default...b;en-us;834124
> and
> FIX: You Receive an Error Message When the xp_logininfo Extended Stored
> Procedure Runs
> http://support.microsoft.com/default.aspx?kbid=830596
> Also make sure you are on the latest windows service pack
> --
> HTH
> Jasper Smith (SQL Server MVP)
> http://www.sqldbatips.com
> I support PASS - the definitive, global
> community for SQL Server professionals -
> http://www.sqlpass.org
> "Paul Bergstedt" <Paul@.nospam.com> wrote in message
> news:uLmmgm4XEHA.3664@.TK2MSFTNGP12.phx.gbl...
> from
'MyDomain\ADUser'[vbcol=seagreen]
Access[vbcol=seagreen]
I[vbcol=seagreen]
the
>

Error when changing job owner

When I change one of my job owners on a job that does a simple select, from
sa to a domain account, the job fails giving me the following error:
Could not obtain information about Windows NT group/user 'MyDomain\ADUser'
Error 8198.
I verified this login was a part of the Pre-Windows 2000 Compatible Access
Group (kb 241643). Next I tried using xp_logininfo with this login, and I
got the same error. Then I took out the select from the xp and ran it
separately (select distinct domain+N'\'+name, sid, sidtype from
OpenRowset(NetUserGetGroups, 'mydomain\aduser') and got the same error.
When I ran the above select statement with unknow domain\login, I got the
same error.
Any help would be appreciated.
PaulYou might want to have a look at
How to troubleshoot a SQL Server 8198 error
http://support.microsoft.com/default.aspx?scid=kb;en-us;834124
and
FIX: You Receive an Error Message When the xp_logininfo Extended Stored
Procedure Runs
http://support.microsoft.com/default.aspx?kbid=830596
Also make sure you are on the latest windows service pack
--
HTH
Jasper Smith (SQL Server MVP)
http://www.sqldbatips.com
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
"Paul Bergstedt" <Paul@.nospam.com> wrote in message
news:uLmmgm4XEHA.3664@.TK2MSFTNGP12.phx.gbl...
> When I change one of my job owners on a job that does a simple select,
from
> sa to a domain account, the job fails giving me the following error:
> Could not obtain information about Windows NT group/user 'MyDomain\ADUser'
> Error 8198.
> I verified this login was a part of the Pre-Windows 2000 Compatible Access
> Group (kb 241643). Next I tried using xp_logininfo with this login, and I
> got the same error. Then I took out the select from the xp and ran it
> separately (select distinct domain+N'\'+name, sid, sidtype from
> OpenRowset(NetUserGetGroups, 'mydomain\aduser') and got the same error.
> When I ran the above select statement with unknow domain\login, I got the
> same error.
> Any help would be appreciated.
> Paul
>|||After trying everying under the sun, I tried putting the server name into
the Pre-Windows 2000 Access Group, and that fixed the problem. I got this
idea after noticing that the service account that the SQL Server services
ran under was the local System Account. I would imagine if I were running
the services under a domain account that it too would need to be added. I
have a case open with Microsoft on this, so I will ask them to suggest
putting this info into the KB article listed below.
Paul
"Jasper Smith" <jasper_smith9@.hotmail.com> wrote in message
news:eybsju6XEHA.1764@.TK2MSFTNGP10.phx.gbl...
> You might want to have a look at
> How to troubleshoot a SQL Server 8198 error
> http://support.microsoft.com/default.aspx?scid=kb;en-us;834124
> and
> FIX: You Receive an Error Message When the xp_logininfo Extended Stored
> Procedure Runs
> http://support.microsoft.com/default.aspx?kbid=830596
> Also make sure you are on the latest windows service pack
> --
> HTH
> Jasper Smith (SQL Server MVP)
> http://www.sqldbatips.com
> I support PASS - the definitive, global
> community for SQL Server professionals -
> http://www.sqlpass.org
> "Paul Bergstedt" <Paul@.nospam.com> wrote in message
> news:uLmmgm4XEHA.3664@.TK2MSFTNGP12.phx.gbl...
> > When I change one of my job owners on a job that does a simple select,
> from
> > sa to a domain account, the job fails giving me the following error:
> >
> > Could not obtain information about Windows NT group/user
'MyDomain\ADUser'
> > Error 8198.
> >
> > I verified this login was a part of the Pre-Windows 2000 Compatible
Access
> > Group (kb 241643). Next I tried using xp_logininfo with this login, and
I
> > got the same error. Then I took out the select from the xp and ran it
> > separately (select distinct domain+N'\'+name, sid, sidtype from
> > OpenRowset(NetUserGetGroups, 'mydomain\aduser') and got the same error.
> > When I ran the above select statement with unknow domain\login, I got
the
> > same error.
> >
> > Any help would be appreciated.
> >
> > Paul
> >
> >
>

Error when changing job owner

When I change one of my job owners on a job that does a simple select, from
sa to a domain account, the job fails giving me the following error:
Could not obtain information about Windows NT group/user 'MyDomain\ADUser'
Error 8198.
I verified this login was a part of the Pre-Windows 2000 Compatible Access
Group (kb 241643). Next I tried using xp_logininfo with this login, and I
got the same error. Then I took out the select from the xp and ran it
separately (select distinct domain+N'\'+name, sid, sidtype from
OpenRowset(NetUserGetGroups, 'mydomain\aduser') and got the same error.
When I ran the above select statement with unknow domain\login, I got the
same error.
Any help would be appreciated.
PaulYou might want to have a look at
How to troubleshoot a SQL Server 8198 error
http://support.microsoft.com/defaul...kb;en-us;834124
and
FIX: You Receive an Error Message When the xp_logininfo Extended Stored
Procedure Runs
http://support.microsoft.com/default.aspx?kbid=830596
Also make sure you are on the latest windows service pack
HTH
Jasper Smith (SQL Server MVP)
http://www.sqldbatips.com
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
"Paul Bergstedt" <Paul@.nospam.com> wrote in message
news:uLmmgm4XEHA.3664@.TK2MSFTNGP12.phx.gbl...
> When I change one of my job owners on a job that does a simple select,
from
> sa to a domain account, the job fails giving me the following error:
> Could not obtain information about Windows NT group/user 'MyDomain\ADUser'
> Error 8198.
> I verified this login was a part of the Pre-Windows 2000 Compatible Access
> Group (kb 241643). Next I tried using xp_logininfo with this login, and I
> got the same error. Then I took out the select from the xp and ran it
> separately (select distinct domain+N''+name, sid, sidtype from
> OpenRowset(NetUserGetGroups, 'mydomain\aduser') and got the same error.
> When I ran the above select statement with unknow domain\login, I got the
> same error.
> Any help would be appreciated.
> Paul
>|||After trying everying under the sun, I tried putting the server name into
the Pre-Windows 2000 Access Group, and that fixed the problem. I got this
idea after noticing that the service account that the SQL Server services
ran under was the local System Account. I would imagine if I were running
the services under a domain account that it too would need to be added. I
have a case open with Microsoft on this, so I will ask them to suggest
putting this info into the KB article listed below.
Paul
"Jasper Smith" <jasper_smith9@.hotmail.com> wrote in message
news:eybsju6XEHA.1764@.TK2MSFTNGP10.phx.gbl...
> You might want to have a look at
> How to troubleshoot a SQL Server 8198 error
> http://support.microsoft.com/defaul...kb;en-us;834124
> and
> FIX: You Receive an Error Message When the xp_logininfo Extended Stored
> Procedure Runs
> http://support.microsoft.com/default.aspx?kbid=830596
> Also make sure you are on the latest windows service pack
> --
> HTH
> Jasper Smith (SQL Server MVP)
> http://www.sqldbatips.com
> I support PASS - the definitive, global
> community for SQL Server professionals -
> http://www.sqlpass.org
> "Paul Bergstedt" <Paul@.nospam.com> wrote in message
> news:uLmmgm4XEHA.3664@.TK2MSFTNGP12.phx.gbl...
> from
'MyDomain\ADUser'[vbcol=seagreen]
Access[vbcol=seagreen]
I[vbcol=seagreen]
the[vbcol=seagreen]
>

Friday, March 9, 2012

Error Viewing the Execution option of a Report

I select the option execution from a report (it's in properties option) and then raise an error which says An internal error occurred on the report server. See the error log for more details. (rsInternalError) Get Online Help

EXECUTE permission denied on object 'xp_sqlagent_notify', database 'mssqlsystemresource', schema 'sys'.

I have full privileges in the DB and I think the report server is well configured. This is happening since I reinstalled all the system (including windows). Any ideas?

I think you would need to grant permissions to SQL Agent stored procedures that Reporting services use. Here is the list from our installation script:

USE master

GO

GRANT EXECUTE ON master.dbo.xp_sqlagent_notify TO RSExecRole

GO

GRANT EXECUTE ON master.dbo.xp_sqlagent_enum_jobs TO RSExecRole

GO

GRANT EXECUTE ON master.dbo.xp_sqlagent_is_starting TO RSExecRole

GO

USE msdb

GO

-- Permissions for SQL Agent SP's

GRANT EXECUTE ON msdb.dbo.sp_help_category TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_add_category TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_add_job TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_add_jobserver TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_add_jobstep TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_add_jobschedule TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_help_job TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_delete_job TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_help_jobschedule TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_verify_job_identifiers TO RSExecRole

GO

GRANT SELECT ON msdb.dbo.sysjobs TO RSExecRole

GO

GRANT SELECT ON msdb.dbo.syscategories TO RSExecRole

GO

|||I'm seeing that i'm not have RsExecRole. If there is something wrong with my installation of RS, or the RS DB? Any one have an idea if I have to create a SQL group and then run the script above?|||Yes, you have to create a role called RsExecRole in ReportServer, ReportServerTempDB, master and msdb.
You probably have it in ReportServer and ReportServerTempDB if you backed up your database and restored it on a new SQL server.

Thanks
Tudor|||Yeeeees. You were right. I created the roles in master and in msdb. Because it was already in RS DB (I restore those DB). After that I executed the script you gave me and that's all.
Thank you
VectorR3|||

Hi,

we have the same error for a scheduled subscription report. when we run the report normally it works

I applied the script but still getting the same error. any idea?

Thanks
Bava

|||I was unable to subscribe to reports and this solved my problem. Thanks for your help.

John Cutsinger
Altegris|||This also solved the problem for me. Thanks!

|||

Thanks for the post.. i got the same error and was able to solve it thanks to Tudor

|||

Hi. I am very much having this error, and it doesn't want to go away!

I have the RsExecRole role on all 4 the DB's. It was already there.

I ran your scripts, but still getting the error. I changed the DB owner of my ReportServer$SQL2005 and ReportServer$SQL2005TempDB DB's from my domain administrator to the sa user, which is the user I use in my report's datasource to connect to the DB. Still it doesn't work.

I am quite fedup with this thing now. Spent most of the day on it with no progress.

Any help / tips will be supremely appreciated.

Error Viewing the Execution option of a Report

I select the option execution from a report (it's in properties option) and then raise an error which says An internal error occurred on the report server. See the error log for more details. (rsInternalError) Get Online Help

EXECUTE permission denied on object 'xp_sqlagent_notify', database 'mssqlsystemresource', schema 'sys'.

I have full privileges in the DB and I think the report server is well configured. This is happening since I reinstalled all the system (including windows). Any ideas?

I think you would need to grant permissions to SQL Agent stored procedures that Reporting services use. Here is the list from our installation script:

USE master

GO

GRANT EXECUTE ON master.dbo.xp_sqlagent_notify TO RSExecRole

GO

GRANT EXECUTE ON master.dbo.xp_sqlagent_enum_jobs TO RSExecRole

GO

GRANT EXECUTE ON master.dbo.xp_sqlagent_is_starting TO RSExecRole

GO

USE msdb

GO

-- Permissions for SQL Agent SP's

GRANT EXECUTE ON msdb.dbo.sp_help_category TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_add_category TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_add_job TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_add_jobserver TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_add_jobstep TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_add_jobschedule TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_help_job TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_delete_job TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_help_jobschedule TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_verify_job_identifiers TO RSExecRole

GO

GRANT SELECT ON msdb.dbo.sysjobs TO RSExecRole

GO

GRANT SELECT ON msdb.dbo.syscategories TO RSExecRole

GO

|||I'm seeing that i'm not have RsExecRole. If there is something wrong with my installation of RS, or the RS DB? Any one have an idea if I have to create a SQL group and then run the script above?|||Yes, you have to create a role called RsExecRole in ReportServer, ReportServerTempDB, master and msdb.
You probably have it in ReportServer and ReportServerTempDB if you backed up your database and restored it on a new SQL server.

Thanks
Tudor|||Yeeeees. You were right. I created the roles in master and in msdb. Because it was already in RS DB (I restore those DB). After that I executed the script you gave me and that's all.
Thank you
VectorR3|||

Hi,

we have the same error for a scheduled subscription report. when we run the report normally it works

I applied the script but still getting the same error. any idea?

Thanks
Bava

|||I was unable to subscribe to reports and this solved my problem. Thanks for your help.

John Cutsinger
Altegris|||This also solved the problem for me. Thanks!|||

Thanks for the post.. i got the same error and was able to solve it thanks to Tudor

|||

Hi. I am very much having this error, and it doesn't want to go away!

I have the RsExecRole role on all 4 the DB's. It was already there.

I ran your scripts, but still getting the error. I changed the DB owner of my ReportServer$SQL2005 and ReportServer$SQL2005TempDB DB's from my domain administrator to the sa user, which is the user I use in my report's datasource to connect to the DB. Still it doesn't work.

I am quite fedup with this thing now. Spent most of the day on it with no progress.

Any help / tips will be supremely appreciated.

Error Viewing the Execution option of a Report

I select the option execution from a report (it's in properties option) and then raise an error which says An internal error occurred on the report server. See the error log for more details. (rsInternalError) Get Online Help

EXECUTE permission denied on object 'xp_sqlagent_notify', database 'mssqlsystemresource', schema 'sys'.

I have full privileges in the DB and I think the report server is well configured. This is happening since I reinstalled all the system (including windows). Any ideas?

I think you would need to grant permissions to SQL Agent stored procedures that Reporting services use. Here is the list from our installation script:

USE master

GO

GRANT EXECUTE ON master.dbo.xp_sqlagent_notify TO RSExecRole

GO

GRANT EXECUTE ON master.dbo.xp_sqlagent_enum_jobs TO RSExecRole

GO

GRANT EXECUTE ON master.dbo.xp_sqlagent_is_starting TO RSExecRole

GO

USE msdb

GO

-- Permissions for SQL Agent SP's

GRANT EXECUTE ON msdb.dbo.sp_help_category TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_add_category TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_add_job TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_add_jobserver TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_add_jobstep TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_add_jobschedule TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_help_job TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_delete_job TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_help_jobschedule TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_verify_job_identifiers TO RSExecRole

GO

GRANT SELECT ON msdb.dbo.sysjobs TO RSExecRole

GO

GRANT SELECT ON msdb.dbo.syscategories TO RSExecRole

GO

|||I'm seeing that i'm not have RsExecRole. If there is something wrong with my installation of RS, or the RS DB? Any one have an idea if I have to create a SQL group and then run the script above?|||Yes, you have to create a role called RsExecRole in ReportServer, ReportServerTempDB, master and msdb.
You probably have it in ReportServer and ReportServerTempDB if you backed up your database and restored it on a new SQL server.

Thanks
Tudor|||Yeeeees. You were right. I created the roles in master and in msdb. Because it was already in RS DB (I restore those DB). After that I executed the script you gave me and that's all.
Thank you
VectorR3|||

Hi,

we have the same error for a scheduled subscription report. when we run the report normally it works

I applied the script but still getting the same error. any idea?

Thanks
Bava

|||I was unable to subscribe to reports and this solved my problem. Thanks for your help.

John Cutsinger
Altegris|||This also solved the problem for me. Thanks!|||

Thanks for the post.. i got the same error and was able to solve it thanks to Tudor

|||

Hi. I am very much having this error, and it doesn't want to go away!

I have the RsExecRole role on all 4 the DB's. It was already there.

I ran your scripts, but still getting the error. I changed the DB owner of my ReportServer$SQL2005 and ReportServer$SQL2005TempDB DB's from my domain administrator to the sa user, which is the user I use in my report's datasource to connect to the DB. Still it doesn't work.

I am quite fedup with this thing now. Spent most of the day on it with no progress.

Any help / tips will be supremely appreciated.

Error Viewing the Execution option of a Report

I select the option execution from a report (it's in properties option) and then raise an error which says An internal error occurred on the report server. See the error log for more details. (rsInternalError) Get Online Help

EXECUTE permission denied on object 'xp_sqlagent_notify', database 'mssqlsystemresource', schema 'sys'.

I have full privileges in the DB and I think the report server is well configured. This is happening since I reinstalled all the system (including windows). Any ideas?

I think you would need to grant permissions to SQL Agent stored procedures that Reporting services use. Here is the list from our installation script:

USE master

GO

GRANT EXECUTE ON master.dbo.xp_sqlagent_notify TO RSExecRole

GO

GRANT EXECUTE ON master.dbo.xp_sqlagent_enum_jobs TO RSExecRole

GO

GRANT EXECUTE ON master.dbo.xp_sqlagent_is_starting TO RSExecRole

GO

USE msdb

GO

-- Permissions for SQL Agent SP's

GRANT EXECUTE ON msdb.dbo.sp_help_category TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_add_category TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_add_job TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_add_jobserver TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_add_jobstep TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_add_jobschedule TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_help_job TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_delete_job TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_help_jobschedule TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_verify_job_identifiers TO RSExecRole

GO

GRANT SELECT ON msdb.dbo.sysjobs TO RSExecRole

GO

GRANT SELECT ON msdb.dbo.syscategories TO RSExecRole

GO

|||I'm seeing that i'm not have RsExecRole. If there is something wrong with my installation of RS, or the RS DB? Any one have an idea if I have to create a SQL group and then run the script above?|||Yes, you have to create a role called RsExecRole in ReportServer, ReportServerTempDB, master and msdb.
You probably have it in ReportServer and ReportServerTempDB if you backed up your database and restored it on a new SQL server.

Thanks
Tudor|||Yeeeees. You were right. I created the roles in master and in msdb. Because it was already in RS DB (I restore those DB). After that I executed the script you gave me and that's all.
Thank you
VectorR3|||

Hi,

we have the same error for a scheduled subscription report. when we run the report normally it works

I applied the script but still getting the same error. any idea?

Thanks
Bava

|||I was unable to subscribe to reports and this solved my problem. Thanks for your help.

John Cutsinger
Altegris|||This also solved the problem for me. Thanks!|||

Thanks for the post.. i got the same error and was able to solve it thanks to Tudor

|||

Hi. I am very much having this error, and it doesn't want to go away!

I have the RsExecRole role on all 4 the DB's. It was already there.

I ran your scripts, but still getting the error. I changed the DB owner of my ReportServer$SQL2005 and ReportServer$SQL2005TempDB DB's from my domain administrator to the sa user, which is the user I use in my report's datasource to connect to the DB. Still it doesn't work.

I am quite fedup with this thing now. Spent most of the day on it with no progress.

Any help / tips will be supremely appreciated.

Error Viewing the Execution option of a Report

I select the option execution from a report (it's in properties option) and then raise an error which says An internal error occurred on the report server. See the error log for more details. (rsInternalError) Get Online Help

EXECUTE permission denied on object 'xp_sqlagent_notify', database 'mssqlsystemresource', schema 'sys'.

I have full privileges in the DB and I think the report server is well configured. This is happening since I reinstalled all the system (including windows). Any ideas?

I think you would need to grant permissions to SQL Agent stored procedures that Reporting services use. Here is the list from our installation script:

USE master

GO

GRANT EXECUTE ON master.dbo.xp_sqlagent_notify TO RSExecRole

GO

GRANT EXECUTE ON master.dbo.xp_sqlagent_enum_jobs TO RSExecRole

GO

GRANT EXECUTE ON master.dbo.xp_sqlagent_is_starting TO RSExecRole

GO

USE msdb

GO

-- Permissions for SQL Agent SP's

GRANT EXECUTE ON msdb.dbo.sp_help_category TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_add_category TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_add_job TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_add_jobserver TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_add_jobstep TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_add_jobschedule TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_help_job TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_delete_job TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_help_jobschedule TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_verify_job_identifiers TO RSExecRole

GO

GRANT SELECT ON msdb.dbo.sysjobs TO RSExecRole

GO

GRANT SELECT ON msdb.dbo.syscategories TO RSExecRole

GO

|||I'm seeing that i'm not have RsExecRole. If there is something wrong with my installation of RS, or the RS DB? Any one have an idea if I have to create a SQL group and then run the script above?|||Yes, you have to create a role called RsExecRole in ReportServer, ReportServerTempDB, master and msdb.
You probably have it in ReportServer and ReportServerTempDB if you backed up your database and restored it on a new SQL server.

Thanks
Tudor|||Yeeeees. You were right. I created the roles in master and in msdb. Because it was already in RS DB (I restore those DB). After that I executed the script you gave me and that's all.
Thank you
VectorR3|||

Hi,

we have the same error for a scheduled subscription report. when we run the report normally it works

I applied the script but still getting the same error. any idea?

Thanks
Bava

|||I was unable to subscribe to reports and this solved my problem. Thanks for your help.

John Cutsinger
Altegris|||This also solved the problem for me. Thanks!|||

Thanks for the post.. i got the same error and was able to solve it thanks to Tudor

|||

Hi. I am very much having this error, and it doesn't want to go away!

I have the RsExecRole role on all 4 the DB's. It was already there.

I ran your scripts, but still getting the error. I changed the DB owner of my ReportServer$SQL2005 and ReportServer$SQL2005TempDB DB's from my domain administrator to the sa user, which is the user I use in my report's datasource to connect to the DB. Still it doesn't work.

I am quite fedup with this thing now. Spent most of the day on it with no progress.

Any help / tips will be supremely appreciated.

Error Viewing the Execution option of a Report

I select the option execution from a report (it's in properties option) and then raise an error which says An internal error occurred on the report server. See the error log for more details. (rsInternalError) Get Online Help

EXECUTE permission denied on object 'xp_sqlagent_notify', database 'mssqlsystemresource', schema 'sys'.

I have full privileges in the DB and I think the report server is well configured. This is happening since I reinstalled all the system (including windows). Any ideas?

I think you would need to grant permissions to SQL Agent stored procedures that Reporting services use. Here is the list from our installation script:

USE master

GO

GRANT EXECUTE ON master.dbo.xp_sqlagent_notify TO RSExecRole

GO

GRANT EXECUTE ON master.dbo.xp_sqlagent_enum_jobs TO RSExecRole

GO

GRANT EXECUTE ON master.dbo.xp_sqlagent_is_starting TO RSExecRole

GO

USE msdb

GO

-- Permissions for SQL Agent SP's

GRANT EXECUTE ON msdb.dbo.sp_help_category TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_add_category TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_add_job TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_add_jobserver TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_add_jobstep TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_add_jobschedule TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_help_job TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_delete_job TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_help_jobschedule TO RSExecRole

GO

GRANT EXECUTE ON msdb.dbo.sp_verify_job_identifiers TO RSExecRole

GO

GRANT SELECT ON msdb.dbo.sysjobs TO RSExecRole

GO

GRANT SELECT ON msdb.dbo.syscategories TO RSExecRole

GO

|||I'm seeing that i'm not have RsExecRole. If there is something wrong with my installation of RS, or the RS DB? Any one have an idea if I have to create a SQL group and then run the script above?|||Yes, you have to create a role called RsExecRole in ReportServer, ReportServerTempDB, master and msdb.
You probably have it in ReportServer and ReportServerTempDB if you backed up your database and restored it on a new SQL server.

Thanks
Tudor|||Yeeeees. You were right. I created the roles in master and in msdb. Because it was already in RS DB (I restore those DB). After that I executed the script you gave me and that's all.

Thank you

VectorR3|||

Hi,

we have the same error for a scheduled subscription report. when we run the report normally it works

I applied the script but still getting the same error. any idea?

Thanks
Bava

|||I was unable to subscribe to reports and this solved my problem. Thanks for your help.

John Cutsinger
Altegris|||This also solved the problem for me. Thanks!

|||

Thanks for the post.. i got the same error and was able to solve it thanks to Tudor

Wednesday, March 7, 2012

Error using non-ANSI Joins (Was "Ansi")

Hi everyone.. can anyone help me on how to solve my problem regarding on Select.. im using PB6.5 and running on MSSLQ2005 database.. i attached an image for your reference.. thnks!Moving to SQL Server|||Hi everyone.. can anyone help me on how to solve my problem regarding on Select
Sure: simply follow the recommendation given in the error message: change the compatibility level of your database

You can either do that in the enterprise manager or through a stored procedure.
Check the manual for details|||Ok thnks for the advise ill try to do that.. the original program is running in a MSSQL2000 then i tried to run it in MSSQL2005. i think that the code was not supported in MSSQL2005, is that right??|||=* is no longer supported. I would rewrite the query to use the ansi syntax.|||I would rewrite the query to use the ansi syntax.

thats great thnks!

Error using MAX() - linked server to Orcl

I have a linked server to an Oracle 9 db using MS OLE DB Provider for Orcl.
When I query "select MAX(IntColumn) from ..." I get the error below when
IntColumn is NUMBER(5) or NUMBER(38) in Orcl, but not when it is NUMBER(9).
No error for simple "select IntColumn from ..." on same tables.
The problem appeared only after SQL 2000 was uninstalled and reinstalled.
The problem persisted after reapplying SP3 for both SQL and for AS.
Also uninstalled/re-installed Orcl 9 client.
I can get around the problem, but I would like to know what DLL/component
got out of sync with all the uninstall/reinstalling.
Thanks,
Les McPheeI should have added details of the error I get...
OLE DB Provider 'MSDAORA" reported an error.
[OLE/DB provider returned message: ORA-01455: converting column overflows
integer datatype]
"lmcphee" wrote:

> I have a linked server to an Oracle 9 db using MS OLE DB Provider for Orcl
.
> When I query "select MAX(IntColumn) from ..." I get the error below when
> IntColumn is NUMBER(5) or NUMBER(38) in Orcl, but not when it is NUMBER(9)
.
> No error for simple "select IntColumn from ..." on same tables.
> The problem appeared only after SQL 2000 was uninstalled and reinstalled.
> The problem persisted after reapplying SP3 for both SQL and for AS.
> Also uninstalled/re-installed Orcl 9 client.
> I can get around the problem, but I would like to know what DLL/component
> got out of sync with all the uninstall/reinstalling.
> Thanks,
> Les McPhee

Error using EM to view data

Hi,
I have a rather annoying problem with enterprise manager. When I select
Open Table, then Select All Rows . or Select Top . I get the following error
from EM:
Provider cannot be found. It may not be properly installed.
This started a few days ago for no apparent reason. The problem seems to be
limited to my machine, and happens if I access the local data store (MSDE)
or that on other servers (full SQL Sever, ent. ed.). I'm running Win2k
(SP4) and the client tools I'm running are from SQL Server 2000 enterprise
edition (SP3).
All other functions seem to work in EM (such as creating / modifying tables,
etc), and I can access data through other applications on this machine (such
as Query Analyzer, VS.Net, etc).
Things I have tried include reinstalling the latest MDAC (2.8), uninstalling
and reinstalling SQL Server client tools + sp3, and using regsvr32 to
reregister some DLLs suggested in other postings.
One last thing - using Profiler and a different workstation, I noticed that
the Open Table, Select all rows. function starts a new application with a
separate login (the app name is listed as "MS SQLEM - Data Tools"). Does
anyone know anything about this?
TIA for any help anyone can provide.
-DH
I found the solution for this and I am posting it for the common good...
Using filemon and regmon (from sysinternals, nice products), I saw that MMC
was trying to use an old version
of the file msdasql.dll in winnt\system32 rather than the version MDAC
installed in
Program Files\Common Files\System\Ole DB
Using regsvr32 to unregister then re-register the newer file fixed the
problem. Since this file is part of MDAC, I would
have thought that reinsalling MDAC should have fixed the problem, but it
didn't. Ditto for SP4 for Win2k.
I hope this helps someone somewhere someday. -DH
"David Howard" <reply@.to.group> wrote in message
news:UvC8c.290$yN6.61@.newsread2.news.atl.earthlink .net...
> Hi,
> I have a rather annoying problem with enterprise manager. When I select
> Open Table, then Select All Rows . or Select Top . I get the following
error
> from EM:
> Provider cannot be found. It may not be properly installed.
>
> This started a few days ago for no apparent reason. The problem seems to
be
> limited to my machine, and happens if I access the local data store (MSDE)
> or that on other servers (full SQL Sever, ent. ed.). I'm running Win2k
> (SP4) and the client tools I'm running are from SQL Server 2000 enterprise
> edition (SP3).
>
> All other functions seem to work in EM (such as creating / modifying
tables,
> etc), and I can access data through other applications on this machine
(such
> as Query Analyzer, VS.Net, etc).
>
> Things I have tried include reinstalling the latest MDAC (2.8),
uninstalling
> and reinstalling SQL Server client tools + sp3, and using regsvr32 to
> reregister some DLLs suggested in other postings.
>
> One last thing - using Profiler and a different workstation, I noticed
that
> the Open Table, Select all rows. function starts a new application with a
> separate login (the app name is listed as "MS SQLEM - Data Tools"). Does
> anyone know anything about this?
>
> TIA for any help anyone can provide.
> -DH
>
|||It helped me, today.
Thanks a lot for your effort to solve this.
Andrew Arace

Error using EM to view data

Hi,
I have a rather annoying problem with enterprise manager. When I select
Open Table, then Select All Rows . or Select Top . I get the following error
from EM:
Provider cannot be found. It may not be properly installed.
This started a few days ago for no apparent reason. The problem seems to be
limited to my machine, and happens if I access the local data store (MSDE)
or that on other servers (full SQL Sever, ent. ed.). I'm running Win2k
(SP4) and the client tools I'm running are from SQL Server 2000 enterprise
edition (SP3).
All other functions seem to work in EM (such as creating / modifying tables,
etc), and I can access data through other applications on this machine (such
as Query Analyzer, VS.Net, etc).
Things I have tried include reinstalling the latest MDAC (2.8), uninstalling
and reinstalling SQL Server client tools + sp3, and using regsvr32 to
reregister some DLLs suggested in other postings.
One last thing - using Profiler and a different workstation, I noticed that
the Open Table, Select all rows. function starts a new application with a
separate login (the app name is listed as "MS SQLEM - Data Tools"). Does
anyone know anything about this?
TIA for any help anyone can provide.
-DHI found the solution for this and I am posting it for the common good...
Using filemon and regmon (from sysinternals, nice products), I saw that MMC
was trying to use an old version
of the file msdasql.dll in winnt\system32 rather than the version MDAC
installed in
Program Files\Common Files\System\Ole DB
Using regsvr32 to unregister then re-register the newer file fixed the
problem. Since this file is part of MDAC, I would
have thought that reinsalling MDAC should have fixed the problem, but it
didn't. Ditto for SP4 for Win2k.
I hope this helps someone somewhere someday. -DH
"David Howard" <reply@.to.group> wrote in message
news:UvC8c.290$yN6.61@.newsread2.news.atl.earthlink.net...
> Hi,
> I have a rather annoying problem with enterprise manager. When I select
> Open Table, then Select All Rows . or Select Top . I get the following
error
> from EM:
> Provider cannot be found. It may not be properly installed.
>
> This started a few days ago for no apparent reason. The problem seems to
be
> limited to my machine, and happens if I access the local data store (MSDE)
> or that on other servers (full SQL Sever, ent. ed.). I'm running Win2k
> (SP4) and the client tools I'm running are from SQL Server 2000 enterprise
> edition (SP3).
>
> All other functions seem to work in EM (such as creating / modifying
tables,
> etc), and I can access data through other applications on this machine
(such
> as Query Analyzer, VS.Net, etc).
>
> Things I have tried include reinstalling the latest MDAC (2.8),
uninstalling
> and reinstalling SQL Server client tools + sp3, and using regsvr32 to
> reregister some DLLs suggested in other postings.
>
> One last thing - using Profiler and a different workstation, I noticed
that
> the Open Table, Select all rows. function starts a new application with a
> separate login (the app name is listed as "MS SQLEM - Data Tools"). Does
> anyone know anything about this?
>
> TIA for any help anyone can provide.
> -DH
>|||It helped me, today.
Thanks a lot for your effort to solve this.
Andrew Arace

error using dbms.sql

Hello:
I have a table with two of the fiedls that are tables_names. I need to use then to select some data and insert in another table. The error is the following:
Procedure created.

No errors.
SQL> exec readtable('state_relation')
BEGIN readtable('state_relation'); END;

*
ERROR at line 1:
ORA-00905: missing keyword
ORA-06512: at "CHADBA.READTABLE", line 78
ORA-06512: at line

The code is the following:

set serveroutput on size 1000000

CREATE OR REPLACE PROCEDURE readtable ( source IN VARCHAR2) IS

v_tablename varchar2(30);
v_tablekey varchar2(30);
fccid number;
name varchar2(30);
state varchar2(2);
strsql varchar2(1000);
numrows number;
averageleng number;
bytes number;
countreg number;
countbytes number;
cursor1 INTEGER;
cursor2 INTEGER;
ignore INTEGER;
BEGIN

-- OPEN CURSOR
cursor1 := dbms_sql.open_cursor;
-- PREPARE PARSE
DBMS_SQL.PARSE(cursor1,
'SELECT table_name, table_key into v_tablename,v_tablekey FROM ' || source,
DBMS_SQL.native);
-- use bind variables? No
-- use query ? yes
-- Define colmna
DBMS_SQL.DEFINE_COLUMN(cursor1, 1, v_tablename,30);
DBMS_SQL.DEFINE_COLUMN(cursor1, 2, v_tablekey,30);
-- execute
ignore := DBMS_SQL.EXECUTE(cursor1);

-- Prepare cursor for read and insert in other table
cursor2 := DBMS_SQL.OPEN_CURSOR;
strsql := ' SELECT DISTINCT '
|| ' l.bill_fccid '
|| ' l.name'
|| ' count(l.svcing_st) '
|| ' from '
|| 'v_tablekey l'
|| 'v_tablename m'
|| ' where '
|| 'l.bill_fccid'
|| ' = '
|| 'm.bill_fccid'
|| 'group by '
|| ' l.bill_fccid'
|| 'l.name';

-- Parse cursor2
DBMS_SQL.PARSE(cursor2,strsql,DBMS_SQL.native);

-- fetch_rows
LOOP
IF DBMS_SQL.FETCH_ROWS(cursor1) > 0 THEN
-- get column values of the row
DBMS_SQL.COLUMN_VALUE(cursor1, 1, v_tablename);
DBMS_SQL.COLUMN_VALUE(cursor1, 2, v_tablekey);

ignore := DBMS_SQL.EXECUTE(cursor2);
ELSE
-- No more rows to read
EXIT;
END IF;
END LOOP;

DBMS_SQL.CLOSE_CURSOR(cursor1);
DBMS_SQL.CLOSE_CURSOR(cursor2);
EXCEPTION
WHEN OTHERS THEN
IF DBMS_SQL.IS_OPEN(cursor1) THEN
DBMS_SQL.CLOSE_CURSOR(cursor1);
END IF;
IF DBMS_SQL.IS_OPEN(cursor2) THEN
DBMS_SQL.CLOSE_CURSOR(cursor2);
END IF;
RAISE;
END readtable;
/
show errors;
Can some body help me? Thanks in advanceRemove "into v_tablename,v_tablekey" where you are parsing the sql. You are already defining the columns, hence dont need the into clause.

Here is the correct stmt :
DBMS_SQL.PARSE(cursor1, 'SELECT table_name, table_key FROM ' || source, DBMS_SQL.native);

Originally posted by nelari
Hello:
I have a table with two of the fiedls that are tables_names. I need to use then to select some data and insert in another table. The error is the following:
Procedure created.

No errors.
SQL> exec readtable('state_relation')
BEGIN readtable('state_relation'); END;

*
ERROR at line 1:
ORA-00905: missing keyword
ORA-06512: at "CHADBA.READTABLE", line 78
ORA-06512: at line

The code is the following:

set serveroutput on size 1000000

CREATE OR REPLACE PROCEDURE readtable ( source IN VARCHAR2) IS

v_tablename varchar2(30);
v_tablekey varchar2(30);
fccid number;
name varchar2(30);
state varchar2(2);
strsql varchar2(1000);
numrows number;
averageleng number;
bytes number;
countreg number;
countbytes number;
cursor1 INTEGER;
cursor2 INTEGER;
ignore INTEGER;
BEGIN

-- OPEN CURSOR
cursor1 := dbms_sql.open_cursor;
-- PREPARE PARSE
DBMS_SQL.PARSE(cursor1,
'SELECT table_name, table_key into v_tablename,v_tablekey FROM ' || source,
DBMS_SQL.native);
-- use bind variables? No
-- use query ? yes
-- Define colmna
DBMS_SQL.DEFINE_COLUMN(cursor1, 1, v_tablename,30);
DBMS_SQL.DEFINE_COLUMN(cursor1, 2, v_tablekey,30);
-- execute
ignore := DBMS_SQL.EXECUTE(cursor1);

-- Prepare cursor for read and insert in other table
cursor2 := DBMS_SQL.OPEN_CURSOR;
strsql := ' SELECT DISTINCT '
|| ' l.bill_fccid '
|| ' l.name'
|| ' count(l.svcing_st) '
|| ' from '
|| 'v_tablekey l'
|| 'v_tablename m'
|| ' where '
|| 'l.bill_fccid'
|| ' = '
|| 'm.bill_fccid'
|| 'group by '
|| ' l.bill_fccid'
|| 'l.name';

-- Parse cursor2
DBMS_SQL.PARSE(cursor2,strsql,DBMS_SQL.native);

-- fetch_rows
LOOP
IF DBMS_SQL.FETCH_ROWS(cursor1) > 0 THEN
-- get column values of the row
DBMS_SQL.COLUMN_VALUE(cursor1, 1, v_tablename);
DBMS_SQL.COLUMN_VALUE(cursor1, 2, v_tablekey);

ignore := DBMS_SQL.EXECUTE(cursor2);
ELSE
-- No more rows to read
EXIT;
END IF;
END LOOP;

DBMS_SQL.CLOSE_CURSOR(cursor1);
DBMS_SQL.CLOSE_CURSOR(cursor2);
EXCEPTION
WHEN OTHERS THEN
IF DBMS_SQL.IS_OPEN(cursor1) THEN
DBMS_SQL.CLOSE_CURSOR(cursor1);
END IF;
IF DBMS_SQL.IS_OPEN(cursor2) THEN
DBMS_SQL.CLOSE_CURSOR(cursor2);
END IF;
RAISE;
END readtable;
/
show errors;
Can some body help me? Thanks in advance|||Originally posted by dbmadcap
Remove "into v_tablename,v_tablekey" where you are parsing the sql. You are already defining the columns, hence dont need the into clause.

Here is the correct stmt :
DBMS_SQL.PARSE(cursor1, 'SELECT table_name, table_key FROM ' || source, DBMS_SQL.native);

Thank you for the answer but this is not the problem, I already change us you indicate and continues the same error. The error is with the two variables that i'm using for the second select.|||You have v_tablekey and v_tablename inside quotes. Change it as below :

strsql := ' SELECT DISTINCT '
|| ' l.bill_fccid '
|| ' l.name'
|| ' count(l.svcing_st) '
|| ' from '|| v_tablekey || ' l '
|| ' , '|| v_tablename || ' m '
|| ' where '
|| 'l.bill_fccid'
|| ' = '
|| 'm.bill_fccid'
|| 'group by '
|| ' l.bill_fccid'
|| 'l.name';

Also as a humble suggestion, try to form the string in fewer lines so that it will make easy for you to read & debug

Originally posted by nelari
Thank you for the answer but this is not the problem, I already change us you indicate and continues the same error. The error is with the two variables that i'm using for the second select.

Sunday, February 26, 2012

ERROR USING BULK INSERT

Hi
I'm executing
declare @.ARCHIVOidx varchar(300)
set @.ARCHIVOidx = (Select top 1 MyFile from task)
declare @.sentencia varchar(300)
set @.sentencia = 'bulk insert a from ''' + @.ARCHIVOidx+'''' + ' with
(formatfile ='''+'c:\input\bcpfmt.txt' + ''',batchsize=100) '
exec (@.sentencia)
and the SQL says:
Server: Msg 3624, Level 20, State 1, Line 1
Location: record.cpp:825
Expression: newColLen >= WideTextPointer::OVERHEAD
SPID: 51
Process ID: 3420
ODBC: Msg 0, Level 16, State 1
Communication link failure
Connection Broken
The event viewer says
18052 : Error: 3624, Severity: 20, State: 1.
THE machine has (SQL DEV):
WIN XP SP1 (Pentium 4), with 40 Gb HD (free 10 Gb), Memory 512 Mb
SQL WITH SP3
What can I do?
Thanks a lot> exec (@.sentencia)
Change this to PRINT @.sentencia and see if what it yields makes sense, also
try executing this manually.|||ok
The output is:
bulk insert a from 'C:\input\bankAA.idx' with (formatfile
='c:\input\bcpfmt.txt',batchsize=100)
"Aaron Bertrand [SQL Server MVP]" wrote:

> Change this to PRINT @.sentencia and see if what it yields makes sense, als
o
> try executing this manually.
>
>|||The Sintax is OK.
The server inserts 600.000 records and generate error, however
using a smaller file it does not generate error. The original file has 2
million registries, the second 600,000 registries (with errors).
The Tsql generates error with the greatest archives
"Macisu" wrote:
> ok
> The output is:
> bulk insert a from 'C:\input\bankAA.idx' with (formatfile
> ='c:\input\bcpfmt.txt',batchsize=100)
>
> "Aaron Bertrand [SQL Server MVP]" wrote:
>|||Okay, now, what happened when you ran this command manually?
"Macisu" <Macisu@.discussions.microsoft.com> wrote in message
news:98CA0497-3E9A-4407-8628-9D51BBBE1434@.microsoft.com...
> ok
> The output is:
> bulk insert a from 'C:\input\bankAA.idx' with (formatfile
> ='c:\input\bcpfmt.txt',batchsize=100)
>
> "Aaron Bertrand [SQL Server MVP]" wrote:
>|||> The Sintax is OK.
I understand that. Which is why I suggested RUNNING the code, not just
looking at it.

> The server inserts 600.000 records and generate error, however
> using a smaller file it does not generate error.
So have you considered using the MAXERRORS parameter? Or cleaning the file
before builk inserting it? Obviously the one with errors in it is failing
because there are rows with errors.
By "smaller file" do you really mean "a file that does not happen to include
any rows that cause an error"?|||The command ran ok, the command generates error 6 mins after executing itsel
f,
when the table has 600.000 records aprox.
"Aaron Bertrand [SQL Server MVP]" wrote:

> Okay, now, what happened when you ran this command manually?
>
>
> "Macisu" <Macisu@.discussions.microsoft.com> wrote in message
> news:98CA0497-3E9A-4407-8628-9D51BBBE1434@.microsoft.com...
>
>|||> The command ran ok, the command generates error
Uh, could you be more specific?|||"Aaron Bertrand [SQL Server MVP]" wrote:

> Uh, could you be more specific?
>
>
the window output says
(100 row(s) affected)
(100 row(s) affected)
(100 row(s) affected)
(100 row(s) affected)
(100 row(s) affected)
(100 row(s) affected)
Server: Msg 3624, Level 20, State 1, Line 1
Location: record.cpp:825
Expression: newColLen >= WideTextPointer::OVERHEAD
SPID: 53
Process ID: 3420
ODBC: Msg 0, Level 16, State 1
Communication link failure
Connection Broken
Query batch completed with errors|||This may be a bug, but I have a couple of questions:
Can you post the format file?
Can you try MAXERRORS = 1 and also MAXERRORS = 100, and see if the
problem moves to a different place than around 600000 rows? (By
default, MAXERRORS is 10.)
Can you watch the computer's memory and virtual memory use to see if it
is going up and up to the max before the crash?
Steve Kass
Drew University
Macisu wrote:

>Hi
>I'm executing
>declare @.ARCHIVOidx varchar(300)
>set @.ARCHIVOidx = (Select top 1 MyFile from task)
>declare @.sentencia varchar(300)
>set @.sentencia = 'bulk insert a from ''' + @.ARCHIVOidx+'''' + ' with
>(formatfile ='''+'c:\input\bcpfmt.txt' + ''',batchsize=100) '
>exec (@.sentencia)
>and the SQL says:
>Server: Msg 3624, Level 20, State 1, Line 1
>Location: record.cpp:825
>Expression: newColLen >= WideTextPointer::OVERHEAD
>SPID: 51
>Process ID: 3420
>ODBC: Msg 0, Level 16, State 1
>Communication link failure
>Connection Broken
>
>The event viewer says
>18052 : Error: 3624, Severity: 20, State: 1.
>THE machine has (SQL DEV):
>WIN XP SP1 (Pentium 4), with 40 Gb HD (free 10 Gb), Memory 512 Mb
>SQL WITH SP3
>What can I do?
>Thanks a lot
>
>
>
>

Error Updating DB2 on MVS-MF from a Linked Server

Need to be able to run update queries on DB2 on IBM MF from a Linked Server. Select and Insert queries work but Update and Delete queries don't. DB2 connect is installed and ODBC System dsn's are created for DEV and Production DB2 environments.

The ODBC drivers can be selected when running Imports/Exports but can't be specified through a linked server.

Any Ideas?

Tom...

Linked Servers do not directly support ODBC drivers, but you can plug in ODBC drivers by using a OLE DB to ODBC bridge technology 'Microsoft OLE DB Provider for ODBC (MSDASQL)'. This componentships with MDAC but is not available on 64-bit at this time.

Although option would be to use Microsoft's DB2 OLE DB Provider directly with Linked Server available for download on http://www.microsoft.com/downloads/details.aspx?FamilyId=50b97994-8453-4998-8226-fa42ec403d17&DisplayLang=en

Microsoft OLEDB Provider for DB2

The Microsoft OLE DB Provider for DB2 is a COM component for integrating vital data stored in IBM DB2 databases with new solutions based on Microsoft SQL Server 2005 Enterprise Edition and Developer Edition. SQL Server developers and administrators can use the provider with Integration Services, Analysis Services, Replication, Reporting Services, and Distributed Query Processor. Run the self-extracting download package to create an installation folder. The single setup program will install the provider and tools on x86, x64, and IA64 computers. The package includes product updates in the form of an integrated Service Pack 1. Read the installation guide and Readme for more information.