Showing posts with label query. Show all posts
Showing posts with label query. Show all posts

Tuesday, March 27, 2012

Connecting to SQL server

Select * from ServerName.DatabaseName.OwnerOrSchema.Objectname

I tyied the way given above.But when im going to run it on query analizer it gives an error massege saying that

"Server 'JOY' is not configured for DATA ACCESS.'

How can i configure the particuler sever.

Thanks

Set the server configuration to allow remote connections.

Sunday, March 25, 2012

Connecting to SQL from Access

I have users who currently query a SQL database using Access and an odbc
connection. The database is being moved to a less secure server, and we are
looking for the best way for users to connect to this database so they can
do their own queries. They like Access because they can select the tables
and don't have to remember t-sql code, and I wouldn't want to give them sql
query anaylizer anyway. What would be the best way to do this? Eventually
we will be creating programs for them to access their data, but that could
be a long time in coming, and there are always queries we cannot anticipate
and therefore cannot provide an application for.
Thanks. Any ideas are appreciated.Access works pretty well. We've used access project files (.adp) to
allow users to query databases. .adp files utilize OLE DB connections.
You can also appropriately permission the login that the Access .adp
uses to access the sql server database. Let me know if you need more
specific guidance, I'd be happy to help out.|||Access works pretty well. We've used access project files (.adp) to
allow users to query databases. .adp files utilize OLE DB connections.
You can also appropriately permission the login that the Access .adp
uses to access the sql server database. Let me know if you need more
specific guidance, I'd be happy to help out.

Thursday, March 22, 2012

Connecting to remote SQL Server

I have SQL Server 2000 (Developer) on my computer. So I have SQL
Server Enterprise Manager + Tools (such as Query Analyzer).
I am doing some work on a remote server, mostly ASP pages (not
ASP.NET). There is a SQL Server database on that server. I would like
to use Enterprise Manager or Query Analyzer to access that database.
My main development environment is Dreamweaver MX2004. In Dreamweaver,
I was able to setup the database (on the databases tab) using a
"Custom Connection String", listed below (some info obfuscated for
security):
"Provider=SQLOLEDB.1;Persist Security Info=False;Initial
Catalog=funeral;Data Source=xx.xx.xx.xxx;Locale
Identifier=1033;Connect Timeout=15;Use Procedure for Prepare=1;Auto
Translate=True;Packet Size=4096;User Id=XXX;PASSWORD=XXXXXXXX;"
I don't know if it is possible to use the other tools to manage this
database. I've tried the following:
1. In Enterprise Manager, I've tried just putting the ip address as
the server, and "Use SQL Server authentication" from the user ID and
Password above, but I get the following error:
"SQL Server registration failed because of the connection failure
below... Cannot open user default database. Login failed"
2. Created a udl file. In the Provider, selected the "Microsoft OLE DB
Provider for SQL Server" Entered teh IP address and username/password
on the Connection Tab. I get the same error as #1 above.
Any insight would be greatly appreciated.
"Bryce Fischer" <spamtrap@.berzerker-soft.com> wrote in message
news:3btpo01us397pf1gmfl4bt9c8k9dcrv05e@.4ax.com...
> I have SQL Server 2000 (Developer) on my computer. So I have SQL
> Server Enterprise Manager + Tools (such as Query Analyzer).
> I am doing some work on a remote server, mostly ASP pages (not
> ASP.NET). There is a SQL Server database on that server. I would like
> to use Enterprise Manager or Query Analyzer to access that database.
> My main development environment is Dreamweaver MX2004. In Dreamweaver,
> I was able to setup the database (on the databases tab) using a
> "Custom Connection String", listed below (some info obfuscated for
> security):
> "Provider=SQLOLEDB.1;Persist Security Info=False;Initial
> Catalog=funeral;Data Source=xx.xx.xx.xxx;Locale
> Identifier=1033;Connect Timeout=15;Use Procedure for Prepare=1;Auto
> Translate=True;Packet Size=4096;User Id=XXX;PASSWORD=XXXXXXXX;"
> I don't know if it is possible to use the other tools to manage this
> database. I've tried the following:
> 1. In Enterprise Manager, I've tried just putting the ip address as
> the server, and "Use SQL Server authentication" from the user ID and
> Password above, but I get the following error:
> "SQL Server registration failed because of the connection failure
> below... Cannot open user default database. Login failed"
>
User XXX has a login on the remote server, but does not have a user in the
database he is configured to use. To administer the remote database, User
XXX must be a member of the sysadmin role on the remote server
http://snodland.blogspot.com
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.788 / Virus Database: 533 - Release Date: 01/11/2004
|||On Sat, 6 Nov 2004 22:04:54 -0000, "Bob Simms"
<bob_simms@.somewhere.com> wrote:

>User XXX has a login on the remote server, but does not have a user in the
>database he is configured to use. To administer the remote database, User
>XXX must be a member of the sysadmin role on the remote server
Thanks for the reply.
Is it possible to use Query Analyzer or Access to connect to the
server given the information in my original post? I don't need
administrator-like functionality. As I mentioned, in Dreamweaver, I'm
able to create a connection, and view the tables and data (not to be
confused with creating the connection on the ASP pages, but in
Dreamweaver itself.) Dreamweaver lets you browse the tables, and data,
it doesn't let you run SQL Statements, which is why I'd like to use
other tools I have.
TIA.
|||On Sat, 06 Nov 2004 20:21:58 -0500, Bryce Fischer
<spamtrap@.berzerker-soft.com> wrote:

>On Sat, 6 Nov 2004 22:04:54 -0000, "Bob Simms"
><bob_simms@.somewhere.com> wrote:
>
>Thanks for the reply.
>Is it possible to use Query Analyzer or Access to connect to the
>server given the information in my original post? I don't need
>administrator-like functionality. As I mentioned, in Dreamweaver, I'm
>able to create a connection, and view the tables and data (not to be
>confused with creating the connection on the ASP pages, but in
>Dreamweaver itself.) Dreamweaver lets you browse the tables, and data,
>it doesn't let you run SQL Statements, which is why I'd like to use
>other tools I have.
Well... After some persistence, I figured it out. In Access, and
Visual Studio, I was able to bring up the Data Link Properties dialog,
and enter the information, and the one step I was not doing, was
entering in the catalog in the "Select the database on the server:"
field.
I was able to accomplish the same thing in Visual Studio, Server
Explorer, Data Connections.

Connecting to remote SQL Server

I have SQL Server 2000 (Developer) on my computer. So I have SQL
Server Enterprise Manager + Tools (such as Query Analyzer).
I am doing some work on a remote server, mostly ASP pages (not
ASP.NET). There is a SQL Server database on that server. I would like
to use Enterprise Manager or Query Analyzer to access that database.
My main development environment is Dreamweaver MX2004. In Dreamweaver,
I was able to setup the database (on the databases tab) using a
"Custom Connection String", listed below (some info obfuscated for
security):
"Provider=SQLOLEDB.1;Persist Security Info=False;Initial
Catalog=funeral;Data Source=xx.xx.xx.xxx;Locale
Identifier=1033;Connect Timeout=15;Use Procedure for Prepare=1;Auto
Translate=True;Packet Size=4096;User Id=XXX;PASSWORD=XXXXXXXX;"
I don't know if it is possible to use the other tools to manage this
database. I've tried the following:
1. In Enterprise Manager, I've tried just putting the ip address as
the server, and "Use SQL Server authentication" from the user ID and
Password above, but I get the following error:
"SQL Server registration failed because of the connection failure
below... Cannot open user default database. Login failed"
2. Created a udl file. In the Provider, selected the "Microsoft OLE DB
Provider for SQL Server" Entered teh IP address and username/password
on the Connection Tab. I get the same error as #1 above.
Any insight would be greatly appreciated."Bryce Fischer" <spamtrap@.berzerker-soft.com> wrote in message
news:3btpo01us397pf1gmfl4bt9c8k9dcrv05e@.
4ax.com...
> I have SQL Server 2000 (Developer) on my computer. So I have SQL
> Server Enterprise Manager + Tools (such as Query Analyzer).
> I am doing some work on a remote server, mostly ASP pages (not
> ASP.NET). There is a SQL Server database on that server. I would like
> to use Enterprise Manager or Query Analyzer to access that database.
> My main development environment is Dreamweaver MX2004. In Dreamweaver,
> I was able to setup the database (on the databases tab) using a
> "Custom Connection String", listed below (some info obfuscated for
> security):
> "Provider=SQLOLEDB.1;Persist Security Info=False;Initial
> Catalog=funeral;Data Source=xx.xx.xx.xxx;Locale
> Identifier=1033;Connect Timeout=15;Use Procedure for Prepare=1;Auto
> Translate=True;Packet Size=4096;User Id=XXX;PASSWORD=XXXXXXXX;"
> I don't know if it is possible to use the other tools to manage this
> database. I've tried the following:
> 1. In Enterprise Manager, I've tried just putting the ip address as
> the server, and "Use SQL Server authentication" from the user ID and
> Password above, but I get the following error:
> "SQL Server registration failed because of the connection failure
> below... Cannot open user default database. Login failed"
>
User XXX has a login on the remote server, but does not have a user in the
database he is configured to use. To administer the remote database, User
XXX must be a member of the sysadmin role on the remote server
http://snodland.blogspot.com
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.788 / Virus Database: 533 - Release Date: 01/11/2004|||On Sat, 6 Nov 2004 22:04:54 -0000, "Bob Simms"
<bob_simms@.somewhere.com> wrote:

>User XXX has a login on the remote server, but does not have a user in the
>database he is configured to use. To administer the remote database, User
>XXX must be a member of the sysadmin role on the remote server
Thanks for the reply.
Is it possible to use Query Analyzer or Access to connect to the
server given the information in my original post? I don't need
administrator-like functionality. As I mentioned, in Dreamweaver, I'm
able to create a connection, and view the tables and data (not to be
confused with creating the connection on the ASP pages, but in
Dreamweaver itself.) Dreamweaver lets you browse the tables, and data,
it doesn't let you run SQL Statements, which is why I'd like to use
other tools I have.
TIA.|||On Sat, 06 Nov 2004 20:21:58 -0500, Bryce Fischer
<spamtrap@.berzerker-soft.com> wrote:

>On Sat, 6 Nov 2004 22:04:54 -0000, "Bob Simms"
><bob_simms@.somewhere.com> wrote:
>
>Thanks for the reply.
>Is it possible to use Query Analyzer or Access to connect to the
>server given the information in my original post? I don't need
>administrator-like functionality. As I mentioned, in Dreamweaver, I'm
>able to create a connection, and view the tables and data (not to be
>confused with creating the connection on the ASP pages, but in
>Dreamweaver itself.) Dreamweaver lets you browse the tables, and data,
>it doesn't let you run SQL Statements, which is why I'd like to use
>other tools I have.
Well... After some persistence, I figured it out. In Access, and
Visual Studio, I was able to bring up the Data Link Properties dialog,
and enter the information, and the one step I was not doing, was
entering in the catalog in the "Select the database on the server:"
field.
I was able to accomplish the same thing in Visual Studio, Server
Explorer, Data Connections.

Connecting to remote SQL Server

I have SQL Server 2000 (Developer) on my computer. So I have SQL
Server Enterprise Manager + Tools (such as Query Analyzer).
I am doing some work on a remote server, mostly ASP pages (not
ASP.NET). There is a SQL Server database on that server. I would like
to use Enterprise Manager or Query Analyzer to access that database.
My main development environment is Dreamweaver MX2004. In Dreamweaver,
I was able to setup the database (on the databases tab) using a
"Custom Connection String", listed below (some info obfuscated for
security):
"Provider=SQLOLEDB.1;Persist Security Info=False;Initial
Catalog=funeral;Data Source=xx.xx.xx.xxx;Locale
Identifier=1033;Connect Timeout=15;Use Procedure for Prepare=1;Auto
Translate=True;Packet Size=4096;User Id=XXX;PASSWORD=XXXXXXXX;"
I don't know if it is possible to use the other tools to manage this
database. I've tried the following:
1. In Enterprise Manager, I've tried just putting the ip address as
the server, and "Use SQL Server authentication" from the user ID and
Password above, but I get the following error:
"SQL Server registration failed because of the connection failure
below... Cannot open user default database. Login failed"
2. Created a udl file. In the Provider, selected the "Microsoft OLE DB
Provider for SQL Server" Entered teh IP address and username/password
on the Connection Tab. I get the same error as #1 above.
Any insight would be greatly appreciated."Bryce Fischer" <spamtrap@.berzerker-soft.com> wrote in message
news:3btpo01us397pf1gmfl4bt9c8k9dcrv05e@.4ax.com...
> I have SQL Server 2000 (Developer) on my computer. So I have SQL
> Server Enterprise Manager + Tools (such as Query Analyzer).
> I am doing some work on a remote server, mostly ASP pages (not
> ASP.NET). There is a SQL Server database on that server. I would like
> to use Enterprise Manager or Query Analyzer to access that database.
> My main development environment is Dreamweaver MX2004. In Dreamweaver,
> I was able to setup the database (on the databases tab) using a
> "Custom Connection String", listed below (some info obfuscated for
> security):
> "Provider=SQLOLEDB.1;Persist Security Info=False;Initial
> Catalog=funeral;Data Source=xx.xx.xx.xxx;Locale
> Identifier=1033;Connect Timeout=15;Use Procedure for Prepare=1;Auto
> Translate=True;Packet Size=4096;User Id=XXX;PASSWORD=XXXXXXXX;"
> I don't know if it is possible to use the other tools to manage this
> database. I've tried the following:
> 1. In Enterprise Manager, I've tried just putting the ip address as
> the server, and "Use SQL Server authentication" from the user ID and
> Password above, but I get the following error:
> "SQL Server registration failed because of the connection failure
> below... Cannot open user default database. Login failed"
>
User XXX has a login on the remote server, but does not have a user in the
database he is configured to use. To administer the remote database, User
XXX must be a member of the sysadmin role on the remote server
http://snodland.blogspot.com
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.788 / Virus Database: 533 - Release Date: 01/11/2004|||On Sat, 6 Nov 2004 22:04:54 -0000, "Bob Simms"
<bob_simms@.somewhere.com> wrote:
>> 1. In Enterprise Manager, I've tried just putting the ip address as
>> the server, and "Use SQL Server authentication" from the user ID and
>> Password above, but I get the following error:
>> "SQL Server registration failed because of the connection failure
>> below... Cannot open user default database. Login failed"
>User XXX has a login on the remote server, but does not have a user in the
>database he is configured to use. To administer the remote database, User
>XXX must be a member of the sysadmin role on the remote server
Thanks for the reply.
Is it possible to use Query Analyzer or Access to connect to the
server given the information in my original post? I don't need
administrator-like functionality. As I mentioned, in Dreamweaver, I'm
able to create a connection, and view the tables and data (not to be
confused with creating the connection on the ASP pages, but in
Dreamweaver itself.) Dreamweaver lets you browse the tables, and data,
it doesn't let you run SQL Statements, which is why I'd like to use
other tools I have.
TIA.|||On Sat, 06 Nov 2004 20:21:58 -0500, Bryce Fischer
<spamtrap@.berzerker-soft.com> wrote:
>On Sat, 6 Nov 2004 22:04:54 -0000, "Bob Simms"
><bob_simms@.somewhere.com> wrote:
>> 1. In Enterprise Manager, I've tried just putting the ip address as
>> the server, and "Use SQL Server authentication" from the user ID and
>> Password above, but I get the following error:
>> "SQL Server registration failed because of the connection failure
>> below... Cannot open user default database. Login failed"
>>User XXX has a login on the remote server, but does not have a user in the
>>database he is configured to use. To administer the remote database, User
>>XXX must be a member of the sysadmin role on the remote server
>Thanks for the reply.
>Is it possible to use Query Analyzer or Access to connect to the
>server given the information in my original post? I don't need
>administrator-like functionality. As I mentioned, in Dreamweaver, I'm
>able to create a connection, and view the tables and data (not to be
>confused with creating the connection on the ASP pages, but in
>Dreamweaver itself.) Dreamweaver lets you browse the tables, and data,
>it doesn't let you run SQL Statements, which is why I'd like to use
>other tools I have.
Well... After some persistence, I figured it out. In Access, and
Visual Studio, I was able to bring up the Data Link Properties dialog,
and enter the information, and the one step I was not doing, was
entering in the catalog in the "Select the database on the server:"
field.
I was able to accomplish the same thing in Visual Studio, Server
Explorer, Data Connections.

Monday, March 19, 2012

Connecting to named instance fails for Enterprise Manager but works with Query Analyzer

Hi,
We have just had a 64-bit SQL Server 2000 cluster installed in our
network and I am having difficulties connecting to it.
The named instance I am trying to access is 192.168.0.108\DX
I can connect to it from a machine on the same subnet using Enterprise
Manager, but not from a machine on another subnet (192.168.14.0), when
attempiting EM just stops responding. The weird thing is that I can
connect using Query Analyzer, but not EM (obviously using the same
connection details).
Does anybody have any suggestions to what might be causing this
behaviour?
The client computer I use is a Windows XP Professional with SP2 and
client connectivity tools for SQL Server 2000. I have tried disabling
the firewall, which didn't help. I can connect to another SQL Server
(default instance, 32-bit, non-clustered) on the other network with
EM.
Regards,
Ville Tuomola
Have you tried pinging the server when you can't connect?
Have you checked the registration/connection properties for
the server in Enterprise Manager? Are you sure you aren't
just getting a login timeout? You can increase the login
timeout from the menu go to Tools then Options. On the
Advanced tab, increase the login timeout to a value higher
than the default 4 seconds.
-Sue
On 7 Oct 2004 01:11:35 -0700, vtuomola@.gmail.com (Ville
Tuomola) wrote:

>Hi,
>We have just had a 64-bit SQL Server 2000 cluster installed in our
>network and I am having difficulties connecting to it.
>The named instance I am trying to access is 192.168.0.108\DX
>I can connect to it from a machine on the same subnet using Enterprise
>Manager, but not from a machine on another subnet (192.168.14.0), when
>attempiting EM just stops responding. The weird thing is that I can
>connect using Query Analyzer, but not EM (obviously using the same
>connection details).
>Does anybody have any suggestions to what might be causing this
>behaviour?
>The client computer I use is a Windows XP Professional with SP2 and
>client connectivity tools for SQL Server 2000. I have tried disabling
>the firewall, which didn't help. I can connect to another SQL Server
>(default instance, 32-bit, non-clustered) on the other network with
>EM.
>Regards,
>Ville Tuomola

Connecting to MSDE

I am trying to connect to a MSDE database on server from my desktop using query analyzer. I keep getting the generic "SQL Server does not exist or access denied'

I have verified the following:
- the login/password is valid because when I access osql from server I can gain access
- the registry for Loginmode appears OK - set to 2 - mixed mode

What else do I need to check...

Thanks, kgaskeDid MSDE install as a named instance? Check the service, and see if it is listed as MSSQL$foo. If it is, you connect as servername\foo.|||No MSDE is not a named instance. Checked the service..|||Can you connect to the server from the server? Maybe no network protocols were enabled.|||Can you connect to the server from the server? Maybe no network protocols were enabled.

I'll second this; what version of MSDE is it? What's the operating system. By default, MSDE 2000 installed on WXP or Win2003 will not enable IP connections. You have to install SP3 (minimum) or SP4. I also recall (from some dim memory) that by default, MSDE does not enable anything but shared memory (ie, localhost) connections.

Regards,

hmscott

Sunday, March 11, 2012

Connecting to hosted / remote database

Hello,

I would like to know whether is it possible to administer a database on a hosted site - i.e inserting some lines, executing a query. I normally access the files via ftp connection. And so far the only way I figured I can mess around with the database is to download it and change it on my desktop PC.

Thank You.

Tomá? Pajonk

they would need to open a port (which is not advisable)

port 1433 by default.

the best solution is to create a vpn.

|||

Thank You very much. How can You create VPN for this purpose ? - I believe the hosting company would have to allow it and configure it.

How do people access their ASPNETDB file when their projects are hosted ? It is easy to do in the VWD but when the site is local.

Do I need to create my own "administrative pages" for this prupose ?

Thank You again for such a swift reply.

|||

well. . .depends on your hoster.

Yes it is up to him to let you vpn to the machine.

So you have rented diskspace and they hang your mdf on their server tree?

Do you have telnet capabilities as well as ftp? you could possibly telnet in and use the osql command line utility to administer the database on their side. it is a little cumbersome but once you get the hang of it, its not too hard. you can write your scripts locally, move them over and execute via a batch file.

can you remote desktop into the machine?

other than that, yeah, a set of adminstrative pages is about the only way.

|||

yes I have rented diskspace. They support ASP.NET 2.0, and SQL Server 2000 and SQL Server Express.

They do not provide telnet capabilities. I am trying the remote connection - that could work. But'll have to ask them for a password. I am not sure which password should I use. I am sorry if I sound like a total newbie - but that's the way it is when it comes to hosting and so on.

I guess I'll have to work on those administrative web pages once I understand the ASPNETDB database.

thanks for all the hints.

|||I can't comment on your particular provider but GoDaddy has an administrative interface that is pretty easy to use. The ASPNETDF database is created by issuing the sql scripts on the administrative interface.

Thursday, March 8, 2012

Connecting to Access

Hello,
I am trying to connect to an Access database though Query Analyzer. The
help file is minimally helpful on this. This is what I have so far:
-- add the database as a linked server
execute sp_addlinkedserver Library,
'Access 2002',
'Microsoft.Jet.OLEDB.4.0',
'D:\today\Andrew\Library.mdb'
-- add a login to that server
execute sp_addlinkedsrvlogin Library,
false,
'EBSHQ\Andrew',
'Admin',
NULL
-- show servers
execute sp_linkedservers
-- do something
execute sp_tables_ex 'Library'
Here's where I get an error:
Bah, the server's out for a bit. I'll post the error when it comes back.
Without the error message, does anything above look wrong or out of
place?
Thanks,
AndrewHi
If you get something like:
Server: Msg 7399, Level 16, State 1, Procedure sp_tables_ex, Line 20
OLE DB provider 'Microsoft.Jet.OLEDB.4.0' reported an error.
[OLE/DB provider returned message: Disk or network error.]
OLE DB error trace [OLE/DB Provider 'Microsoft.Jet.OLEDB.4.0'
IDBInitialize::Initialize returned 0x80004005: ].
0x80004005 indicates a permissions issue. You could have specified the wrong
file name as the linked server or the permission are such that you can not
see/open it.
John
"Andrew Clark" <lark047@.hotmail.com> wrote in message
news:1108168266. 8c16687f2eb892e2e3e7ff72d9cb5c72@.teranew
s...
> Hello,
> I am trying to connect to an Access database though Query Analyzer. The
> help file is minimally helpful on this. This is what I have so far:
> -- add the database as a linked server
> execute sp_addlinkedserver Library,
> 'Access 2002',
> 'Microsoft.Jet.OLEDB.4.0',
> 'D:\today\Andrew\Library.mdb'
> -- add a login to that server
> execute sp_addlinkedsrvlogin Library,
> false,
> 'EBSHQ\Andrew',
> 'Admin',
> NULL
> -- show servers
> execute sp_linkedservers
> -- do something
> execute sp_tables_ex 'Library'
> Here's where I get an error:
> Bah, the server's out for a bit. I'll post the error when it comes back.
> Without the error message, does anything above look wrong or out of
> place?
> Thanks,
> Andrew
>|||"John Bell" <jbellnewsposts@.hotmail.com> wrote in
news:eURHWJREFHA.1012@.TK2MSFTNGP14.phx.gbl:

> Hi
> If you get something like:
> Server: Msg 7399, Level 16, State 1, Procedure sp_tables_ex, Line 20
> OLE DB provider 'Microsoft.Jet.OLEDB.4.0' reported an error.
> [OLE/DB provider returned message: Disk or network error.]
> OLE DB error trace [OLE/DB Provider 'Microsoft.Jet.OLEDB.4.0'
> IDBInitialize::Initialize returned 0x80004005: ].
> 0x80004005 indicates a permissions issue. You could have specified the
> wrong file name as the linked server or the permission are such that
> you can not see/open it.
> John
>
>
>
I think that might have been it, but I will have to check on monday
Andrew

connecting to a table

Hi

Please let me how to put a specific query to a database in the task and get the values from the db.

I have this code:

ConnectionManager cm = Microsoft.SqlServer.Dts.Runtime.DtsConvert.ToConnectionManager(

ComponentMetaData.RuntimeConnectionCollection["conRun"].ConnectionManager);

cm.Name = "TestConn";

cm.ConnectionString = "Data Source=srcServerName;Initial Catalog=srcDBName;" +

"Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;" +

"Auto Translate=False;";

After doing this, if i need to write a specific query to a table. How to do it.

Thanks

Vipul

Hi Vipul:

Not sure if this is exactly what you're trying to do, but I think this might be close to what you need.

I'm using the following code to extract a stored flat file date/time stamp from a SQL Server table.
Notice that I'm using a DataAdapter to populate a DataTable with the rows returned by the in-line
SQL statement. This function returns just the first column of the first row of the DataTable, but could
just as easily return the entire DataTable, or just one row from the table:

Private Function GetPreviousDateTimeStamp(ByVal pstrFileName As String) As Date
Dim cn As Data.SqlClient.SqlConnection
Dim cm As Data.SqlClient.SqlCommand
Dim da As Data.SqlClient.SqlDataAdapter
Dim dt As DataTable
Dim strSQL As String

Try
cn = New SqlConnection

'Set up a Connection object:
cn = CType(Dts.Connections("My_Connection_ADO" _
).AcquireConnection(Nothing), Data.SqlClient.SqlConnection)

strSQL = "SELECT PreviousDateTimeStamp " _
& "FROM dbo._FileTimeStamps " _
& "WHERE ImportFileName = '" & pstrFileName & "'"

'Establish a Command object with this SQL statement:
cm = New Data.SqlClient.SqlCommand(strSQL)

'Set Command object's Connection property:
cm.Connection = cn

'Set up a SqlDataAdapter:
da = New SqlDataAdapter(cm)

'Instantiate a DataTable:
dt = New DataTable

'Populate the DataTable:
da.Fill(dt)

'Return the first cell of the first row:
Return CType(dt.Rows(0).Item(0), Date)

Catch ex As Exception

Throw ex

End Try

End Function

Hope this helps! BTW: I could only get this code to work with an ADO connection,
and could not get it to work with an OLEDB connection. I'm sure someone here knows
why I couldn't use OLEDB, but it's working for me and I'm okay with that.

- Mike

|||

Hi Mike:

Thanks for the reply. I was able to do it. This is my piece of code and i have made use of oledb only.

ConnectionManager cm = Microsoft.SqlServer.Dts.Runtime.DtsConvert.ToConnectionManager(

ComponentMetaData.RuntimeConnectionCollection["Source"].ConnectionManager);

ConnectionManagerOleDb cmoledb = cm.InnerObject as ConnectionManagerOleDb;

OleDbCommand oledbCommand;

String connMgrString = cm.ConnectionString;

OleDbConnection conn = new OleDbConnection(connMgrString);

conn.Open();

String query = "INSERT INTO Tab1 (First, Second) " + " VALUES ('TEST', 'TEST')";

oledbCommand = new OleDbCommand(query, conn);

oledbCommand.ExecuteNonQuery();

conn.Close();

You can check it if this helps.

Thanks

Vipul

|||

Hi Vipul:

Is your code working now? It looks okay to me.

- Mike

|||

Yes it works..

Thanks

Vipul

Wednesday, March 7, 2012

Connecting to a MSDE server in Internet

Hi !!
I would like to connect to a SQL Server (MSDE edition) that's in Internet,
using Enterprise Manager either Query Analizer. For these I've configured
the client tool as:
Server Alias: INET_SERVER
Net: TCP/IP
Connection parameters:
Server name: [DNS_NAME]\[REMOTE_SERVER_NAME]\[INSTANCE_NAME]
Port number: 1433
Althought I've tried to configure the server name in different ways, I
haven't found the successful way to do it.
I don't think it's a firewall problem. In theory I've successfull disabled.
Thanks !!
Josep.You can check to see if it's a firewall or port blocking issue or not by
using TELNET and seeing if it can connect. Type this from a command
prompt (replace INET_SERVER with your server name).
telnet INET_SERVER 1433
If the telnet session fails to connect, you have a firewall issue or are
not using the correct port or host name - when I try to connect to
something that is blocked by a firewall, the error reported for me was
"could not open connection to the host on port xxxx: Connect failed".
If you get a screen that appears to be the start of the connected
session, you can be sure you have actually opened a port to another
machine. You won't be able to do anything meaningful from this telnet
session, but it rules out firewall, port, or hostname issues. Close it
and use the same settings to connect with Query Analyzer or Enterprise
Manager.
Good luck,
Tony Sebion
"Josep" <hola@.microsoft.com> wrote in message
news:#1fFelMxFHA.700@.TK2MSFTNGP11.phx.gbl:

> Hi !!
> I would like to connect to a SQL Server (MSDE edition) that's in Internet,
> using Enterprise Manager either Query Analizer. For these I've configured
> the client tool as:
> Server Alias: INET_SERVER
> Net: TCP/IP
> Connection parameters:
> Server name: [DNS_NAME]\[REMOTE_SERVER_NAME]\[INSTANCE_NAME]
> Port number: 1433
> Althought I've tried to configure the server name in different ways, I
> haven't found the successful way to do it.
> I don't think it's a firewall problem. In theory I've successfull disabled
.
>
> Thanks !!
> Josep.|||Well, it seems I didn't unblock the port successfully. So, my work is to
find how this router works... where else I've to configure the ports... but
I like to know that's not an SQL Server problem :-)
Thank you Tony for explaining me this very fast way, and easy, to know if a
port is blocked or not :D
Josep.
"Tony Sebion" <tony@.sebion.com> escribi en el mensaje
news:3q2bkiFcpoaaU1@.individual.net...
> You can check to see if it's a firewall or port blocking issue or not by
> using TELNET and seeing if it can connect. Type this from a command
> prompt (replace INET_SERVER with your server name).
> telnet INET_SERVER 1433
> If the telnet session fails to connect, you have a firewall issue or are
> not using the correct port or host name - when I try to connect to
> something that is blocked by a firewall, the error reported for me was
> "could not open connection to the host on port xxxx: Connect failed".
> If you get a screen that appears to be the start of the connected session,
> you can be sure you have actually opened a port to another machine. You
> won't be able to do anything meaningful from this telnet session, but it
> rules out firewall, port, or hostname issues. Close it and use the same
> settings to connect with Query Analyzer or Enterprise Manager.
> Good luck,
> Tony Sebion
> "Josep" <hola@.microsoft.com> wrote in message
> news:#1fFelMxFHA.700@.TK2MSFTNGP11.phx.gbl:
>
>|||Josep,
did you can do it? I have the same problem here. I think is not due to
firewall, all those ports are opened. (1433TCP; 1434UDP!)
Thank you,
Leo-
"Josep" <hola@.microsoft.com> escribi en el mensaje
news:%231$1wmaxFHA.4032@.TK2MSFTNGP15.phx.gbl...
> Well, it seems I didn't unblock the port successfully. So, my work is to
> find how this router works... where else I've to configure the ports...
> but I like to know that's not an SQL Server problem :-)
> Thank you Tony for explaining me this very fast way, and easy, to know if
> a port is blocked or not :D
> Josep.
>
> "Tony Sebion" <tony@.sebion.com> escribi en el mensaje
> news:3q2bkiFcpoaaU1@.individual.net...
>

Connecting to a MSDE server in Internet

Hi !!
I would like to connect to a SQL Server (MSDE edition) that's in Internet,
using Enterprise Manager either Query Analizer. For these I've configured
the client tool as:
Server Alias: INET_SERVER
Net: TCP/IP
Connection parameters:
Server name: [DNS_NAME]\[REMOTE_SERVER_NAME]\[INSTANCE_NAME]
Port number: 1433
Althought I've tried to configure the server name in different ways, I
haven't found the successful way to do it.
I don't think it's a firewall problem. In theory I've successfull disabled.
Thanks !!
Josep.
You can check to see if it's a firewall or port blocking issue or not by
using TELNET and seeing if it can connect. Type this from a command
prompt (replace INET_SERVER with your server name).
telnet INET_SERVER 1433
If the telnet session fails to connect, you have a firewall issue or are
not using the correct port or host name - when I try to connect to
something that is blocked by a firewall, the error reported for me was
"could not open connection to the host on port xxxx: Connect failed".
If you get a screen that appears to be the start of the connected
session, you can be sure you have actually opened a port to another
machine. You won't be able to do anything meaningful from this telnet
session, but it rules out firewall, port, or hostname issues. Close it
and use the same settings to connect with Query Analyzer or Enterprise
Manager.
Good luck,
Tony Sebion
"Josep" <hola@.microsoft.com> wrote in message
news:#1fFelMxFHA.700@.TK2MSFTNGP11.phx.gbl:

> Hi !!
> I would like to connect to a SQL Server (MSDE edition) that's in Internet,
> using Enterprise Manager either Query Analizer. For these I've configured
> the client tool as:
> Server Alias: INET_SERVER
> Net: TCP/IP
> Connection parameters:
> Server name: [DNS_NAME]\[REMOTE_SERVER_NAME]\[INSTANCE_NAME]
> Port number: 1433
> Althought I've tried to configure the server name in different ways, I
> haven't found the successful way to do it.
> I don't think it's a firewall problem. In theory I've successfull disabled.
>
> Thanks !!
> Josep.
|||Well, it seems I didn't unblock the port successfully. So, my work is to
find how this router works... where else I've to configure the ports... but
I like to know that's not an SQL Server problem :-)
Thank you Tony for explaining me this very fast way, and easy, to know if a
port is blocked or not :D
Josep.
"Tony Sebion" <tony@.sebion.com> escribi en el mensaje
news:3q2bkiFcpoaaU1@.individual.net...
> You can check to see if it's a firewall or port blocking issue or not by
> using TELNET and seeing if it can connect. Type this from a command
> prompt (replace INET_SERVER with your server name).
> telnet INET_SERVER 1433
> If the telnet session fails to connect, you have a firewall issue or are
> not using the correct port or host name - when I try to connect to
> something that is blocked by a firewall, the error reported for me was
> "could not open connection to the host on port xxxx: Connect failed".
> If you get a screen that appears to be the start of the connected session,
> you can be sure you have actually opened a port to another machine. You
> won't be able to do anything meaningful from this telnet session, but it
> rules out firewall, port, or hostname issues. Close it and use the same
> settings to connect with Query Analyzer or Enterprise Manager.
> Good luck,
> Tony Sebion
> "Josep" <hola@.microsoft.com> wrote in message
> news:#1fFelMxFHA.700@.TK2MSFTNGP11.phx.gbl:
>
|||Josep,
did you can do it? I have the same problem here. I think is not due to
firewall, all those ports are opened. (1433TCP; 1434UDP!)
Thank you,
Leo-
"Josep" <hola@.microsoft.com> escribi en el mensaje
news:%231$1wmaxFHA.4032@.TK2MSFTNGP15.phx.gbl...
> Well, it seems I didn't unblock the port successfully. So, my work is to
> find how this router works... where else I've to configure the ports...
> but I like to know that's not an SQL Server problem :-)
> Thank you Tony for explaining me this very fast way, and easy, to know if
> a port is blocked or not :D
> Josep.
>
> "Tony Sebion" <tony@.sebion.com> escribi en el mensaje
> news:3q2bkiFcpoaaU1@.individual.net...
>

connecting to a linked server using VS2005

hi,

i've currently created a linked server using sql server management studio express (it connects to an oracle database to draw data), i can query it all fine using the query analyzer with sql server etc.

how can i start using the linked server data with visual studio 2005? i can't seem to find the linked server anywhere inside the server explorer, am i suppose to import it / connect to it any specific way so i can start using the data retreived from the linked server?

thanks in advance!

create a view in SQL that reads from this linked server, and in ur server explorer, browse ur view,

Hope this helps

|||

Ramzi.Aynati:

create a view in SQL that reads from this linked server, and in ur server explorer, browse ur view,

Hope this helps

thanks, but how do i create a view?

|||

if you would like to hit linked server in you code just add database name to each object your would like to access. You can run query on server to which you are connected and server will forward your query to linked server. for example if your SQLServer2 is linked server in SQlServer1 you can run query like this om SQLServer1 ( if user you used to link servers have rights to objects in your query)

select * from [SQLserver2].[database].dbo.[tablename]

you can connect results from multiple servers

select * from [SQLserver2].[database].dbo.[tablename]
left join [SQLserver1].[database1].dbo.[tablename1]
ON tablename.aa=tablename1.bb

If you only use linked server in your query you can use OpenQuery which will process data on the linked server and returns only results to you.

SELECT * from OPENQUERY([SQLServer2,' select * from [database].dbo.[tablename]')

Thanks

|||

In your SQL, go to ur query analyzer

and type

Create View View_name as

SELECT *
FROM TEST1.Northwind.dbo.Orders

//where test is ur linked server

This is it, u got urself a view accessible from ur server explorer

|||

I would not recommend to create view like this because it will work very slow. To create view SQL server will try to load all data required to generate view from linked server to your server so it will generate very heavy network traffic and will be very slow. The better way is to get exactly what you need from your linked server or create view on linked server and access it from your main server.

Best solution will be to use Stored procedure to do this or table returned function (but not everything will work in function)

Thanks

|||

jpazgier:

I would not recommend to create view like this because it will work very slow. To create view SQL server will try to load all data required to generate view from linked server to your server so it will generate very heavy network traffic and will be very slow. The better way is to get exactly what you need from your linked server or create view on linked server and access it from your main server.

Best solution will be to use Stored procedure to do this or table returned function (but not everything will work in function)

Thanks

thanks, i might try both options.. would you happen to know of any tutorials that would put me to the right direction in creating a stored procedure to do this? thanks

|||

Dear Frank

As long as the table ur querying is less than 10000 records, u wont feel a pinch, the difference will be in milli seconds,

The topic jpazgier is raising is for really advanced SQL programming and for huge amount of records over 1 million

|||

thanks, have given it a go and i get this error message, any idea what i'm doing wrong?

OLE DB error trace [Non-interface error].

Msg 7312, Level 16, State 1, Procedure OracleComDir, Line 3

Invalid use of schema and/or catalog for OLE DB provider 'MSDAORA'. A four-part name was supplied, but the provider does not expose the necessary interfaces to use a catalog and/or schema.

|||nevermind, worked it out, thanks :)|||

Dear Frank

Please dont forget to mark the post that helped u the most as answered for sake of future readers

Glad to be of help my friend

|||

jpazgier:

I would not recommend to create view like this because it will work very slow. To create view SQL server will try to load all data required to generate view from linked server to your server so it will generate very heavy network traffic and will be very slow. The better way is to get exactly what you need from your linked server or create view on linked server and access it from your main server.

Best solution will be to use Stored procedure to do this or table returned function (but not everything will work in function)

Thanks

turns out there's about 500,000 records in the database, so results are generating really slow.

i've been attempting to create a stored procedure, but it's still taking 20 odd seconds to bring up the results, here's a basic summary of my stored procedure:

ALTER PROCEDURE GetOracleData
AS

SELECT
oracle_table1.field1,
oracle_table1.field2,
oracle_table2.field1,
oracle_table2.field2

from
OracleCD..oracle_database1.table1,
OracleCD..oracle_database2.table2

WHERE
(oracle_table1.field1 = oracle_table2.field1) AND
(oracle_table1.field2 = oracle_table2.field2)

OracleCD = name of the linked server i created, i'm thinking the fact that i'm calling the data from the linked server is the reason why it's taking soo long for the data to load? what's the best way to call upon data from different databases in a stored procedure?

thanks in advance!

connecting to 2 databases inside one query

hi there,
I saw a similar thread before but i've tried it and no luck. I want run a query off a database (stawebdata.branchinfo) then a join into bluepages.phonelist

i've tired

JOIN bluepages.phonelist p

Incorrect syntax near the keyword 'JOIN'.

any ideas... is this possible?

complete code below:

select DISTINCT b.name, b.tel1, b.id, b.telprivate,b.sc, b.manager,b.branchEmail
from branchInfo b
inner
JOIN bluepages.phonelist p on b.name = p.subdepartment
where b.name like 'Sarah' or b.id LIKE '%@.keyword%' OR b.county LIKE '%@.keyword%' OR b.Area LIKE '%@.keyword%' OR b.Manager LIKE '%@.keyword%' OR b.AssistantManager LIKE '%@.keyword%' OR b.Postcode LIKE '%@.keyword%' OR b.PseudoCity LIKE '%@.keyword%' OR b.TicketingTA LIKE '%@.keyword%' OR b.SLC LIKE '%@.keyword%' OR b.ItineraryTA LIKE '%@.keyword%' OR b.TIDS LIKE '%@.keyword%' OR b.ABTA LIKE '%@.keyword%' and
p.department = 'UK Branch' and
b.isbranch <> 'False' or
(p.lastName = '@.keyword' or p.firstname = '@.keyword')
order by b.name asc
GOyou have to put

JOIN bluepages.dbo.phonelist

i thought "dbo" was a param!

derrr|||How about putting two dots:

JOIN bluepages..phonelist

Roshmi Choudhury

Saturday, February 25, 2012

Connecting the ASP.Net to a DB using SQL Query

I have a SQL query that I think it wont work it's:

SELECT break_time, break_rep_no, break_count, break_update_count, break_type, break_group
FROM breaks
WHERE (break_date = @.p1) AND (break_group = @.p2) AND (break_time > @.p3) OR
(break_time < @.P4)
ORDER BY break_time

When I insert this parameters:

@.p1= 7/21/2004
@.p2= 0
@.p3= 9:00 AM
@.p4= 3:00 PM

I get these results:
Break_time rep_no count ucount break_type break_group
9:00:00 AM____2____2_____0________2_________0
9:00:00 AM____2____2_____1________1_________0
10:00:00 AM___1____2_____0________2_________2
11:20:00 AM___2____1_____0________2_________2
1:00:00 PM____2____2_____1________1_________0

Which if you notice not the result I expect look at the (break_group) Column you will find that it brings 0's in addition to 2 which is not expected to appears?

I'm using this query in ASP.Net page Under VB.Net

Me.SqlComm_Chk_Group.Parameters(0).Value = System.DateTime.Today
Me.SqlComm_Chk_Group.Parameters(1).Value = 0
Me.SqlComm_Chk_Group.Parameters(2).Value = tFrom.AddMinutes(59).ToShortTimeString()
Me.SqlComm_Chk_Group.Parameters(3).Value = tTo.AddMinutes(-59).ToShortTimeString()

dr = Me.SqlComm_Chk_Group.ExecuteReader

While dr.Read
tBreakTime = dr(0)
iRepNo = dr(1)
iBreakCount = dr(2)
iBreakUCount = dr(3)
iBreakType = dr(4)
iBreakGreoup = dr(5)

Call Engine(tBreakTime, tFrom, iBreakType, False, iRepNo)
End While
dr.Close()

Where is the problem PLAES?
Thank youParenthesize.


SELECT break_time, break_rep_no, break_count, break_update_count, break_type, break_group
FROM breaks
WHERE (break_date = @.p1) AND (break_group = @.p2) AND ((break_time > @.p3) OR
(break_time < @.P4))
ORDER BY break_time

Even now, I am not sure the code will do what you are looking to do.|||Why I did it before and it works I even try it with OleDB with MSAccess DB But I'm not understand why its not working here every thing seems to be correct|||Depending upon the data in the db and the times you pass, it might APPEAR to work for some data.

Connecting SQL Server Express 2005 to a Microsoft Access 97 Database

I want to use SQL Server to query an Access Database with about 40,000 rows of data. If possible, I don't want to upsize the database because others need acess to it in the ACC97 format. Is there a way to use ODBC to connect to the ACC97 database so that I can use the SQL query capability of SQL server to query the database.

I know access allows you to write some SQL queries but I need the power of the SQL server and now it is a matter of curiosity because I've been searching for this answer for about 8 hours.

WHat do you mean by power of SQL Server ? If you do some queries on the data and you will not pass the query to access as a pass through query, SQL Server will always pull out the whole data to do the query.

HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de

connecting sql server

i created a database, when i query a simple select statement , i get an
error:
"Cannot open database requested in login 'XYZ_Database'.
Login fails, Login failed for user 'sa''
But when i change , the database name to Northwind, it works.
i checked that user rights of 'sa' for XYZ_database and Northwind are the
same?
i get the same error, when i used integrated security to connect too.
what would be the case here?
Hi,
It seems the database creator/owner might be some other user.
Execute the below command to check the database owner:-
sp_helpdb 'XYZ_Database'
If the owner is a non SA user , then change the database owner using:-
sp_changedbowner system procedure (Refer books online for information)
Thanks
Hari
MCDBA
"e-mid" <someone@.somewhere> wrote in message
news:#uip9U6VEHA.208@.TK2MSFTNGP10.phx.gbl...
> i created a database, when i query a simple select statement , i get an
> error:
> "Cannot open database requested in login 'XYZ_Database'.
> Login fails, Login failed for user 'sa''
>
> But when i change , the database name to Northwind, it works.
> i checked that user rights of 'sa' for XYZ_database and Northwind are the
> same?
> i get the same error, when i used integrated security to connect too.
> what would be the case here?
>
|||Hari;
user of the database seems to be sa; here is the properties of the database:
"XYZ_database 3.00 MB sa 7 Jun 21 2004 Status=ONLINE,
Updateability=READ_WRITE, UserAccess=MULTI_USER, Recovery=FULL,
Version=539, Collation=Latin1_General_CI_AS, SQLSortOrder=0,
IsTornPageDetectionEnabled, IsAutoCreateStatistics, IsAutoUpdateStatistics
80"
what else can be the problem?
"Hari Prasad" <hari_prasad_k@.hotmail.com> wrote in message
news:#Sh3WY6VEHA.1144@.TK2MSFTNGP10.phx.gbl...[vbcol=seagreen]
> Hi,
> It seems the database creator/owner might be some other user.
> Execute the below command to check the database owner:-
> sp_helpdb 'XYZ_Database'
> If the owner is a non SA user , then change the database owner using:-
> sp_changedbowner system procedure (Refer books online for information)
> Thanks
> Hari
> MCDBA
>
>
> "e-mid" <someone@.somewhere> wrote in message
> news:#uip9U6VEHA.208@.TK2MSFTNGP10.phx.gbl...
the
>
|||i am becoming insane.
i did not change even a letter but it is working now ?!
"e-mid" <someone@.somewhere> wrote in message
news:u7BQSe6VEHA.2520@.TK2MSFTNGP12.phx.gbl...
> Hari;
> user of the database seems to be sa; here is the properties of the
database:[vbcol=seagreen]
> "XYZ_database 3.00 MB sa 7 Jun 21 2004 Status=ONLINE,
> Updateability=READ_WRITE, UserAccess=MULTI_USER, Recovery=FULL,
> Version=539, Collation=Latin1_General_CI_AS, SQLSortOrder=0,
> IsTornPageDetectionEnabled, IsAutoCreateStatistics, IsAutoUpdateStatistics
> 80"
> what else can be the problem?
> "Hari Prasad" <hari_prasad_k@.hotmail.com> wrote in message
> news:#Sh3WY6VEHA.1144@.TK2MSFTNGP10.phx.gbl...
an
> the
>
|||Good.
Thanks
Hari
MCDBA
"e-mid" <someone@.somewhere> wrote in message
news:OFRlQt6VEHA.2408@.tk2msftngp13.phx.gbl...[vbcol=seagreen]
> i am becoming insane.
> i did not change even a letter but it is working now ?!
>
> "e-mid" <someone@.somewhere> wrote in message
> news:u7BQSe6VEHA.2520@.TK2MSFTNGP12.phx.gbl...
> database:
IsAutoUpdateStatistics[vbcol=seagreen]
> an
are[vbcol=seagreen]
too.
>

connecting sql server

i created a database, when i query a simple select statement , i get an
error:
"Cannot open database requested in login 'XYZ_Database'.
Login fails, Login failed for user 'sa''
But when i change , the database name to Northwind, it works.
i checked that user rights of 'sa' for XYZ_database and Northwind are the
same?
i get the same error, when i used integrated security to connect too.
what would be the case here?Hi,
It seems the database creator/owner might be some other user.
Execute the below command to check the database owner:-
sp_helpdb 'XYZ_Database'
If the owner is a non SA user , then change the database owner using:-
sp_changedbowner system procedure (Refer books online for information)
Thanks
Hari
MCDBA
"e-mid" <someone@.somewhere> wrote in message
news:#uip9U6VEHA.208@.TK2MSFTNGP10.phx.gbl...
> i created a database, when i query a simple select statement , i get an
> error:
> "Cannot open database requested in login 'XYZ_Database'.
> Login fails, Login failed for user 'sa''
>
> But when i change , the database name to Northwind, it works.
> i checked that user rights of 'sa' for XYZ_database and Northwind are the
> same?
> i get the same error, when i used integrated security to connect too.
> what would be the case here?
>|||Hari;
user of the database seems to be sa; here is the properties of the database:
"XYZ_database 3.00 MB sa 7 Jun 21 2004 Status=ONLINE,
Updateability=READ_WRITE, UserAccess=MULTI_USER, Recovery=FULL,
Version=539, Collation=Latin1_General_CI_AS, SQLSortOrder=0,
IsTornPageDetectionEnabled, IsAutoCreateStatistics, IsAutoUpdateStatistics
80"
what else can be the problem?
"Hari Prasad" <hari_prasad_k@.hotmail.com> wrote in message
news:#Sh3WY6VEHA.1144@.TK2MSFTNGP10.phx.gbl...
> Hi,
> It seems the database creator/owner might be some other user.
> Execute the below command to check the database owner:-
> sp_helpdb 'XYZ_Database'
> If the owner is a non SA user , then change the database owner using:-
> sp_changedbowner system procedure (Refer books online for information)
> Thanks
> Hari
> MCDBA
>
>
> "e-mid" <someone@.somewhere> wrote in message
> news:#uip9U6VEHA.208@.TK2MSFTNGP10.phx.gbl...
> > i created a database, when i query a simple select statement , i get an
> > error:
> >
> > "Cannot open database requested in login 'XYZ_Database'.
> > Login fails, Login failed for user 'sa''
> >
> >
> > But when i change , the database name to Northwind, it works.
> >
> > i checked that user rights of 'sa' for XYZ_database and Northwind are
the
> > same?
> >
> > i get the same error, when i used integrated security to connect too.
> >
> > what would be the case here?
> >
> >
>|||i am becoming insane.
i did not change even a letter but it is working now '!
"e-mid" <someone@.somewhere> wrote in message
news:u7BQSe6VEHA.2520@.TK2MSFTNGP12.phx.gbl...
> Hari;
> user of the database seems to be sa; here is the properties of the
database:
> "XYZ_database 3.00 MB sa 7 Jun 21 2004 Status=ONLINE,
> Updateability=READ_WRITE, UserAccess=MULTI_USER, Recovery=FULL,
> Version=539, Collation=Latin1_General_CI_AS, SQLSortOrder=0,
> IsTornPageDetectionEnabled, IsAutoCreateStatistics, IsAutoUpdateStatistics
> 80"
> what else can be the problem?
> "Hari Prasad" <hari_prasad_k@.hotmail.com> wrote in message
> news:#Sh3WY6VEHA.1144@.TK2MSFTNGP10.phx.gbl...
> > Hi,
> >
> > It seems the database creator/owner might be some other user.
> >
> > Execute the below command to check the database owner:-
> >
> > sp_helpdb 'XYZ_Database'
> >
> > If the owner is a non SA user , then change the database owner using:-
> >
> > sp_changedbowner system procedure (Refer books online for information)
> >
> > Thanks
> > Hari
> > MCDBA
> >
> >
> >
> >
> > "e-mid" <someone@.somewhere> wrote in message
> > news:#uip9U6VEHA.208@.TK2MSFTNGP10.phx.gbl...
> > > i created a database, when i query a simple select statement , i get
an
> > > error:
> > >
> > > "Cannot open database requested in login 'XYZ_Database'.
> > > Login fails, Login failed for user 'sa''
> > >
> > >
> > > But when i change , the database name to Northwind, it works.
> > >
> > > i checked that user rights of 'sa' for XYZ_database and Northwind are
> the
> > > same?
> > >
> > > i get the same error, when i used integrated security to connect too.
> > >
> > > what would be the case here?
> > >
> > >
> >
> >
>|||Good. :)
Thanks
Hari
MCDBA
"e-mid" <someone@.somewhere> wrote in message
news:OFRlQt6VEHA.2408@.tk2msftngp13.phx.gbl...
> i am becoming insane.
> i did not change even a letter but it is working now '!
>
> "e-mid" <someone@.somewhere> wrote in message
> news:u7BQSe6VEHA.2520@.TK2MSFTNGP12.phx.gbl...
> > Hari;
> >
> > user of the database seems to be sa; here is the properties of the
> database:
> >
> > "XYZ_database 3.00 MB sa 7 Jun 21 2004 Status=ONLINE,
> >
> > Updateability=READ_WRITE, UserAccess=MULTI_USER, Recovery=FULL,
> >
> > Version=539, Collation=Latin1_General_CI_AS, SQLSortOrder=0,
> >
> > IsTornPageDetectionEnabled, IsAutoCreateStatistics,
IsAutoUpdateStatistics
> > 80"
> >
> > what else can be the problem?
> >
> > "Hari Prasad" <hari_prasad_k@.hotmail.com> wrote in message
> > news:#Sh3WY6VEHA.1144@.TK2MSFTNGP10.phx.gbl...
> > > Hi,
> > >
> > > It seems the database creator/owner might be some other user.
> > >
> > > Execute the below command to check the database owner:-
> > >
> > > sp_helpdb 'XYZ_Database'
> > >
> > > If the owner is a non SA user , then change the database owner using:-
> > >
> > > sp_changedbowner system procedure (Refer books online for information)
> > >
> > > Thanks
> > > Hari
> > > MCDBA
> > >
> > >
> > >
> > >
> > > "e-mid" <someone@.somewhere> wrote in message
> > > news:#uip9U6VEHA.208@.TK2MSFTNGP10.phx.gbl...
> > > > i created a database, when i query a simple select statement , i get
> an
> > > > error:
> > > >
> > > > "Cannot open database requested in login 'XYZ_Database'.
> > > > Login fails, Login failed for user 'sa''
> > > >
> > > >
> > > > But when i change , the database name to Northwind, it works.
> > > >
> > > > i checked that user rights of 'sa' for XYZ_database and Northwind
are
> > the
> > > > same?
> > > >
> > > > i get the same error, when i used integrated security to connect
too.
> > > >
> > > > what would be the case here?
> > > >
> > > >
> > >
> > >
> >
> >
>

connecting sql server

i created a database, when i query a simple select statement , i get an
error:
"Cannot open database requested in login 'XYZ_Database'.
Login fails, Login failed for user 'sa''
But when i change , the database name to Northwind, it works.
i checked that user rights of 'sa' for XYZ_database and Northwind are the
same?
i get the same error, when i used integrated security to connect too.
what would be the case here?Hi,
It seems the database creator/owner might be some other user.
Execute the below command to check the database owner:-
sp_helpdb 'XYZ_Database'
If the owner is a non SA user , then change the database owner using:-
sp_changedbowner system procedure (Refer books online for information)
Thanks
Hari
MCDBA
"e-mid" <someone@.somewhere> wrote in message
news:#uip9U6VEHA.208@.TK2MSFTNGP10.phx.gbl...
> i created a database, when i query a simple select statement , i get an
> error:
> "Cannot open database requested in login 'XYZ_Database'.
> Login fails, Login failed for user 'sa''
>
> But when i change , the database name to Northwind, it works.
> i checked that user rights of 'sa' for XYZ_database and Northwind are the
> same?
> i get the same error, when i used integrated security to connect too.
> what would be the case here?
>|||Hari;
user of the database seems to be sa; here is the properties of the database:
"XYZ_database 3.00 MB sa 7 Jun 21 2004 Status=ONLINE,
Updateability=READ_WRITE, UserAccess=MULTI_USER, Recovery=FULL,
Version=539, Collation=Latin1_General_CI_AS, SQLSortOrder=0,
IsTornPageDetectionEnabled, IsAutoCreateStatistics, IsAutoUpdateStatistics
80"
what else can be the problem?
"Hari Prasad" <hari_prasad_k@.hotmail.com> wrote in message
news:#Sh3WY6VEHA.1144@.TK2MSFTNGP10.phx.gbl...
> Hi,
> It seems the database creator/owner might be some other user.
> Execute the below command to check the database owner:-
> sp_helpdb 'XYZ_Database'
> If the owner is a non SA user , then change the database owner using:-
> sp_changedbowner system procedure (Refer books online for information)
> Thanks
> Hari
> MCDBA
>
>
> "e-mid" <someone@.somewhere> wrote in message
> news:#uip9U6VEHA.208@.TK2MSFTNGP10.phx.gbl...
the[vbcol=seagreen]
>|||i am becoming insane.
i did not change even a letter but it is working now '!
"e-mid" <someone@.somewhere> wrote in message
news:u7BQSe6VEHA.2520@.TK2MSFTNGP12.phx.gbl...
> Hari;
> user of the database seems to be sa; here is the properties of the
database:
> "XYZ_database 3.00 MB sa 7 Jun 21 2004 Status=ONLINE,
> Updateability=READ_WRITE, UserAccess=MULTI_USER, Recovery=FULL,
> Version=539, Collation=Latin1_General_CI_AS, SQLSortOrder=0,
> IsTornPageDetectionEnabled, IsAutoCreateStatistics, IsAutoUpdateStatistics
> 80"
> what else can be the problem?
> "Hari Prasad" <hari_prasad_k@.hotmail.com> wrote in message
> news:#Sh3WY6VEHA.1144@.TK2MSFTNGP10.phx.gbl...
an[vbcol=seagreen]
> the
>|||Good.
Thanks
Hari
MCDBA
"e-mid" <someone@.somewhere> wrote in message
news:OFRlQt6VEHA.2408@.tk2msftngp13.phx.gbl...
> i am becoming insane.
> i did not change even a letter but it is working now '!
>
> "e-mid" <someone@.somewhere> wrote in message
> news:u7BQSe6VEHA.2520@.TK2MSFTNGP12.phx.gbl...
> database:
IsAutoUpdateStatistics[vbcol=seagreen]
> an
are[vbcol=seagreen]
too.[vbcol=seagreen]
>

Sunday, February 19, 2012

connecting in a script to another db

hi.

I've tried to use the exec sql connect to ... in query analyzer, but could not
get it to parse.

Can someone show me how in a script, say the middle, I can connect to another
database and execute the remaining script lines there.

This way I can have a script update two separate db's at once.

Thanks
Jeff

Jeff KishJeff,

You can specify the from clause of SQL statements as
DATABASE.OWNER.TABLE, as long as they are on the same SQL Server. You
may also utilize the USE DATABASE command to change which database you
script will execute in. But, if you have different servers you want to
access, then that will not work unless you have set up Linked Servers.
In which case you would add the servername to the beginning of your
sting: SERVERNAME.DATABASE.OWNER.TABLE.

Update Table1 set C1 = 'YES' from Table1 T1, Table2 T2 where
T1.ReportID = T2ReportID

use DB2 --This Example will use both Databases to update the column

Update Table 4 set C5 = 'Report Printed' from Table4 T4, DB1.DBO.Table1
T1 where T4.ReportID = T1.ReportID

Steve|||On 23 Mar 2006 13:16:41 -0800, "sdyckes" <stephendyckes@.gmail.com> wrote:

>Jeff,
> You can specify the from clause of SQL statements as
>DATABASE.OWNER.TABLE, as long as they are on the same SQL Server. You
>may also utilize the USE DATABASE command to change which database you
>script will execute in. But, if you have different servers you want to
>access, then that will not work unless you have set up Linked Servers.
>In which case you would add the servername to the beginning of your
>sting: SERVERNAME.DATABASE.OWNER.TABLE.
>Update Table1 set C1 = 'YES' from Table1 T1, Table2 T2 where
>T1.ReportID = T2ReportID
>use DB2 --This Example will use both Databases to update the column
>Update Table 4 set C5 = 'Report Printed' from Table4 T4, DB1.DBO.Table1
>T1 where T4.ReportID = T1.ReportID
>Steve
Thanks Steve. They will be on the same SQL Server, so I can run with this.

Regards
Jeff Kish