Re: tsql knowing which DB to default to
"Tony Baldarelli" <[email protected]>
| Newsgroups | gmane.comp.db.tds.freetds |
|---|---|
| Message-ID | <00aa01cc584d$9765a990$c630fcb0$@com> |
Actually, someone else mentioned at -D option. Because it was not in "man tsql", I missed the command line option. Don't see it online either. Weird. Your idea is still a good idea, so I may still end up using it if I find some other problem that the -D option does not fix. Thanks. Tony From: Robert Hetzel [mailto:[email protected]] Sent: Wednesday, August 10, 2011 8:43 PM To: [email protected] Subject: Re: [freetds] tsql knowing which DB to default to Can you use a separate userids for each application, setting a different default database for each? Bob On Wed, Aug 10, 2011 at 7:26 PM, Tony Baldarelli <[email protected]> wrote: Hello, For my production server, it just so happens that the database I use is the default database. As such, I don't need to use the following to connect to the correct database inside tsql: use <database> go But now we have 2 other databases that just happen to be on the same server. This requires me to use the "use <database>" pattern to connect to the correct database. I thought this setup would get around that requirement, but it does not: [Wms_Stage] host = PBMVMWMSSQLDEV port = 1433 tds version = 8.0 database=WMS_STAGE I actually think "database" is not supported as I don't see it in the documentation online. So either that changed, or someone added it and then never got rid of it since it does not seem to cause a problem. I want to make my application ( including SQL scripts ) as blind as possible to the database, but I cannot if I have to use the "use <database>" pattern for 2 databases, but not the production one. Is there a way to tell tsql to use a particular database so I don't have to? Note that since "tsql" is run from a special shell script ( called "sql" ), a perfectly valid option would be to have a command line option to tsql that tells tsql to use a particular database. Also, an environmental variable would also work, for this same reason. Thanks. I could not see an obvious way to do it in the documentation. In case you are wondering, I commonly run a command like this: sql < report.sql. Since "sql" is defined differently for each database ( actually, each Linux user ), I just want to be able to "run" the same sql script against all 3 databases without any changes at all. Thus my questions above. Here is an example of the "sql" script using the above freetds.conf setup: [wmsStage]> more sql tsql -S Wms_Stage -U <user name removed for security> -P <Password removed for security> echo [wmsStage]> Tony Baldarelli _______________________________________________ FreeTDS mailing list [email protected] http://lists.ibiblio.org/mailman/listinfo/freetds