Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

Execution of dynamic SQL

2 posts in Windows NT Last posting was on 2000-07-11 14:23:09.0Z
Scott Landers Posted on 2000-07-11 13:50:08.0Z
From: "Scott Landers" <scott770@bellsouth.net>
Subject: Execution of dynamic SQL
Date: Tue, 11 Jul 2000 08:50:08 -0500
Lines: 23
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2615.200
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200
Message-ID: <jNsy0C06$GA.70@forums.sybase.com>
Newsgroups: sybase.public.sqlserver.nt
NNTP-Posting-Host: 38.216.214.75
Path: forums-1-dub!forums-master.sybase.com!forums.sybase.com
Xref: forums-1-dub sybase.public.sqlserver.nt:1915
Article PK: 1089346

I have an SQL Statement that Inserts into database 'B' Select * from
Database 'A', where certain values are equal (INSERT INTO DatabaseB.Table1
Select * from DatabaseA.Table1, while connected to database A). I am
passing the name of DatabaseB into the stored procedure and concatenating it
into the SQL statement above. I then want to execute this statement. Can
someone point me in the correct direction? I do not want to hard code this
information. I would rather it be passed in through the stored procedure.
Your time is greatly appreciated!

Here is an example of what I am trying!

DECLARE @Statement varchar(255)
SELECT @Statement = 'INSERT INTO ASE013.dbo.ACCOUNT SELECT * FROM ACCOUNT
WHERE ACCOUNT + BUSINESS NOT IN(SELECT ACCOUNT + BUSINESS FROM
ASE013.dbo.ACCOUNT)'
EXEC @STATEMENT

Thank you!

Scott Landers
Solutions Plus, Inc.


Andy Price Posted on 2000-07-11 14:23:09.0Z
From: "Andy Price" <andy.price@canada.com>
References: <jNsy0C06$GA.70@forums.sybase.com>
Subject: Re: Execution of dynamic SQL
Date: Tue, 11 Jul 2000 15:23:09 +0100
Lines: 36
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4133.2400
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
Message-ID: <k8q7uS06$GA.203@forums.sybase.com>
Newsgroups: sybase.public.sqlserver.nt
NNTP-Posting-Host: dyn190-ras2.screaming.net 212.49.225.190
Path: forums-1-dub!forums-master.sybase.com!forums.sybase.com
Xref: forums-1-dub sybase.public.sqlserver.nt:1914
Article PK: 1089350

If you use v12, you can use the execute() statement, which is new for
executing dynamic SQL.

Andy

"Scott Landers" <scott770@bellsouth.net> wrote in message
news:jNsy0C06$GA.70@forums.sybase.com...
> I have an SQL Statement that Inserts into database 'B' Select * from
> Database 'A', where certain values are equal (INSERT INTO DatabaseB.Table1
> Select * from DatabaseA.Table1, while connected to database A). I am
> passing the name of DatabaseB into the stored procedure and concatenating
it
> into the SQL statement above. I then want to execute this statement. Can
> someone point me in the correct direction? I do not want to hard code
this
> information. I would rather it be passed in through the stored
procedure.
> Your time is greatly appreciated!
>
> Here is an example of what I am trying!
>
> DECLARE @Statement varchar(255)
> SELECT @Statement = 'INSERT INTO ASE013.dbo.ACCOUNT SELECT * FROM ACCOUNT
> WHERE ACCOUNT + BUSINESS NOT IN(SELECT ACCOUNT + BUSINESS FROM
> ASE013.dbo.ACCOUNT)'
> EXEC @STATEMENT
>
> Thank you!
>
> Scott Landers
> Solutions Plus, Inc.
>
>