I have an application in classic ASP, and a database in SQL server 2005.
I transfer the database in SQL server express edition and I have one strange problem, I can see the tables in the database in this way:
information_Schema.dbo.test, so when I execute SQL command
select * From test
I get error that it can't find the table.
When I execute
select * From information_Schema.dbo.test
I do get results.
The problem is that my application is many many files and I can't rewrite the SQL commands.
Is there any way to find a solution in SQL without changing anything in my application?
I would guess you are not connecting to the information_Schema database but to some other db that does not contain the table. Did you put the table in the wrong place(Information_Schema doesn't sound like a typical application db location to me) or is your connection wrong?
Related
I want to move the data from a DB to another DB where the two DB's are in two different Sybase servers.
I have tried
"INSERT INTO <target_table_name>
LOCATION target_server.target_database
SELECT FROM (source table or query);"
I have executed the above statements from the source Sybase server in RapidSQL tool but it is throwing an error "Incorrect Syntax near LOCATION".
Thanks
You could use "Component Integration Services". A table on another Sybase server is made to appear locally, as if it were a local table.
You (or the DBA) has to set up Component Integration Services and then set up the table (as a proxy table.)
If you just need the table to be copied over occasionally Meet is right - bulk copy with bcp is the thing. Look that up in the Sybase Utilities guide.
I am new to MS SQL and I am trying to do something that seems simple but is driving me crazy.
I want to write a query to pull data from two databases. Each database is on a different instance on the same DEV machine. (one is MS SQL 2008 and the other MS SQL 2005). I am using the Microsoft SQL Server Management Studio (MSSMS).
I have the basics figured out. I know the format of the query and what I need to do. My big problem is figuring out what the NAME of each server is?
SELECT LastName
FROM [servername1].CHA2.dbo.Customer
UNION
SELECT LastName
FROM [servername2].OBXKites.dbo.Contact
ORDER BY LastName
I used the server name that I connect to MSSMS (DLPT\HENRY) with and what is also returned by ##SERVERNAME
SELECT ##SERVERNAME returns DLPT\HENRY
I tried
DLPT\HENRY.CHA2.dbo.Customer
did not work
I tried it without the DLPT HENRY.CHA2.dbo.Customer
did not work
I need to future out what the NAME of the server is to use in the query.
[DLPT\HENRY].CHA2.dbo.Customer
The namo contains a backslash which is normally illegal in an identifier. You surround illegal names with brackets.
Note that you surround just the server name. In other words, it is [DLPT\HENRY].CHA2.dbo.Customer, not [DLPT\HENRY.CHA2.dbo.Customer].
You have to configure Linked servers. Then only different instances of SQL Server are able to communicate with each other.
Unfortunately you can't access tables in databases in separate SQL Server instances by default. You have a couple of options here - neither are simple and might require help from a DBA:
1) Use linked servers like this:
http://technet.microsoft.com/en-us/library/ff772782(v=sql.110).aspx
Then you will be able to refer to the second table in the format INSTANCENAME.DatabaseName.SchemaName.TableName
2) Use replication to get the table from the second database into the first database. Then the contents of the second table will be synched to the first database in more or less real time
Read about SQL Replication here
I'm running into a problem when accessing a SQL Server table from an Oracle setup via ODBC.
I can access 90% of the tables absolutely fine, but there's a few tables that have a name that's longer than 30 characters. Whenever I try to interact with the table (describes, selects, etc) Oracle throws an "identifier too long" error and gives up.
Is there a way to coax Oracle into playing nice with the SQL Server tables?
Assuming that we are talking about an Oracle database that has a database link created to a SQL Server database via Heterogeneous Services, you would need to write code using the DBMS_HS_PASSTHROUGH package to interact with the tables in question. You'd also need to use this package if you have tables where there are column names that are not valid Oracle identifiers.
I need to transfer certain information out of our SQL Server database into an MS Access database. I've already got the access table structure setup. I'm looking for a pure sql solution; something I could run straight from ssms and not have to code anything in c# or vb.
I know this is possible if I were to setup an odbc datasource first. I'm wondering if this is possible to do without the odbc datasource?
If you want a 'pure' SQL solution, my proposal would be to connect from your SQL server to your Access database making use of OPENDATASOURCE.
You can then write your INSERT instructions using T-SQL. It will look like:
INSERT INTO OPENDATASOURCE('Microsoft.Jet.OLEDB.4.0','Data Source=myDatabaseName.mdb')...[myTableName] (insert instructions here)
The complexity of your INSERTs will depend on the differences between SQL and ACCESS databases. If tables and fields have the same names, it will be very easy. If models are different, you might have to build specific queries in order to 'shape' your data, before being able to insert it into your MS-Access tables and fields. But even if it gets complex, it can be treated through 'pure SQL'.
Consider setting up your Access db as a linked server in SQL Server. I found instructions and posted them in an answer to another SO question. I haven't tried them myself, so don't know what challenges you may encounter.
But if you can link the Access db, I think you may then be able to execute an insert statement from within SQL Server to add your selected SQL Server data to the Access table.
Here's a nice solution for ur question
http://www.codeproject.com/Articles/13128/Exporting-Data-from-SQL-to-Access-in-Mdb-File
I need to copy some records from our SQLServer 2005 test server to our live server. It's a flat lookup table, so no foreign keys or other referential integrity to worry about.
I could key-in the records again on the live server, but this is tiresome. I could export the test server records and table data in its entirety into an SQL script and run that, but I don't want to overwrite the records present on the live system, only add to them.
How can I select just the records I want and get them transferred or otherwise into the live server? We don't have Sharepoint, which I understand would allow me to copy them directly between the two instances.
If your production SQL server and test SQL server can talk, you could just do in with a SQL insert statement.
first run the following on your test server:
Execute sp_addlinkedserver PRODUCTION_SERVER_NAME
Then just create the insert statement:
INSERT INTO [PRODUCTION_SERVER_NAME].DATABASE_NAME.dbo.TABLE_NAME (Names_of_Columns_to_be_inserted)
SELECT Names_of_Columns_to_be_inserted
FROM TABLE_NAME
I use SQL Server Management Studio and do an Export Task by right-clicking the database and going to Task>Export. I think it works across servers as well as databases but I'm not sure.
An SSIS package would be best suited to do the transfer, it would take literally seconds to setup!
I would just script to sql and run on the other server for quick and dirty transferring. If this is something that you will be doing often and you need to set up a mechanism, SQL Server Integration Services (SSIS) which is similar to the older Data Transformation Services (DTS) are designed for this sort of thing. You develop the solution in a mini-Visual Studio environment and can build very complex solutions for moving and transforming data.