I Cant Solve This Linked Server Problem, Can You?
Jun 25, 2004
We rebooted our main SQL Server (SQL2k). It had 5 linked servers setup, 2 on the same network and 3 on another network. After the reboot the linked sql servers on the other network only work some of the time when trying to access them via a linked server. The 2 linked servers on the same network have no problems at all. All the routes are setup properly and are persistant.
Linked servers
SameNetwork1 -- No Problems
SameNetwork2 -- No Problems
ServerOtherNetwork1 -- "sqlserver does not exist or access is denied. [SQLSTATE 42000] (Error 17)."
ServerOtherNetwork2 -- "sqlserver does not exist or access is denied. [SQLSTATE 42000] (Error 17)."
ServerOtherNetwork3 -- "sqlserver does not exist or access is denied. [SQLSTATE 42000] (Error 17)."
All SQL Server 2k Standard with 2 processor licenses and the latest service packs.
All have been setup as TCPIP and the port has been defined in the client network utility using the IP address not the name.
All servers can be "pinged" and you can pull up the physical drive folders from across the networks with no problems.
All linked servers are running windows 2000. The main server is running NT.
After the reboot only server1 was working with the linked server. The other 2 servers were getting either a timeout or "sqlserver does not exist or access is denied. [SQLSTATE 42000] (Error 17)."
I tried to fiddle with the linked servers by changing the passwords and got Server1 and Server2 working over the linked server connection but could not get server3 to work. After about 30 minutes or so I noticed that server 2 was working on and off. It was not consistant about failing or working. I decided to go home for the night. When I came in this morning, only Server2 works. Server1 and 3 do not at all.
I have a job setup to pull transactions from a table on server2 to our main sqlserver. This job was running every 5 minutes and it was failing here and there. I have now setup the job to run every 2 minutes and it has not failed for the past hour. When it does fail it gives the error above (server does not exist).
I really hope this makes sence to someone... lol :o
Thanks.
View 14 Replies
ADVERTISEMENT
Mar 25, 2002
Hi ,
On my Desktop i registered Production Server in Enterprise Manager
on that Server if i go to SecurityLinked Servers
There is another Server is already mapped, when i am trying to see the Tables under that one of the
Linked Server i am getting the Error message saying that
"Error 17 SQL Server does not exist or access denied"
if i went to Production Server location and if i try to see the tables i am able to see properly, no problems
why i am not able to see from my Desk top
i am using the sa user while mapping the Production Server on my DESKTOP using (ENTERPRISE MANAGER)
And i check the Client Network Utility in the Alias using Named Pipe only, i changed to TCP/IP still same problem
What might the Problem how can i see the Tables in Linked Server from my DESKTOP
Thanks
View 5 Replies
View Related
Apr 24, 2015
I am using Linked Server in SQL Server 2008R2 connecting to a couple of Linked Servers.
I was able to connect Linked Servers, but I cannot point to a specific database in a Linked Server, also, I cannot rename Linked Server's name.
How to point the linked server to a specific database? How to rename the Linked Server?
The following is the code that I am using right now:
USE [master]
GO
EXEC master.dbo.sp_addlinkedserver
@server = N'Machine123Instance456',
@srvproduct=N'SQL Server' ;
GO
EXEC sp_addlinkedsrvlogin 'Machine123Instance456', 'false', NULL, 'username', 'password'
View 6 Replies
View Related
Jul 18, 2006
Is there a way to bypass the syntax checking when adding a stored procedure via a script?
I have a script that has a LINKed server reference (see below) .
INSERT
INTO ACTDMSLINKED.ACTDMS.DBO.COILS ..etc.
ACTDMSLINKED does not exist at the time I need to add the stored procedure that references it.
PLEASE to not tell me to add the LINK and then run the script. This is not an option in this scenerio.
Thanks,
Terry
View 4 Replies
View Related
Jul 9, 2006
Hi Guys,
[VS2005, .NET 2.0 SQL Server Express]
I could really use some help with this one - as in desperately!:
I have a couple of database projects which run fine in Debug Mode from VS2005, but I can't get them to run outside of it.
The problem is that, for some reason, the login to the database file isn't succeeding. I'm getting the following errors:
.NET Project: System.Data.SqlClient.SqlException: Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed.
DotNetNuke 4.0.3 Project: ERROR: Could not connect to database specified in connectionString for SqlDataProvider. (I sometimes get a "The Server Version does not match the Database Version" error)
Here are my connection strings for the above two scenarios:
<connectionStrings> <add name="EpgDbConnection" connectionString="Data Source=.SQLEXPRESS;AttachDbFilename=C:ProjectsEpgEpg.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True" providerName="System.Data.SqlClient" /></connectionStrings>
<connectionStrings> <add name="SiteSqlServer" connectionString="Data Source=.SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|Database.mdf;" providerName="System.Data.SqlClient" /></connectionStrings>
My assumption is that I need to switch from Integrated Security (is that Windows Security?) to SQL Server Security, but I'm battling to do that effectively.
A pointer to a simple step-by-step guide would be fantastic, but, if there isn't such a thing available, I have a number of specific questions:
Question 1: Why does one need to switch from Integrated Security to SQL Server Security?
If I'm right, I suspect that my connection strings will become:
<connectionStrings> <add name="SiteSqlServer" connectionString="Data Source= (local);user id=gary;password=password;Connect Timeout=30" />
and
<connectionStrings> <add name="EpgDbConnection" connectionString="Data Source=(local); user id=gary;password=password;Connect Timeout=30" />
respectively.
Question 2: Are these strings correct?
(I receive a login failed error)
Question 3: How do I go about changing the Security Setting, using either VS2005 or SQL Server?
(I've modified permissions at a SQL Server Express level from Windows Authentication mode to SQL Server and Windows Authentication mode in SSMS, but the Authentication Method can't seem to be changed at the database file level. View connection string (under database properties), reveals an unalterable "Windows Authentication" Authentication Method.)
Question 4: I've managed to add a user and password at the SQL Server Express level. What roles should the user have?
I'd be very grateful for any help you could give me. I've tried everything I can find or think of and am not getting anywhere!
Thanks very much.
Regards
Gary
View 2 Replies
View Related
Jan 2, 2008
Hai,
we have a Dell pe 6600 server running for our ERP Application databases. version of Sql server is 2000 with sp4. OS is windows 2000 with SP 4 .we were running out of space in server and we planned to upgrade the harddisks.
after upgradation, the Performance of the server is very slow. Even zipping of .bak files from one drive to other is slow (which is not related to database). In old setup (before upgradation ) , to zip .bak files (backup files of DB's)(tot Size : 90 GB) use to take 3hrs 40 mins. Now it is taking more than 10 Hrs. There are no errors found in Windows Event viewer and SQL Server.
we logged a call with Dell and finally, dell said that they could not find any errors in raid configuration or harddisks. all the firmware and bios versions are up todate. Application vendor is also saying that, the database is fully optimized. we could not find out the reason for the sluggish performance and we feel that this is something to do with hardware or with raid configuration.
From our analysis,any activity that requires a read or write activity from the harddik is slow.( but server vendor is saying that there is no problem in the hardware.)
Activities analysed (all at zero load on server)
1) backup thru SQL Server - 40 mins (old setup)
backup thru SQL Server - 2 hrs (New setup)
2) zipping of .bak files (from Raid 5 HDD to Raid 1 HDD)
old setup - 3 hrs 40 mins
New setup - 8 hrs 30 mins
3) all the schedulers (both windows and sql server) are dead slow.
4) Maintenance jobs for databases
old setup - 5 - 6 Hrs
New setup - 11 - 12 hrs
after analysing all the above activities ,we came to a conclusion that the problem may not be with sql server.
But we could not trace out the problem till now. since it is the production server we are not able to take downtime that easily. i have given the old set up and new setup configuration below.
Note: the server lies with the same configuration in both old set up and new setup.(only harddisks are upgraded.
Please help me to solve this issue
As of now, we have decided to start from the scrap once again. before that can i get some help ???
old set up:
Raid 1 - 32 x 2 - (two Partitions C and D )
C - OS , D - Batch Files
Raid 5 - 72 x 5 - (two Partitions E and F ) (1 harddisk - Hotspare - 4 hdd will be used for raid)
E - .MDF Files , F - .BAK Files (Backup of database files will be stored here temporarily before moving it to tapes)
Raid 1 - 32 x 2 - (two Partitions G and H )
G - .LDF Files , H - to store the zipped .bak files ( we have a windows sceduler which zip the .bak files in E drive and place the .zip files in H drive)
New Set up:
Raid 1 - 72 x 2 - (two Partitions C: and D )
C - OS , D - Batch Files
Raid 5 - 300 x 5 - (two Partitions E and F ) (1 harddisk - Hotspare)
E - .MDF Files , F - .BAK Files (Backup of database files will be stored here temporarily before moving it to tapes)
Raid 1 - 72 x 2 - (two Partitions G and H )
G - .LDF Files , H - to store the zipped .bak files ( we have a windows sceduler which zip the .bak files in E drive and place the .zip files in H drive)
View 3 Replies
View Related
Nov 26, 2013
I execute the code below
declare @LastDate datetime
SELECT @LastDate = max([LastUpdate])
FROM [exhibitor].[dbo].[blgBelongs]
WHERE (([Table1]=@module1 OR [Table2]=@module2 )or ([Table2]=@module1 OR [Table1]=@module2 )
AND Exists (SELECT [Table1],[Table1ID] FROM [exhibitor].[dbo].[blgBelongs] WHERE table2=30 and table2ID=@dmn_ID))
Before I see @LastDate , I see this warning
Warning: Null value is eliminated by an aggregate or other SET operation.
View 7 Replies
View Related
Jan 3, 2007
I get this error when i try to connect with my sql,
I created my SQL with MS SQL 2005 Workgroup,
the error is:
Server Error in '/' Application.
The 'System.Web.Security.SqlMembershipProvider' requires a database schema compatible with schema version '1'. However, the current database schema is not compatible with this version. You may need to either install a compatible schema with aspnet_regsql.exe (available in the framework installation directory), or upgrade the provider to a newer version.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Configuration.Provider.ProviderException: The 'System.Web.Security.SqlMembershipProvider' requires a database schema compatible with schema version '1'. However, the current database schema is not compatible with this version. You may need to either install a compatible schema with aspnet_regsql.exe (available in the framework installation directory), or upgrade the provider to a newer version.
View 2 Replies
View Related
Mar 25, 2006
When i used MySql in my appliaction its working well, but now i shifted my web application on SQL Server2000 , its gives problem.
It gives this error at runtime...
The specified module could not be found.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.IO.FileNotFoundException: The specified module could not be found.Source Error:
Line 79: SqlCommand OcCom=new SqlCommand(Query,OdCon);
Line 80: SqlDataReader OdDat;
Line 81: OdCon.Open();
Line 82: OdDat=OcCom.ExecuteReader(CommandBehavior.CloseConnection);
Line 83: return OdDat;
i read ths stuff from all over and reinstall the Visual studio .NET2003 again . but still some is not solved.
So Pls help Me!!!!!!!!!!!!!!
Thanx
Manish
View 3 Replies
View Related
Sep 5, 2001
Lets say I want to delete a record in tableA. tableA has 5 foreign key tables.
Before I delete the row in tableA, I want to make sure I dont get any foreign key violation error. I dont want to make a cascading delete, since the record should not be deleted if it has child records.
Of course I could check all those tables before the delete. Anybody know of a better approach?
Regards,
Stefan
View 1 Replies
View Related
Jan 23, 2004
hi
I have a question:
why when we call a stored procedure in delphi
that the return in Null (Example Not Match data with our Select)
Error occured?
Please help me .
thanks alot.bye.
View 2 Replies
View Related
Jan 1, 2008
Hi! i need to know which tables in my database are not used by any stored procedure in my database.i need ur help.
View 2 Replies
View Related
Jan 10, 2008
hi,
i have a doubt whether constraints(for eg:default constraint ) can be applied on table variable or not. plz let me know. iam presenting the table variable which iam using.
declare @t table (a int constraint d default 1 ,b varchar(10) constraint a default 'india' )
insert into @t values ( 1,'ic')
thanks
View 2 Replies
View Related
Mar 5, 2008
hi,
I need to get values in a column of different rows to be comma seperated.
example:
table a
col1 col2 col3
1 a b
2 c d
3 e f
I want output like this
col1 col2 col3
1,2,3 a,c,e b,d,f
Thanks in advance.........
View 7 Replies
View Related
Mar 24, 2008
Help me out how to solve this requirement
Table_1
Col1Col2Col3Col4
1101Usr1WRK1
2101Usr2WRK1
Table_2
Col1Msg
101User %1 Logged on %2
Expected Output
User Usr1 logged on WRK1
User Usr2 logged on WRK1
View 2 Replies
View Related
Mar 2, 2007
I'm a beginer!
I host my web on a hosting service provider. But when I access an error occur:
Server Error in '/' Application.
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace:
[SqlException (0x80131904): An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +734867
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188
System.Data.SqlClient.TdsParser.Connect(Boolean& useFailoverPartner, Boolean& failoverDemandDone, String host, String failoverPartner, String protocol, SqlInternalConnectionTds connHandler, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection owningObject, Boolean aliasLookup) +820
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +628
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +170
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +130
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +28
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +424
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66
System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +496
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +82
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +105
System.Data.SqlClient.SqlConnection.Open() +111
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +121
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +137
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +83
System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +1770
System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +17
System.Web.UI.WebControls.DataBoundControl.PerformSelect() +149
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +70
System.Web.UI.WebControls.DetailsView.DataBind() +4
System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82
System.Web.UI.WebControls.DetailsView.EnsureDataBound() +181
System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +69
System.Web.UI.Control.EnsureChildControls() +87
System.Web.UI.Control.PreRenderRecursiveInternal() +41
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1360
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210
View 1 Replies
View Related
Oct 1, 2007
Hi,there are three tables:1) department---------------ID (primary key)name2) reports----------ID (p. key)depIDuserID3) users--------ID (p.key)nameI want to get in one query how many distinct users have made a report for each department.E.g.: table reports may look like this:ID depID userID1 1 12 1 13 1 34 3 65 4 8This gives:for dep 1: 2 distinct usersfor dep 2: 0for dep 3: 1 distinct userfor dep 4: 1 distinct userThanks for helpTartuffe
View 5 Replies
View Related
Nov 12, 2007
Hi, I am trying to update my table... but when i try to save my query.. i am getting the following error
Column 'SourceDBF.DEFPCT' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. This is my sproc...
UPDATE
Statements..ParticipantSourceSummary
SET
DeferralPct = DEFPCT,
BeginingBal = BEGBAL,
Deposits = DEPOSITS,
Withdraw = WITHDRAW,
GainLoss = GAINLOSS,
Others = OTHER,
EndingBal = ENDBALANCE,
VestPercent = VESTPCT,
VestBal = VESTBALANC
FROM
Statements..ParticipantSourceSummary ps
Join (
SELECT
p.ParticipantId,
cp.PlanId,
cs.SourceId,
@PeriodId PeriodId,
s.DEFPCT,
s.BEGBAL,
s.DEPOSITS,
s.WITHDRAW,
s.GAINLOSS,
s.OTHER,
s.ENDBALANCE,
s.VESTPCT,
s.VESTBALANC
FROM
SourceDBF s
INNER JOIN Statements..ClientPlan cp
ON s.PLAN_NUM = cp.ClientPlanId
INNER JOIN Statements..ClientSources cs
ON s.SOURCE_NUM = cs.ClientSourceId and cs.ClientId = @ClientId
Inner Join Statements..Participant p
on s.PART_ID = p.SSN
Where
s.Import = 1
GROUP BY
p.ParticipantId,
cp.PlanId,
cs.SourceId
) s
ONps.ParticipantId = s.ParticipantId
AND
ps.PlanId = s.PlanId
AND
ps.SourceId = s.SourceId
AND
ps.PeriodId = s.PeriodId any help will be appreciated.RegardsKaren
View 1 Replies
View Related
May 15, 2008
Hi all
i have a problem in my stored procedureUSE [eLocalize_System]
GO
/****** Object: StoredProcedure [dbo].[Insert_Branch] Script Date: 05/15/2008 16:03:23 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================ALTER PROCEDURE [dbo].[Insert_Branch]
(
@Building_No int
,@Street_Name nvarchar(50)
,@City nvarchar(50)
,@Postal_Code nvarchar(50)
,@Telephone nvarchar(50)
,@Fax nvarchar(50)
,@Client_Id int
,@Country_Id int
,@Row int output)
AS
Declare
@BranchCode int,
@Branch_Name nvarchar(50)
set @BranchCode=isnull((select Max(BranchCode) from dbo.Branch where Client_Id=(select Id from dbo.Client where Id=@Client_Id)),0);
set @BranchCode=@BranchCode+1
set @Branch_Name=(select City from dbo.Branch)+'+'+(select Name from dbo.Country where Id=(select Country_Id from dbo.Branch))INSERT INTO [eLocalize_System].[dbo].[Branch]
([Branch_Name],[BranchCode]
,[Building_No],[Street_Name]
,[City],[Postal_Code]
,[Telephone],[Fax]
,[Client_Id]
,[Country_Id])
VALUES
(@Branch_Name,@BranchCode ,
@Building_No ,@Street_Name
,@City ,@Postal_Code
,@Telephone ,@Fax
,@Client_Id
,@Country_Id)
set @Row = (select scope_identity())
return @Row
i want Branch_Name = City + Country
and how i do it if there is any update
Thanks for help
View 1 Replies
View Related
Jul 26, 2000
Subscriptions were created successfully at the following Subscribers:
SERVER330
SQL Server Enterprise Manager could not start the service 'MSDTC' on server 'SERVER330'.
5 - (Access is denied)
The subscription at Subscriber 'SERVER330' cannot be initialized immediately because the snapshot for this publication is not yet available. To initialize the subscription, start the Distribution Agent after the snapshot is available.
View 1 Replies
View Related
Jun 8, 2007
Hello friends,
I want to find only fifth row from a table please give me better solution.
thanks in adavance
regards
Harsh
View 4 Replies
View Related
May 13, 2006
could some one help in giveing solution for this tasks..
[CODE]
Task 1 : Get the first day and last day of the week
Ex: input : '04/12/2006'
Required ouput :
start_date End_date
04/09/200604/15/2006
Note :1. start_date should be sunday
2. end_date should be saturday
Task 2 -- Find the product sales week wise
Find the product sales week wise
Output Required:
gasstationID productClass week1 week2 week3 week4
-------------------- ------------ ----------- ----------- ----------- -----------
111 DSL 1 0 0 0
111 GAS 2 0 1 1
222 DSL 1 0 1 1
222 GAS 1 0 0 0
create table trial_sales(
gasstationIDbigint,
salesDatesmalldatetime,
gallonsbigint,
productClass varchar(4))
insert into trial_sales values(111,'11/01/2005',10000,'GAS')
insert into trial_sales values(111,'11/02/2005',1000,'GAS')
insert into trial_sales values(111,'11/02/2005',20000,'DSL')
insert into trial_sales values(222,'11/01/2005',10000,'GAS')
insert into trial_sales values(222,'11/02/2005',10000,'DSL')
insert into trial_sales values(111,'11/15/2005',1000,'GAS')
insert into trial_sales values(222,'11/15/2005',10000,'DSL')
insert into trial_sales values(111,'11/25/2005',1000,'GAS')
insert into trial_sales values(222,'11/25/2005',10000,'DSL')
Task 3 Display unique values
Display unique values in
create table t (colA varchar(25))
insert into t values('apple')
insert into t values('bat')
insert into t values('car')
ouput required:
a
b
c
e
l
p
r
t
Task : 4
I have a table in the database I am working with with the following columns:
(I have simplified this down for the sake of clarity)
int p1
int p2
int p3
int s1
date d1
string s1
There is no primary key and the table more resembles a log than anything.
e.g.
p1 p2 p3 s1 d1 s1
1 12 14 100 23May comment 2
1 12 14 800 22May comment 1
1 12 14 300 24May comment 3
1 12 15 100 22May comment 2
1 12 15 800 21May comment 1
2 12 15 100 23May comment 1
What I want to do is exttract the rows from the table where the combination
of p1 p2 and p3 is distinct/unique and the date is the most recent one for
all combinations of p1, p2, p3. So from the table above I would end up with
the resultset:
p1 p2 p3 s1 d1 s1
1 12 14 300 24May comment 3
1 12 15 100 22May comment 2
2 12 15 100 23May comment 1
Task 5
say i have the following data...
uId(int PK), productcode(int), quantity(int)
1,12,5
2,12,3
3,12,5
4,11,9
....and i have an order for productcode 12 with quantity of 6 products.
i need to select only enough rows to reach a quantity of 6.
in this case, i would want the first two rows which would give me a sum of
8.
how can i do this without looping through each record, getting the quantity
and exiting the loop when i have a sum >= 6?
Task 6
I have two tables as below, TABLE1 and TABLE2.
TABLE 1: Base
IDPNamePPrice
-------------------------------------
1A30
2B20
TABLE 2: History
IDLdateAmount
-------------------------------------
12005/8/750
The ID of TALBE1 is the primary key and the ID of TABLE2 is the foreign key.
What's the right T-SQL JOIN statement when I pass the date of 2005/8/7,
it will return the result as below:
LdatePNameAmount
------------------------------------
2005/8/7A50
2005/8/7Bnull
and when I pass the date of 2005/8/8, it will return the result as below:
LdatePNameAmount
------------------------------------
2005/8/8Anull
2005/8/8Bnull
Task : 7
Reverse the Name
create table sample_judge(
judge_namevarchar(50))
go
insert into sample_judge values ('J Smith')
insert into sample_judge values ('M Samuel')
insert into sample_judge values ('S Shan')
insert into sample_judge values ('K Anand')
insert into sample_judge values ('K K K K Anand')
insert into sample_judge values ('K R Shanth Anand')
insert into sample_judge values ('K R Shanth Anand Kumara Velu')
go
Expected Output :
Smith J
Samuel M
Shan S
Anand K
Anand K K K K
Shanth Anand K R
Shanth Anand Kumara Velu K R
[CODE]
thanks in adv
chakri
View 5 Replies
View Related
Feb 5, 2004
chiranjeevi
raveendra
sreenivasarao
koteswar
manoj
sangeetharanika
Here my query is
in the above names i want to find out the persons whoz names consist of exact 2 a's
eg output:
raveendra
assume that the names are ename and table name is emp.
Thanks in advance
Plz mail this qury to chiru_y2k@yahoo.com
Chiranjeevi
View 2 Replies
View Related
Feb 9, 2004
Hi,
I have two database servers and in this one is consists of tables and another one is for stored procedures ...
Here is my proble...
I want to access the stored procedures from my application(.net) ...
How to do...
Thanks in Advance
Chiru
View 1 Replies
View Related
Apr 18, 2004
I was working on the thread "Call stored procedure within SELECT statement "
but a funny thing happend
i was going to suggest using a function instead of a proc but i cant seem to get it to run
create function dbo.Fitem(@item int)
Returns table
as
Return (select item, Result=(value * value) from tba
where item = @item)
GO
select dbo.Fitem(1)
then i get this
Server: Msg 208, Level 16, State 1, Line 1
Invalid object name 'dbo.Fitem'
am i just too tired or what?
View 2 Replies
View Related
Feb 21, 2007
please solve this query
first table second table
loginname categoryid
categoryid categoryname
first table data
nisar (1,2,3,4)
second table data
1 Bearbase
2 Amunation
3 Training
4 Workorder
Now I want cross tab report like that which will show user name nisar has this category
Nisar bearbase amunation traiaing workorder
View 3 Replies
View Related
Feb 21, 2007
please solve this query
first table ============= second table
loginname ============= categoryid
categoryid ============= categoryname
first table data
nisar=====1,2,3,4)
second table data
1==== Bearbase
2==== Amunation
3==== Training
4==== Workorder
Now I want cross tab report like that which will show user name nisar has this category
Nisar ==bearbase=== amunation === traiaing === workorder
View 1 Replies
View Related
Apr 24, 2007
hi anyone can please solve this query
I have table1 like this
locationid locationname
1 london
2 bombay
and in table2 like this
personname fromlocation tolocation
john 1 2
ryan 2 3
now i want to udpated table 2's from location and tolocation colum with all the all related value in table1
Regards
Monika
View 4 Replies
View Related
May 19, 2007
Hi please solve this
DBF file
Id 1
Building 21b
Population 4
Sql server table
Building 21b
Population8
Now I want to execute a sql script when ever I will run this script
It will not only transfer data between sql server 2000 and dbase file but Also update the corresponding population value in dbf table, which has same building value In sql server table
View 1 Replies
View Related
Jan 10, 2008
1) bothe numeric and decemal are equl. Why we were using both.
we can go throgh one of them.
Both are under same exact numeric category. In which situation we go for decimal in which situation we go for nummerics?
View 2 Replies
View Related
Mar 10, 2008
hi,
i have a two tables like this.
employees table
empid, emp_name, emp_designationid, emp_departid
1 'rex' 1 3
2 'robert' 2 3
strings table
id, name
1 'manager'
2 'lead'
3 'software'
i want a sql query to get the data like this
emp_name, emp_designation , emp_depart
rex manager software
robert lead software
Raghu sunkara.
View 3 Replies
View Related
Mar 12, 2008
hi,
i have a table like this.
employees
emp_id, emp_name , emp_active, emp_departPID, emp_salary
1 'robert' 1 1 200
2 'Rose' 0 1 100
Department
DepartmentPID, DepartmentName
1 software
i need an sql query like.
i want to inner join employee table with department table when emp_derpatmentPID IS 1
can you help me out please.
Raghu sunkara.
View 1 Replies
View Related
Mar 12, 2008
hi,
i have employee table like this.
emp_id,emp_name,emp_designationpid, emp_salaryRangePid
1 'rose' 1 1
2 'rose1' 2 1
3 'rose2' 3 1
emp_desgination table
designation_id , name
1 'manager'
2 'employee'
Managers_salaryRange Table
salary id , salary-start, salary-end
1 1000 2000
Emp_salaryRange Table
salary id, salary-start, salary-end
1 500 1000
I want a single query:
if the employee role is manager i want to inner join with managers_salaryRange Table.
if the employee role is employee then i want to inner join with
emp_salaryrange table.
please give me single sql query to solve my problem
Raghu sunkara.
View 5 Replies
View Related