How Do I Select From Another Server
Oct 6, 2006I need to back up a table from serverA to my machine
I guess I do: select * from databaseA.myTable into databaseB.mytabel
but how do I specify that databaA is in other server.
Thankse
I need to back up a table from serverA to my machine
I guess I do: select * from databaseA.myTable into databaseB.mytabel
but how do I specify that databaA is in other server.
Thankse
I need to write a select statement that take the upper table and select the lower table.
View 3 Replies View RelatedI have the linked server connection created and works perfectly well. I mean I am able to see the tables while I am on my database.
how do I write a SQL statement to reference the linked server ?
I tried the following:
Select top 100 * from casmpogdbspr1.MPOG_Collations.dbo.AsaClass_Cleaned
Then I get the error message....
Msg 7314, Level 16, State 1, Line 1
The OLE DB provider "SQLNCLI10" for linked server "casmpogdbspr1" does not contain the table ""MPOG_Collations"."dbo"."AsaClass_Cleaned"". The table either does not exist or the current user does not have permissions on that table.
I am trying to install SQL Server Sep 2005 CTP - ENTERPRISE, there are
View 1 Replies View RelatedI need to investigate about what happened to our production server at the last weekend.i restored it to another server which is development. I restored it under a name "old_master_2015_07_10".
But if I run a query
SELECT *
FROM [old_master_2015_07_10].[sys].[servers]
it actually selects from master.sys.servers, not from my old_master... In order to prove it, I created a linked server in this, development server, and if I run SELECT * FROM [old_master_2015_07_10].[sys].[servers], it selects it. And in database selection drop-down box I also selected old_ master_ 2015_07_10. What I think it apparently recognizes familiar names like sys.servers and redirects the query to the master.
What I can do to select really from old_master_2015_07_10 database? I already thought about renaming sys.servers to something different, but did not do it not to break something in master in case if SQL Server will run it in master as well.
I created a linked server on server A to server B as follows...
USE master;
GO
EXEC sp_addlinkedserver
'B',
N'SQL Server'
GO
...in mgt studio (in a connection to A) from my local where as a person with sys admin rights on both A and B I'm having no problems connecting to either and running queries. When I run a query from a connection on A as select * from .[a db on B] .[an owner on B].[a table on B], I get an error that says Login failed for user 'NT AUTHORITYANONYMOUS LOGON'.
I believe both A and B are in the same domain
the default behavior that I saw checked in the linked server's security properties was "connection will be made using the logins current security context".
when change the default and clicked and entered "this security context" as domainuserid and password, rerun the query, I get error Login failed for user 'domain nameuserid'.
is there a simple way to get this to work, at least for test purposes? I even tried playing with the login mappings but nothing seemed to work.
I have a single form that the users can do lookups for items. We have two locations each with its own SQL Server and database. Trying to use an IF...THEN statement as they select the DB they want to query it then creates the connection string for that particular database. I haven't a clue on how to do this. If someone could point me to the documentation to do this I would really appreciate it. <%@ Page Language="VB" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDB" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Sub get_Dies(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim dbConnection As New SqlConnection
If ddlDatabase.SelectedValue = "db2" Then
??? dbConnection = "server=server2;Database=db2;UID=user;PWD=pass"
dbConnection.Open()
Else
??? dbConnection = "server=server1;Database=db1;UID=user;PWD=pass"
dbConnection.Open()
End If
Dim sqlString As String = " sql statement"
Dim dbCommand As New SqlCommand(sqlString, dbConnection)
Dim dbDataReader As SqlDataReader
dbDataReader = dbCommand.ExecuteReader(CommandBehavior.CloseConnection)
gvDies.DataSource = dbDataReader
gvDies.DataBind()
dbConnection.Close()
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Die Usage Lookup</title>
<link rel="stylesheet" href="/intranet.css" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<div>
Find dies matching:
<asp:TextBox ID="tbDies" runat="server" /><br />
Select database:
<asp:DropDownList id="ddlDatabase" runat="server" AutoPostBack="true" OnSelectedIndexChanged="get_Dies">
<asp:ListItem Text="" Selected="true" Value="" />
<asp:ListItem Text="DB1" Value="db1" />
<asp:ListItem Text="DB2" Value="db2" />
</asp:DropDownList>
<asp:gridview ID="gvDies" runat="server" GridLines="none" >
</asp:gridview>
</div>
</form>
</body>
</html>
I have a table "tbNews" in my database with N_ID, N_Content...
eg:
N_ID N_Content
1 Hello
3 How are you?
14 Are you there?
23 Can you help me?
32 ABC
33 CDE
36 EFG
If I have my N_ID = n (with n=1,3...) , can I select my records with next 1,2 or pre 1,2
eg: I have my N_ID=23, -->can I have got N_ID=3, 14 or N_ID=32, 33 ?
N_ID N_Content
3 How are you?
14 Are you there?
or
32 ABC
33 CDE
Please help me have a Select clause!
Thanhs all.
Hi all, in SQL 2000 I can select data from a different server using the sintax
"select * from server_name.db_name.owner.table_name".
Can i do the same thing with a table function (e.g "select * from server_name.db_name.owner.MyFun_name()")?
Is there a way to do it?
Thank you all, Andrew
There is a column for Name with data type varchar 50 the input data is like Alok Kumar, Sunita kuamri, Rohit Gupta Like that. The column contains the data as Combination of First name and second name.I would like to write a select query for selecting first part of name like Alok, Sunit, Rohit and so on only, ignoring the second part of name.
View 3 Replies View RelatedHello.
I have a parameter with multi value option.
When I run the report in Visual studio, The first value in the drop down of this parameter is (Select All).
When I check this option it check all the other values for this parameter and when I unCheck this value it uncheck all the ther values for this parameter.
The problem is thet when I'm publishing the report to the server and then open it in IE the (Select All) value does't appear and I only get all the other values.
Any body know how to fix this?
Thanks.
Hello all,
I have two mult-value parameters in my report. Both of them working with selecting one or more values. But, when I test using "(Select All)" values for both parameters , only one parameter works. The "available values" for these two parameters are both from the data set.
select distinct ProductType
from Product
order by ProductType
Any suggestion? thx
I am unable to the access on table even after providing the SELECT permission on table.
Used Query by me :
Here Test is schema ; Card is table ; User is Satish
To grant select on Table
GRANT SELECT ON TEST.Card TO satish
Even after this it is not working, So provided select on schema also.
used query : GRANT SELECT ON SCHEMA::TESTÂ TO Satish.
Hi all,
I copied and executed the following sql code in my SQL Server Management Studio Express (SSMSE):
--SELECTeg8.sql from SELECT-Using correlated subqueries of MSDN2 SELECT Examples--
USE AdventureWorks ;
GO
SELECT DISTINCT Name
FROM Production.Product p
WHERE EXISTS
(SELECT *
FROM Production.ProductModel pm
WHERE p.ProductModelID = pm.ProductModelID
AND pm.Name = 'Long-sleeve logo jersey') ;
GO
-- OR
USE AdventureWorks ;
GO
SELECT DISTINCT Name
FROM Production.Product
WHERE ProductModelID IN
(SELECT ProductModelID
FROM Production.ProductModel
WHERE Name = 'Long-sleeve logo jersey') ;
GO
=========================================
I got:
Results Messages
Name o row affected
========================================
I think I did not get a complete output from this job. Please help and advise whether I should search somewhere in the SSMSE for the complete results or I should correct some code statements in my SELECTeg8.sql for obtaining the complete results.
Thanks in advance,
Scott Chang
I have a report that uses different datasets based on the year selected by a user.
I have a year_id parameter that sets a report variable named dataset_chosen. I have varified that these are working correctly together.
I have attempted populating table cell data to display from the chosen dataset. As yet to no avail.
How could I display data from the dataset a user selects via the year_id options?
Dear All
I need to cerate a SP that SELECTS all the records from a table WHERE the first letter of each records starts with 'A' or 'B' or 'C' and so on. The letter is passed via a parameter from a aspx web page, I was wondering that someone can help me in the what TSQL to use I am not looking for a solution just a poin in the right direction. Can you help.
Thanks Ross
I have a problem where my users complain that a select statement takes too long, at 90 seconds, to read 120 records out of a database.
The select statement reads from 9 tables three of which contain 1000000 records, the others contain between 100 and 250000 records.
I have checked that each column in the joins are indexed - they are (but some of them are clustered indexes, not unclustered).
I have run the SQL Profiler trace from the run of the query through the "Database Engine Tuning Advisor". That just suggested two statistics items which I added (no benefit) and two indexes for tables that are not involved at all in the query (I didn't add these).
I also ran the query through the Query window in SSMS with "Include Actual Execution Plan" enabled. This showed that all the execution time was being taken up by searches of the clustered indexes.
I have tried running the select with just three tables involved, and it completes fast. I added a fourth and it took 7 seconds. However there was no WHERE clause for the fourth table, so I got a cartesian product which might have explained the problem.
So my question is: Is it normal for such a type of read query to take 90 seconds to complete?
Is there anything I could do to speed it up.
Any other thoughts?
Thanks
Hi All
I am using SQL Server 2005 with SP2. I have multi select parameter in the report. In SP2 reporting services gives Select All option in the drop down.
Is there any way I can remove that option from the list?
Thanks
I have a table which I need to obtain data from but am having a problem with select statement.
Specifically, I have a table that has multiple records for a particular hostName where the name of the host is either a shortname (say "Larry") or a long name (say "Larry's").
I need to display only the long names (NOT THE SHORT NAME records with the similar hostName).
Select winsHostName, len(winsHostName) from winsData where winsClientIPAddress IN (SELECT winsClientIPAddress from winsData Group By winsClientIPAddress Having count(winsClientIpAddress) > 1) Order by winsHostName
Which returns data
Name Length
ATVDDR 6 ATVDDR1 7
This is a s far as I can get but,
Now, I need to list all remaining table fields based on the Name with the longer length and this is where I run into trouble.
The output should read per below with the remaining table fields which I cannot seem to extract with nested select statement
Name IP Addr Location
ATVDDR1 1.1.1.1 2ndFloor
I tried adding another GROUP BY by this gets me no where because I do not need to execute another aggregate in select statement. Maybe I need to use INNER JOIN
Please advise any assistance.
string connectionString;
string queryString;
SqlConnection sqlconnection;connectionString="server=fatyi;integrated security=SSPI;initial catalog=tempdb";
queryString="insert into products values(5,'BaoMa',200596,900000,0)";
sqlconnection=new SqlConnection(connectionString);
SqlCommand addScorce=new SqlCommand(queryString,sqlconnection);
sqlconnection.Open();
addScorce.ExecuteNonQuery();
sqlconnection.Close();
help to find out why? if i use "select" it can transaction in this code. And here "insert" .My WebAplication could work,but have no result of "insert".and no error information.The "insert" purview of "products" table have selected.
I help you can help me to point out maybe where is error.
Thank you !
Hi all, i have a trouble when i want to select 100.000.000 records in a table, Pls, give me a solution thanks
View 4 Replies View RelatedHi,
I need to import data from another server on recurring basis. Before inserting the data, I need to perform some checking e.g. check the last update date and time.
I am thinking of scheduling SQL job that run SQL Query. The SQL query will make use of cursor to check each row, to decide what to do with the imported data
Is it the right way to import the data? However I did not know how to select data from another server using T-SQL. Can help? I am using SQL 2000
Thanks in advance
Regards,
Christine
I use 'select top 10 customerID, customerName from customers' on one
testing maching 'Test1', it works.
But after restore the database from 'Test1' to 'Test2', the same sql
select top statement does not work. Both machine are SQL2k.
appreciate your help!
-D
Hello everybody.
I am attempting the following relatively simple SQL.
UPDATE Server.db.dbo.table1 SET Value = @Value
WHERE Id IN (SELECT Id FROM table2)
This update is taking up to 1 minute. However if I remove the select and replace with actual values the update is completed instantly ie
UPDATE Server.db.dbo.table1 SET Value = @Value
WHERE Id IN (id1, id2, id3)
The select is also instant if executed in isolation. But when these two statements are combined time taken is too long
Please note that the update is occurring on a different server and that table1 does contain update triggers.
Any ideas on why this is happening? Cheers!
Hi groupmates,
In MySQL, we can use limit for our selection. E.g.
select * from mytable limit 10, 20
means selecting [20] records of all information from the table [mytable] from the [10]th record
But in MS SQL, what can we do? Please help.
I am writing PHP to retrieve small data from a large volume of database. Please help
-stan
Hi,
Recently the powers-that-be migrated the largest databases from one server to another, more powerful server while keeping some support data on the original server. My problem: I need to run queries on tables spanning both database servers. Unfortunately, I can't find any documentation on how to do this. Does anyone have any ideas?
Thanks!
hi,i have three database servers with heterogeneous databases, and i have a sql server 2005 that should has a table that will be filled with records from the three servers every time period, so what would be the best technique to create this table with the scripts ????i used to use linked server + sql server agent jobs but usually for one linked server only, but this time i am afraid of the performance as there will be three linked servers, so i need ur suggestions.
View 2 Replies View RelatedI have a table like below
create table #temp
(
valid_id int not null,
valid_no varchar(50)
)
10001
20002
30011
40012
i need to select the valid no without '0' lie 1,2,11,12, how do i?
I have string as below:
InvoiceTemplateId= SOURCE.InvoiceTemplateId
,Name= SOURCE.Name
,DetailTotalUnitsQty= SOURCE.DetailTotalUnitsQty
,InsertedDate= SOURCE.InsertedDate
,UpdatedDate= SOURCE.UpdatedDate
,Distributor_Id= SOURCE.Distributor_Id
,InsertedBy= SOURCE.InsertedBy
,UpdatedBy= SOURCE.UpdatedBy
I need a string Like below:
Name= SOURCE.Name
,DetailTotalUnitsQty= SOURCE.DetailTotalUnitsQty
,InsertedDate= SOURCE.InsertedDate
,UpdatedDate= SOURCE.UpdatedDate
,Distributor_Id= SOURCE.Distributor_Id
,InsertedBy= SOURCE.InsertedBy
,UpdatedBy= SOURCE.UpdatedBy
So I need every thing except the First value before first comma .
The passwords in table 'users', column 'passwordencrypted' are encrypted. Someone enters a password and I'd like to compare if it is correct. The syntax below seems ok but nothing is returned. Why not?
OPEN SYMMETRIC KEY mykey DECRYPTION BY CERTIFICATE mycert;
DECLARE @mypw varchar(300);
SET @mypw = 'test';
SELECT * FROM users WHERE passwordencrypted = EncryptByKey(Key_GUID('mykey'), @mypw);
CLOSE SYMMETRIC KEY mykey;
I am trying to select leveling; I have table like this;
FACC_WID FACC_BKEY FACC_CODE FACC_DESC FACC_CODE_DESC FACC_DESC_CODE FACC_H1_L5_CODE FACC_H1_L5_DESC FACC_H1_L5_CODE_DESC FACC_H1_L5_DESC_CODE FACC_H1_L4_CODE FACC_H1_L4_DESC FACC_H1_L4_CODE_DESC FACC_H1_L4_DESC_CODE FACC_H1_L3_CODE
[Code] ...
Now I need to make 5 levels like this:
1
10
100
1001
100100
When column FACC_CODE have 1 char then its a level one so I put this in FACC_H1_L1_CODE..
I this possible in (SSIS)?
Hi All,
I need some help from u..
I wanted to know the exact flow behind SQL Server when we fire
SELECT select_list
[ FROM table_source ]
[ON Join_Condition]
[ WHERE search_condition ]
[ GROUP BY group_by_expression ]
[ HAVING search_condition ]
[ ORDER BY order_expression [ ASC | DESC ] ]
what is exact execution process mean which get first strike to server and then what followed then..
T.I.A
HiI currently have a select query with "Description = 'input from userhere'" which basically returns the associated row containing theDescription field exactly as typed by the user, however, would it bepossible to, if not found, return the closest match? I am usingMicrosoft Visual Studio 2005 with C# as language and Microsoft SQLServer 2005 as database.Regards,Lionel Pinkhard---avast! Antivirus: Outbound message clean.Virus Database (VPS): 0642-0, 2006/10/17Tested on: 2006/10/18 12:46:07 PMavast! - copyright (c) 1988-2006 ALWIL Software.http://www.avast.com
View 4 Replies View Related