Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

SQL script does not run within my ODBC session ?

 
   Database Help (Home) -> ODBC RSS
Next:  Error using old table() in UDF  
Author Message
Lothar Behrens

External


Since: Nov 08, 2008
Posts: 1



(Msg. 1) Posted: Sat Nov 08, 2008 6:07 am
Post subject: SQL script does not run within my ODBC session ?
Archived from groups: microsoft>public>sqlserver>odbc (more info?)

Hi,
if I execute the following script in SQL Management Studio (SQLServer
2005), then it works. But
when I use my ODBC application it fails.
Is there anything wrong with the script when using ODBC ?
Thanks a lot,
Lothar
CREATE PROCEDURE lbDMF_DropConstraint @Table VARCHAR(50), @Name
VARCHAR(50)
AS
BEGIN
DECLARE @Statement1 VARCHAR(200)
DECLARE hSqlProc CURSOR LOCAL FOR
SELECT 'ALTER TABLE ' + @Table + ' DROP CONSTRAINT ' +
pr.name
FROM sysobjects pr
WHERE pr.xtype IN ('F') AND upper(pr.name) =
upper(@Name)
OPEN hSqlProc
FETCH hSqlProc INTO @Statement1
WHILE (@@fetch_status = 0)
BEGIN
EXECUTE (@Statement1)
FETCH hSqlProc INTO @Statement1
END
CLOSE hSqlProc
DEALLOCATE hSqlProc
END;
CREATE PROCEDURE lbDMF_DropTable @Table VARCHAR(50)
AS
BEGIN
DECLARE @Statement2 VARCHAR(200)
DECLARE hSqlProc CURSOR LOCAL FOR
SELECT 'DROP TABLE ' + pr.name
FROM sysobjects pr
WHERE pr.xtype IN ('U') AND upper(pr.name) =
upper(@Table)
OPEN hSqlProc
FETCH hSqlProc INTO @Statement2
WHILE (@@fetch_status = 0)
BEGIN
EXECUTE (@Statement2)
FETCH hSqlProc INTO @Statement2
END
CLOSE hSqlProc
DEALLOCATE hSqlProc
END;
CREATE PROCEDURE lbDMF_DropProc @Name VARCHAR(50)
AS
BEGIN
DECLARE @Statement3 VARCHAR(200)
DECLARE hSqlProc CURSOR LOCAL FOR
SELECT 'DROP ' + case pr.xtype when
'P' then 'PROCEDURE ' else 'FUNCTION ' end +
pr.name
FROM sysobjects pr
WHERE pr.xtype IN ('P','FN','TF') AND upper(pr.name) =
upper(@Name)
OPEN hSqlProc
FETCH hSqlProc INTO @Statement3
WHILE (@@fetch_status = 0)
BEGIN
EXECUTE (@Statement3)
FETCH hSqlProc INTO @Statement3
END
CLOSE hSqlProc
DEALLOCATE hSqlProc
END;
-- Association TestSteps -> TestStepsDetail
exec lbDMF_DropConstraint 'TestStepsDetail',
'fk_TestStepsDetail_TestSteps_ID';
-- Class is TestStepsMSSQL
exec lbDMF_DropTable 'TestSteps';
CREATE TABLE "TestSteps" (
"ID" INTEGER IDENTITY (1, 1) NOT NULL,
PRIMARY KEY ("ID"),
"Spalte1" CHAR(100)
);
-- Class is TestStepsDetailMSSQL
exec lbDMF_DropTable 'TestStepsDetail';
CREATE TABLE "TestStepsDetail" (
"ID" INTEGER IDENTITY (1, 1) NOT NULL,
PRIMARY KEY ("ID"),
"Spalte1" CHAR(100)
);
-- Association TestStepsDetail -> TestSteps with name ''
ALTER TABLE "TestStepsDetail" ADD "TestSteps" INT;
ALTER TABLE "TestStepsDetail" ADD CONSTRAINT
"fk_TestStepsDetail_TestSteps_ID" FOREIGN KEY ( "TestSteps" )
REFERENCES "TestSteps" ( "ID" );
exec lbDMF_DropProc 'lbDMF_DropTable';
exec lbDMF_DropProc 'lbDMF_DropConstraint';
exec lbDMF_DropProc 'lbDMF_DropProc';
This are the errors after executing the script in my application:
lbDB.cpp, 3884: Error in lbQuery: (SQLExecDirect()) 42000: 156 -
[Microsoft][ODB
C SQL Server Driver][SQL Server]Falsche Syntax in der N©¥he des
'PROCEDURE'-Schl¡Ã
sselwortes.
lbDB.cpp, 3884: Error in lbQuery: (SQLExecDirect()) 42000: 156 -
[Microsoft][ODB
C SQL Server Driver][SQL Server]Falsche Syntax in der N©¥he des
'PROCEDURE'-Schl¡Ã
sselwortes.

 >> Stay informed about: SQL script does not run within my ODBC session ? 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
32 bit odbc - Will the 32 bit odbc driver available on Windows Clients Operating systems communicate to a 64 bit SQL Server on Itanium?

ODBC connection. - Hello I can create a ODBC connection to another database which is not SQL Server. But when I want to choose a Integration Service Destination connection I am not given any ODBC connection type. I would like to transfer and transform data from a SQL..

ODBC Over WAN - I have been told by our consultant that we cannot access our SQL Server over the WAN without corrupting our data, is this true? Thanks for any help, David

not able to use failover in odbc - hey When i try to create odbc connection, i wanted use the failover sqlserver if the primary server in not available. I have configured mirroring between the databases in primary and secondary servers. But, it is not enabled and looks grayed. Can yo...

ODBC connection - I have a DTS package that runs fine, but I can not view any of the transform data tasks. When ever I try to view them it just times out. The SQL connection I can view and edit fine, but not the ODBC. Even if I try to make a new ODBC connection, it..
   Database Help (Home) -> ODBC All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]