Hi,
I am trying to find out how to connect to a database, inside a stored
procedure...including identification (Username and passsword)?
I tried the CONNECT TO statement, but when I try to use it, I get the error:
[ODBC SQL Server Driver]Syntax Error or Access violation
I am using the connect to statemente this way:
Connect to {pc12.DB} User us.abc
DB= Databasename;
pc12= Servername;
us= Username;
abc= password
Can somebody tell me what is wrong with the way I use the connect statement
or tell me a better way to connect to databases?
ThanksCONNECT TO is IIRC only supported in Embedded SQL for C, not in stored
procedures and T-SQL.
If you are trying to connect to a database on the same server, you can just
access it by prefixing the tables etc with the database name and the owner
name in the form of:
SELECT some_column FROM other_database.dbo.some_table
If the database is on a different server, you can set up a linked server
(see BOL), and than add the server name to the select:
SELECT some_column FROM other_server.other_database.dbo.some_table
Jacco Schalkwijk
SQL Server MVP
"Albano Alves" <albano.alves@.vpconsulting.pt> wrote in message
news:eN6LxuKVFHA.2664@.TK2MSFTNGP15.phx.gbl...
> Hi,
> I am trying to find out how to connect to a database, inside a stored
> procedure...including identification (Username and passsword)?
> I tried the CONNECT TO statement, but when I try to use it, I get the
> error:
> [ODBC SQL Server Driver]Syntax Error or Access violation
> I am using the connect to statemente this way:
> Connect to {pc12.DB} User us.abc
> DB= Databasename;
> pc12= Servername;
> us= Username;
> abc= password
> Can somebody tell me what is wrong with the way I use the connect
> statement or tell me a better way to connect to databases?
> Thanks
>
Wednesday, March 7, 2012
Connection to a database
Labels:
connect,
connection,
database,
identification,
including,
inside,
microsoft,
mysql,
oracle,
passsword,
server,
sql,
storedprocedure,
username
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment