|
Lior S wrote: basically the main slowing reason is the UPDATE procedure since it is searching in more then 5 million records to fit to the conditioned row for the update.
Sounds like the search component isn't very efficient. Are you searching on the primary key, or an index? If not make an index from the columns on which you are searching.
|
|
|
|
|
HI,
I need to know what is the best way to create a database on SQLSERVER 2000 for a holding and its subsidiaries.
Same server will be used.
Same database structure will be applied for all subsidiaries which have common data(in tables like country, city, agency, client, product), but at the same time, transactional data specific to each one on transactional tables.
Is it better to create a database for all common tables and another one for the other tables (with creating triggers , so that we have same data on all databases) OR Creating one database for all subsidiaries? OR is there another way?
Advantages and disadvantages ??
Thanks in advance,
Regards,
|
|
|
|
|
Myra,
This depends a lot on security, and how much data you need to proccess and what schema your data will be organised in.
I suggest you model your data then make a choice from there.
Blog Have I http:\\www.frankkerrigan.com
|
|
|
|
|
Thanks Frank,
I'll try to give you more details, maybe you would clarify the situation to me.
I have until now 4 subsidiaries for this holding, each one having to book spots for different TV channels.Each subsidiary have one or more channels.A user should be related to one subsisiary and can only view and work with the booking orders of this subsisiary. However, he can have access to product , client, agency tables which are shared by all users in the holding. cause u know that, for instance, the agencies and the products are the same.
as an example, one subsidiary could have booked around 300 000 spots per year, for 5 channels.Another one , having one channel, 60 000 records for booking Order per year
I'm a little bit lost
Thanks in advance
|
|
|
|
|
Basically I cannot connect (in certain circumstances to SQL Server 2005 (Express) on my laptop (from my laptop)).
Configuration:
Window XP SP2 (not part of domain)
SQL Server 2005 Express
Visual Studio .NET 2005 Standard
SQL Management Studio Express
The service is running as is the SQL Browser Service
I can connect to the server using SSME (Management Studio) but not using SqlConnection nor osql nor sqlcmd nor VS2005 Server Explorer.
Shared Memory, Named Pipes and TCP/IP connections are enabled and I've been trying to log in through Windows Authentication (work requires it although not essential for development).
Does anybody have any ideas on what might be causing this lack of connectivity, I've run through the articles in the MS KB on configuring the XP firewall, even tried disabling it with no luck, still same error message:
<span name="intelliTxt" id="intelliTxt" style="margin-top: -15px;"></span>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: Named Pipes Provider, error: 40 - Could not open a connection
to SQL Server). Which reminds me remote connections are enabled in SSME.
Don't know what's going on since it was running under Win2K just fine (BTW removing SP2 is unfortunately not an option).
|
|
|
|
|
What is the status of windows firewall? Is port 1433 open for SQL server TCPIP connections?
What does your connection string look like?
|
|
|
|
|
Firewall is enabled, added the default instance of sqlservr.exe (only one running) to the exceptions list and opened port 1433 as well but to no avail.
Note I have also tried disabling the firewall as well but that doesn't seem to do anything either, what's bugging me is that SSME can connect but nothing else, not even VS.
Connection strings tried:
Data Source=(local);Initial Catalog=MIDAS;Integrated Security=true;
Data Source=seafire;Initial Catalog=MIDAS;Integrated Security=true;
Data Source=<ipaddress>;Initial Catalog=MIDAS;Integrated Security=true; Also tried variations using an SQL authentication but that doesn't seem to work.
On a different note another possibility would be if I could get the following scenario to work.
SQL 2005 on Win2K with ZoneAlarm as firewall (at least this is easy to configure).
Accessing from WinXP SP2 from laptop.
Both can be (and are I think) part of the same workgroup but there is no domain involved. IP address of desktop with Win2K is fixed, laptop is assigned dynamically from the router through which we access our broadband.
Either is a possibility, but using SQL on laptop is preferable (but only slightly to accessing it from the desktop).
Many thanks
|
|
|
|
|
Fixed it (I think), changed the connection string to use Data Source=SEAFIRE\SQLEXPRESS . At least I got a different error which showed that the connection was thrown out by SQL because of permissions so I'm correcting these and hopefully it should work.
Looks like it's not a default instance as I thought it was.
|
|
|
|
|
I have created a database table with 5 columns in VS 2005 and I want the first column to autoincrement. I have set the Is Identity property of the column to yes and set the Identity Increment and Identity Seed properties to 1. In my codebehind, when I make the call this.TableAdapter.Insert(1, 1, DateTime.Now, 0, 0) and run it, I get this error message: Cannot insert explicit value for identity column in table 'Table' when IDENTITY_INSERT is set to OFF. What do I need to pass in as the first argument into the Insert function to get the auto increment to work? Any help would be appreciated, thanks.
|
|
|
|
|
Try passing a DbNull as the value for the identity column. Alternatively, change the commandtext for the adapters's insertCommand to simply omit the first column.
|
|
|
|
|
I have a C++ application that uses ADO to connect to a JET database. It uses MDAC available in most Windows operating systems to support this. The application checks for MDAC 2.71 and if it is an earlier version in the computer, stops the program and asks the user to update their MDAC ( Have customers who still use Win98). So far so good.
How do I proceed with Windows Vista - it does not have MDAC - has Windows DAC. Apparently does not support JET - does this mean Access/Jet programs don't work any more? MSDN says support to ADO is built in - does this mean, I just don't bother to check for MDAC if it is Vista & all my current calls to ADO will work (Even though the database is a JET database)?
I would appreciate any and all input.
Thanks in advance.
|
|
|
|
|
consider a payment table with the following fields: billno,invid,amount,date
Also consider tables invoices (contains invid,invno,pkgid) and packages (contain pkgid)...
I need to generate bill for a particular invoice number(invno). That invoice may contain more than 1 packages. I have to generate bill for each packages with a same bill no. If there are 3 packages in invoice number 'I31' then 3 bill must be generated.
How to insert this using package or someother method? I'll pass thes values (billno,invno, and date) from my application to SQL server. The insert command must generate no. of bills that is equal to the number of packages of that invoice. The no. of pkgid can be retrieved by invno, the amount can be retrived by using the pkgid.
Please help me to insert multiple records from one request.
Hope you understand my prob.
Thanks.
|
|
|
|
|
Is is possible to add variables to functions in SQL Server. My issue is I am buildint a dashboard and I am sendint the variables directly from the dropdown menu.
what I need to do is have the ability to modify the Datediff function. By changing the type.
i.e
datediff(@dateRange, getdate())=0
I need to have the @dateRange be a variable instead of (dd, ww, or yy).
Any Ideas?
thanks
|
|
|
|
|
oskardiazdeleon wrote: i.e
datediff(@dateRange, getdate())=0
That's not a legal call to DATEDIFF[^] See the linked documentation for what you actually need.
oskardiazdeleon wrote: Any Ideas?
CASE[^]
CASE @dateRange WHEN 'dd' THEN DATEDIFF(dd, GETDATE(), @someOtherDate)
WHEN 'ww' THEN DATEDIFF(ww, GETDATE(), @someOtherDate)
WHEN 'yy' THEN DATEDIFF(yy, GETDATE(), @someOtherDate)
ELSE 0 END
You could then potentially wrap this in a function[^], however, since GETDATE() is non-deterministic it isn't possible to do what you want, but you could always pass GETDATE() into the function.
e.g.
CREATE FUNCTION DateDifference(@dateRange CHAR(2), @startDate DATETIME, @endDate DATETIME)
RETURNS INT
AS
BEGIN
RETURN CASE @dateRange WHEN 'dd' THEN DATEDIFF(dd, @startDate, @endDate)
WHEN 'ww' THEN DATEDIFF(ww, @startDate, @endDate)
WHEN 'yy' THEN DATEDIFF(yy, @startDate, @endDate)
ELSE 0 END
END
It can be called like this:
SELECT dbo.DateDifference(@dateRange, @someDate, GETDATE())
Does this help?
|
|
|
|
|
Does anyone have any experience with creating data dictionaries for Sql Server?
Our corporation needs to setup a data dictionary to store all our db info however currently, we're just storing it in a spreadsheet. What's the global practice for creating a corporate Data Dictionary?
Or does anyone perhaps know of an online tutorial that explains this?
Thanks.
-Goalie35
|
|
|
|
|
Have you searched Microsoft's web site for database tutorials, if not, then please do, however ...
For non-microsoft produced tutorials about Databases, there are many web sites that can help, here is one you might find helpful ...
http://www.geekgirls.com/menu_databases.htm[^]
and here are some video tutorials
http://www.learnsqlserver.com/VideoTutorials/[^]
Also, make a search here at Code Project, there are many database tutorials at various levels
modified 1-Aug-19 21:02pm.
|
|
|
|
|
Hi,
I am trying to call a procedure within another Stored Procedure.
The Stored Procedure (A) that is being called contains code for a caculated field. The Stored Procedure (B) that is calling it is one which stores data in a table.
Currently I am calling (A) in the following manner from within (B) :
EXEC sp_A
I was told I have to pass a particular parameter when calling (A). How do I do that? is it like this? :
EXEC sp_A(ParameterName)
Let me know if you need anymore detail. The problem with this issue is that, it is sooo complicated if i try to explain it fully. Sorry for the lack to code detail.
|
|
|
|
|
Here is an example.
CREATE PROCEDURE MyFirstProc @cParam varchar(10)
AS
PRINT 'MyFirstProc ' + @cparam
EXEC MySecondProc @cparam
GO
CREATE PROCEDURE MySecondProc @cTest varchar(20)
AS
PRINT 'This is in MySecondProc ' + @cTest
GO
Call this from SQL Query Analyzer like this:
EXEC MyFirstProc 'testing'
and you will see this:
MyFirstProc testing<br />
This is in MySecondProc testing
However, you said that "Stored Procedure (A) that is being called contains code for a caculated field." This sounds like you would be better off with a User Defined Function.
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
Here's the deal,
Table A has a field called 'TimeEstimate'. This field is in Days. DataType Integer.
Table B has a field call 'PercentageOfProgress'. This field is calculated. DataType Integer.
When I enter and save all the data for Table A, The procedure that holds the calculation for 'PercentageOfProgress' needs to be fired. Therefore from within the Stored Procedure which saves the Data for Table A, I want to fire the SP for the Caulculated field which stores THAT RESULT in Table B.
See what I mean?
Also, I tried to pass the Parameter like you said in Query Analyser, it gave me this:
Error converting data type varchar to int.
I will have to revise the SPs. In anycase, if you have any suggestions, Please let me know.
Thank you so much for your reply!
|
|
|
|
|
Since you have not listed the code, If you get Error converting data type varchar to int.
explicitly convert it to int and see what happens.
|
|
|
|
|
The example I gave had a varchar parameter, so I put single quotes around it. If your sproc is expecting an int data type, then don't put quotes around it.
It would be easier to help if you provided some code.
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
Thank you very much for your replies.. much appreciated..
I will be looking at this problem very soon, so check your email for this post =D
Something came up and I have to focus on that first..
I will provide the code soon.
|
|
|
|
|
Hi,
i would like to ask how we can unify two triggers!
In first trigger i want to do something when a column is updated and in the other trigger i want to do something else when a different column is updated at the same table.
Now i have the two triggers and they are working properly, but i still have to do it in the same trigger!
Does anyone know how to do it!
CREATE TRIGGER UPDATE_REST1
ON [DBO].[FINTRADE]
FOR UPDATE
AS
IF UPDATE(FTRIDPAYMENT)
UPDATE FINTRADE
SET Z_YPOLOIPO= (SELECT ISNULL(I.TOTLAMOUNT,0) - ISNULL(PLH.TOTLAMOUNT,0) AS Z_YPOLOIPO
FROM INSERTED I, FINTRADE PLH
WHERE I.FTRIDPAYMENT=PLH.ID)
FROM FINTRADE F, INSERTED I
WHERE F.ID=I.ID
CREATE TRIGGER UPDATE_REST2
ON [DBO].[FINTRADE]
FOR UPDATE
AS
IF UPDATE (TOTLAMOUNT)
UPDATE FINTRADE
SET Z_YPOLOIPO= (SELECT ISNULL(PAR.TOTLAMOUNT,0) - ISNULL(I.TOTLAMOUNT,0) AS Z_YPOLOIPO
FROM INSERTED I, FINTRADE PAR
WHERE PAR.FTRIDPAYMENT=I.ID)
FROM FINTRADE F, INSERTED I
WHERE F.FTRIDPAYMENT=I.ID
Thanks in advance!
andreas
|
|
|
|
|
CREATE TRIGGER UPDATE_REST1
ON [DBO].[FINTRADE]
FOR UPDATE
AS
IF UPDATE(FTRIDPAYMENT)
UPDATE FINTRADE
SET Z_YPOLOIPO= (SELECT ISNULL(I.TOTLAMOUNT,0) - ISNULL(PLH.TOTLAMOUNT,0) AS Z_YPOLOIPO
FROM INSERTED I, FINTRADE PLH
WHERE I.FTRIDPAYMENT=PLH.ID)
FROM FINTRADE F, INSERTED I
WHERE F.ID=I.ID
IF UPDATE(TOTLAMOUNT)
UPDATE FINTRADE
SET Z_YPOLOIPO= (SELECT ISNULL(PAR.TOTLAMOUNT,0) - ISNULL(I.TOTLAMOUNT,0) AS Z_YPOLOIPO
FROM INSERTED I, FINTRADE PAR
WHERE PAR.FTRIDPAYMENT=I.ID)
FROM FINTRADE F, INSERTED I
WHERE F.FTRIDPAYMENT=I.ID
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
I have already try this!But the application which runs triggers is treated like two triggers!In the aplication which i work i can't run more than 3 triggers and i have two more!
|
|
|
|
|