SQL Server Express Excruciatingly Slow With Simple Quries
Mar 10, 2008
I am running simple queries against test SQL Express installation and they take a very long time to return data. I have two SQL Express instances installed on colleagues' machines to which I connect for my testing and both exhibit the same problem. The setup is Windows XP SP 2 with 2 GB RAM and 3.6 GHz CPU. I am querying a table with around 7000 records and my query is simply SELECT TOP 1000 * FROM MyTable. It takes over 10 seconds to return the recordset!
I have done the research and found posts, which talk about AUTO_CLOSE option, indexes, query execution plan, etc. I have done everything those posts recommend, but performance is still terrible. All the instances have SQL 2005 SP2 applied.
I also found that the query runs fast locally on each SQL Express instance, the problem seem to happen when I am trying to pull the data over the network.
I am really not sure what else to look for.
Thank you,
Michael
View 1 Replies
ADVERTISEMENT
Apr 26, 2007
Hi,
I have got an application running which connects 2 databases and performs an action that copies data from one database to the other database.
When using SQL Server 2000 MSDE, it takes about 5 seconds.
When using SQL Server 2005 Express Edition it takes about 30 seconds.
For testing 2005, I use 'upgraded' databases, so same indexes and data. I tried reindexing the databases, but always get the same result.
My setup string for installing SQL Server 2005 Express is :
/qb ADDLOCAL=ALL INSTANCENAME=DBNAME SECURITYMODE=SQL SAPWD=QWERTY SQLACCOUNT="NT AUTHORITYSYSTEM"
The code (ADO) is something like :
SELECT FROM original database
-- do something with data
INSERT INTO other database
Until EOF
Any idea how to solve this ???
P.S. When perfoming a simple Query on the databases (with 1.000.000 rows result) with SQL Server Management Studio Express, I see 37 seconds for SQL Server 2000 and 33 Second for SQL Server 2005. That is more the result I expect.
-------
XPPro SP2 3Ghz 1Gb
View 16 Replies
View Related
May 1, 2006
Hello,
i want to install the SQL 2005 express Server on a HP-Netserver LH4 with 1 Xeon 500 CPU. I know, that i must have a 600MHz CPU, but i cant change the CPU. Is there one way to start the SQL server?
Thanks
Michael
View 3 Replies
View Related
Apr 22, 2008
Hi,
I use a Remote Sql Server Express instance, and I have a strange behavior.. The first connection is really slow and I don't know how to fix that.I read some posts about this topic but I didn't find the right solution.Is there a way to "keep alive" the connection between my IIS server and the SQL one ?I check the auto-close property and it sets to false.
Any help ?
Stan
View 1 Replies
View Related
Oct 30, 2007
Hi,
I've recently installed SQL Server 2005 Express on my PC (winXP).
I'm finding that SQL Server Management Studio Express runs very slow. Every simple task takes 10-60seconds (open table, creating a table, saving anything etc). I can't find an answer to this anywhere. I've read neumerous articles that people wern't online therefore it was running slow because a certificate was trying to verify in the background... but I'm online and I've disabled the certificate so it can't be that.
This is a fresh install so I can't understand why it runs so slowly! When I used to use enterprise manager with SQL Server 2000 it worked at lighting speed.
What's going on?
CHeers
Matthew
View 24 Replies
View Related
Jan 12, 2007
Dear Experts,I have a fairly simple query in which adding a where clause slowsthings down by at least a factor of 100. The following is the slowversion of the query-------------------------SELECT * FROM( Select x.event_date From x FULL OUTER JOIN yON x.event_date = y.event_date) innerQWHERE ( innerQ.event_date >= {ts '1980-01-01 00:00:00'} )------------------------Removing the where clause makes the query run quickly. This seemsextremely strange because it seems like SQL Server should simply beable to take the results of innerQ and discard anything with a datethat doesn't match. If I instead split the query into two pieces whereI create a temp table and put innerQ into that and then do the select *WHERE (...) from the temp table things work fine.Any thoughts on what SQL Server might be doing to make things slow andhow I can fix it?Thanks,-Emin
View 9 Replies
View Related
Jan 5, 2007
Hi
We have SQL Express running very slowly on Small Business Server. Does
anyone know if there is a conflict between the two? Or any ideas on how
to solve our problem?
(Autoclose is set to
false)
Thanks
View 1 Replies
View Related
Mar 7, 2005
Hello,
I don't know what to do anymore ;o(
I've got 2 servers, with sql server 2000 sp3 and ms windows 2003 server.
I've written a very simple stored procedure to insert 20,000 rows into a very simple table TEST (id int, msg varchar_50)
On the first server (P-IV 2 GHz), it takes 700 ms / 1000 insertions
and on the second (2x Xeon 2,6 GHz), it takes 13 s / 1000 insertions...
(insertion is : INSERT INTO TEST (id, msg) VALUES (@id, 'dummy text'))
...
SQL Server was installed exactly in the same way...
what could I do see where the problem is ? With profiler, I see no difference while logging all events....
please help or give ideas
View 1 Replies
View Related
Apr 2, 2007
Hi all, I've been building a set of traffic based reports on our website and I've run into a strange problem.
The reports are pretty basic, and up till now I've been really impressed with RS overall.
Recently I've added a StartDate and EndDate and since then the performance has gone from ~10 secs to ~10 minutes.
I've taken a really simple query from my reports. Running this query in Management Studio on the same data returns in less than a second. When its run from a test report with nothing else in it it takes ~1 minute. Even stranger when I run the same query with the same values for parameters inside of RS in the data view it takes less than 1 second. ARG!
SELECT COUNT(DISTINCT SessionID) as Occurences
FROM WebAppSummary
JOIN WebAppLocalizations
ON WebAppSummary.ClientIp = WebAppLocalizations.ClientIp
where FirstTime BETWEEN @StartDate AND @EndDate
The last line that was just added is this part:
where FirstTime BETWEEN @StartDate AND @EndDate
So whats going on here? Is this a really poorly performing query that management studio is optimizing but RS isnt? Is RS messing up the databind and getting a bunch of DSs instead of just one?
View 1 Replies
View Related
Apr 24, 2007
I am moving an application from MSDE to SQL Server Express. I have having difficulty finding a way to use a simple passsword for the SQL Login. SQL Server 2005 allows this
View 5 Replies
View Related
Jun 25, 2007
Hi all,I've just installed Express on my Vista notebook and I'm having a few problems.Maybe this is just a conceptual problem on my side but I expected to see a server process (in other versions of SQL server I've used there has been an icon in the server tray of the taskbar).When I open "Microsoft SQL Server Management Studio Express" I also expected to see a database instance running locally I can connect to (from other research this instance appears to be called SQLEXPRESS). There isn't one.
If I select server type "database engine" on the "connect to server" dialog there are no instances displayed in the "Server Name" field. "Browsing for others" shows nothing under "local servers" which doesn't seem right to me.If I change "server type" to "SQL SERVER COMPACT EDITION" (which doesn't seem right either as I thought "compact edition" was something else) I can have an option to create a database file
Additional information:
I downloaded SQL server express today from this url:
http://msdn.microsoft.com/vstudio/express/sql/download/. I downloaded the advanced services toolkit edition as I thought I may was well have all the bells and whistles to play around with.Any ideas?thanksJoel
View 2 Replies
View Related
Jun 12, 2008
I've this tableCREATE TABLE [dbo].[Attivita]( [IDAttivita] [int] IDENTITY(1,1) NOT NULL, [IDOwner] [int] NULL, [IDAttivitaStato] [varchar](1) COLLATE Latin1_General_CI_AS NULL, [IDAttivitaTipo] [varchar](2) COLLATE Latin1_General_CI_AS NULL, [IDAnagrafica] [int] NULL, [Data] [datetime] NULL CONSTRAINT [DF_Attivita_Data] DEFAULT (getdate()), [Descrizione] [varchar](max) COLLATE Latin1_General_CI_AS NULL, [Privato] [bit] NULL, [LastUpdate] [datetime] NULL CONSTRAINT [DF_Attivita_LastUpdate] DEFAULT (getdate()), CONSTRAINT [PK_Attivita] PRIMARY KEY CLUSTERED ( [IDAttivita] ASC)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]) ON [PRIMARY]How Can I create a trigger for modify the IDAttività Stato field in specific situaion: if IDAttivitaTipo == OK or == NOIDAttivitaStato must be set to CPlease note that I can write in the IDAttivitaStato field (during my code operation).... but I would like also automatic update if the IDAttivitaTipo is OK or NO Can you help me for create this with a trigger?Thanks
View 2 Replies
View Related
Jul 9, 2001
In my database/MY SERVER (SQL7/Win2K), I run a simple query with a Table/10000 rows (without cluster index):
SELECT * FROM TABLE
it take over 30s. Why it's slow? How can I check for reason? How to configure my server to improve performance?
Thanks in advance.
TH
----------------------------------
SP_CONFIGURE's RESULT in MY SERVER
----------------------------------
Table 'spt_values'. Scan count 1, logical reads 2, physical reads 0, read-ahead reads 0.
name minimum maximum config_value run_value
----------------------------------- ----------- ----------- ------------ -----------
affinity mask 0 2147483647 0 0
allow updates 0 1 1 1
cost threshold for parallelism 0 32767 5 5
cursor threshold -1 2147483647 -1 -1
default language 0 9999 0 0
default sortorder id 0 255 52 52
extended memory size (MB) 0 2147483647 0 0
fill factor (%) 0 100 0 0
index create memory (KB) 704 1600000 0 0
language in cache 3 100 3 3
language neutral full-text 0 1 0 0
lightweight pooling 0 1 0 0
locks 5000 2147483647 0 0
max async IO 1 255 32 32
max degree of parallelism 0 32 0 0
max server memory (MB) 4 2147483647 2147483647 2147483647
max text repl size (B) 0 2147483647 65536 65536
max worker threads 10 1024 255 255
media retention 0 365 0 0
min memory per query (KB) 512 2147483647 1024 1024
min server memory (MB) 0 2147483647 0 0
nested triggers 0 1 1 1
network packet size (B) 512 65535 4096 4096
open objects 0 2147483647 0 0
priority boost 0 1 1 1
query governor cost limit 0 2147483647 0 0
query wait (s) -1 2147483647 -1 -1
recovery interval (min) 0 32767 0 0
remote access 0 1 1 1
remote login timeout (s) 0 2147483647 5 5
remote proc trans 0 1 0 0
remote query timeout (s) 0 2147483647 0 0
resource timeout (s) 5 2147483647 10 10
scan for startup procs 0 1 0 0
set working set size 0 1 0 0
show advanced options 0 1 1 1
spin counter 1 2147483647 10000 10000
time slice (ms) 50 1000 100 100
two digit year cutoff 1753 9999 2049 2049
Unicode comparison style 0 2147483647 196609 196609
Unicode locale id 0 2147483647 1033 1033
user connections 0 32767 0 0
user options 0 4095 0 0
Table 'spt_values'. Scan count 43, logical reads 108, physical reads 0, read-ahead reads 0.
Table 'sysconfigures'. Scan count 1, logical reads 2, physical reads 0, read-ahead reads 2.
View 4 Replies
View Related
Sep 10, 2007
I have a 2GHZ cpu with 1GB of RAM. I occassionally see very slow (long) queries against a local SQL Server 2005 Express (SP2) database. The issue occurs against different SQL Queries, but all queries are rather basic select statements Perfmon shows that the SQL Server counter for the "MEMORY GRANT QUEUE WAIT Avg MS" gets extremely high (25000+ ms). Perfmon also also shows that PAGING is not occuring, and the system is not under unsual stress. The problem is not reproducible with MSDE.
Has anyone seen this issue, or have any recommendations for a next course of action?
View 1 Replies
View Related
Mar 18, 2006
Normally I'd go and write a bunch of code for doing it manually... But instead of that, maybe there is a smarter way?
What I know is that you can get some kind of dump out of MySQL but I would be very surprised if that could be directly read into SQL Express ??
So if you have a few step guide to migrate from MySQL to SQL Express, I am all ears (and eyes)!
Thanks!
(Yes I am aware there is some DTS thingy for this but could not find it in the Express folders)
View 6 Replies
View Related
Jan 25, 2008
I've installed sql server 2005 on a customer's machine.
I have a very small "connection tester" app C# (2005) winforms app, which I use to verify connection strings. This app has been working for years. I am using the sa account to login with in this test app just to keep things simple. I am using Sql Server Authentication.
When I try to connect, I get a "login failed for user sa". I'm absolutely certain that I have the password correct.
Sql Server Express is setup in mixed mode, and I have all the tcp/ip settings correct ( as far as I know ).
I think if it was a tcp/ip thing, it wouldn't find the machine, as opposed to saying Login Failed.
I'm running out of things to look at.
The machine has .NET 3.5 installed. The connection test was written using C# 2005, .NET 2.x Could that cause a problem?
View 3 Replies
View Related
Jun 11, 2007
Hi,
Anyone can send the Sql query questions i need to pratice quries on sqlserver.
Regards,
Hari Prasad
View 1 Replies
View Related
Sep 28, 2007
Hi all,
I want to do SQLCLR by Connecting to SQL Express User Instances in Management Studio via VB 2005 Express and I have read the following articles and books:
(i) Connecting to SQL Express User Instances in Management Studio in http://blogs.msdn.com/sqlexpress/archive/2006/11/22/connecting-to-sql-express-user-insta...
(ii) Managing SQL Server Express with SQL Server 2005 Management Studio Express Edition in http://www.microsoft.com/technet/sql/2005/mgsqlexpwssmse.mspx
(iii) Chapter 16 - Going Beyand Transact-SQL: Using the SQL Common Language Rutime (SQLCLR) in Microsoft SQL Server 2005 Express Edition for Dummies
(iv) Chapter 21 - Working with the Common Language Runtime in Microsft SQL Server 2005 Programming for Dummies
(v) Chapter 4 - Introduction to Common Language Runtime (CLR) Integration in Programming SQL Server 2005 by Bill Hamilton.
I want to create an SQLCLR project "HelloWorld" by Connecting to SQL Express User Instances in Management Studio via VB 2005 Express. But I am still not sure how to get it started, because I do not understand the following things:
(1) Pipe Name for a User Instance, (2) Enabling (or Disabling) the CLR by using Transact-SQL, (3) Creating a Transact-SQL script, (4) Creating an Assembly, (5) Creating a backup device, etc. I need to see some simple examples of SQLCLR by Connecting to SQL Express User Instances in Management Studio via VB 2005 Express. Please help and tell me where in the websites I can find them.
Thanks in advance,
Scott Chang
View 5 Replies
View Related
May 26, 2008
Hi Friends
I want Some Power Point Presentations In MS SQL SERVER 2000
1. Joins
2. Views
3. Basic Queries
4. Functions
5. Store Procedures and Cursors
All the above i want PPTs could you any body please send me
View 2 Replies
View Related
Nov 1, 2000
Can anyone know the difference between using distributed queries for transfering data and replication.
Which is more reliable and which is the better way?
If the volume of database over 2,000,000 with nearly 100 columns,which is the better method?
View 2 Replies
View Related
Dec 6, 1999
I have Two Access Databases connected as Linked servers through ODBC driver.
I want to run a Distributed Query .
The SQL is as follows:
SELECT Alias1.FiledNames,Alias2.FiledNames from
FROM LinkedServer1.DatabaseName1.dbo.Tablename1 AS Alias1,
LinkedServer2.DatabaseName2.dbo.Tablename2 AS Alias2
It gives me this error message.
ODBC: Msg 0, Level 19, State 1
SqlDumpExceptionHandler: Process 12 generated fatal exception c0000005 EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process.
Connection Broken
Am i missing something?
Thanks in Adavance
Puru
View 1 Replies
View Related
Jan 6, 2008
Here are the tables I am dealing with:
Tables
license TABLE
---------------
license_id int PK
vendor_id int FK
po_id int FK Nulls
license_type_id int FK
lic_user_id int FK Nulls
location_id int FK Nulls
lic_start_date smalldatetime Nulls
days_allowed int Nulls
serial_num varchar(50) Nulls
activation_key varchar(50) Nulls
max_users int Nulls
comments varchar(1000) Nulls
software TABLE
------------------
software_id int PK
os_id int
software_name varchar(150)
comments varchar(1000) Nulls
software_license TABLE
--------------------------
license_id int PK , FK
software_id int PK , FK
comments varchar(1000) Nulls
dept_license TABLE
---------------------
dept_id int PK , FK
license_id int PK , FK
comments varchar(1000) Nulls
purch_order TABLE
---------------------
po_id int PK
po_number varchar(50)
po_date smalldatetime
comments varchar(1000) Nulls
dept_purch_order TABLE
----------------------------
po_id int PK , FK
dept_id int PK , FK
comments varchar(1000) Nulls
I am using the following stored proceedure to try to create a useful report from those tables:
Code Block
ALTER PROCEDURE [dbo].[ListDepartmentLicenses]
@Department int,
@Software int
AS
BEGIN
SET NOCOUNT ON;
SELECT dept_license.license_id,
license.lic_start_date,
department.dept_name,
purch_order.po_number,
software.software_name
FROM dept_license
JOIN license
ON dept_license.license_id = license.license_id
JOIN department
ON dept_license.dept_id = department.dept_id
JOIN dept_purch_order
ON dept_purch_order.dept_id = dept_license.dept_id
JOIN purch_order
ON dept_purch_order.po_id = purch_order.po_id
JOIN software_license
ON dept_license.license_id = software_license.license_id
JOIN software
ON software_license.software_id = software.software_id
WHERE (department.dept_id = @Department or @Department Is Null) and
(software.software_id = @Software or @Software Is Null)
ORDER BY license.lic_start_date
END
The sproc compiles fine but I get no rows returned.
View 7 Replies
View Related
Aug 25, 2006
Has anyone else noticed delays with SQL Express? I'm not really talking about delays on the queries but just delays in general response. For example: everything is running great, then for about 2 minutes I get connection timeouts etc can't even open stuff in the management studio without getting timeouts ... then as strangely as it started everything goes back to normal and requests are served again.
The server has nothing on except 1 website, its Win 2003 Server. 512MB Ram on a PIV. The memory usage is low and during the "lockups" the machine isn't showing any processor usage and SQL mem usage is around 40Megs.
I am not using User Instances either. Nothing in the event logs. What is odd, is its happening on 3 of my machines ..... all with different sites, the only thing in common between them is SQL.
thanks,
-c
View 1 Replies
View Related
Jul 17, 2007
Some queries take a long time to complete.
Setup is:
- SQL Express SP2
- Windows Vista Business
- 2 GB RAM
- Core 2 Duo processor
- Connecting to (local) server with SQL Authentication
- only 1 Instance of MSSQLSERVER
Simple queries (SELECT * FROM TableName) wher the table has only a few records. This query may take up to 30 or more to execute. This slowness is consistent to certain tables. Other much larger tables run queries fine.
If a different computer logs in to the same server, queries provide instantaneous results.
View 4 Replies
View Related
Feb 2, 2007
I posted this in one of the VB forums but I'm starting to think itmight be more appropriate to have it here, since it really seems to bea SQL server (MSDE/Express 2005) problem:Hey, all, I have a problem with queries against a SQL server instancethat I just found and is causing me fits. I hope someone can pointmein the right direction, please. TIA.Basically, I got a Vista OS machine to test my VB6 app on it as someof my clients will be switching over in the coming months. I went toa local Circuit City during early business hours in the middle of theweek and I installed my application on each of 5 PC's on the newVistaOS (Tuesday, when it was released). I had read that MSDE 2000, whichI normally use as my DB is not supported on Vista so I had downloadedand was using SQL Express 2005. Each system had at least a 1.9 GHzdual core processor and 1 GB of RAM. One process in my program findsrecords in one table that do not match records in another table andthen reports those un-matched entries. On my development machine(laptop with 1 GB of RAM, XP Pro SP2, MSDE 2000 (current SP), 2 GHzCentrino (IIRC)) the process takes less than 30 seconds consistently.On each of those 5 systems at Circuit City the process took 5 minutes(on each of 3 HP machines, a1700n, a1720n, a1730n, and 11 minutes oneach of two Gateway systems (the model numbers of which I forget atthe moment). Each of these computers should be much faster than mylaptop, and some had twice the RAM, and all had SATA or SATA IIdrivesinstead of my piddly 5400 laptop drive, I would have thought they'dall be faster but were abysmally slow.So, seeing a huge difference in the time, and to try to keep thisshort and sweet, I fired up another computer I have, running XP SP2,on 512 MB RAM, AMD Athlon 2300+. First I loaded MSDE 2000 and myapplication and ran the process. < 30 seconds on each of multipleruns. Second, I unloaded MSDE 2000 and installed SQL Express 2005andmoved the DB to it (sp_attach_db) which caused some upgrading(messages reported in OSQL about update/upgrade). When it was done Irebooted, to be sure, and the ran the program and the process again.On the same data, on the same computer, the process took 7-9 minutesconsistently on each of several runs. This makes this part of theapplication unusable, and even the simple stuff like grabbing asinglerecord from the DB (maybe 5 columns of no more than 500 bytes total)is noticeably slower on the SQL Express 2005 than on MSDE 2000.So, the problem seems to be with my interaction with the DB. I amusing ADO 2.8 in VB 6 (SP 6). I use DSN-less connections with aconnection string like: Driver={SQL Server};server=(local)caredata;database=caredata;Uid=sa; Pwd=<password>I use the RecordsSet Object to open the data similar to this:oRS.OpenstrSQL$, oCN, adOpenKeysetafter the oCN object has had the connection string set and the objectis opened.Considering that the same computer, against the same data, with thesame program, takes about 14 times (or more) longer to run, then ithas to be either that SQL Express 2005 is slow OR that my program isinteracting with it in an incorrect manner.Can someone point me in the right direction, please?Thank you.--HCSo, the problem isn't Vista
View 11 Replies
View Related
Jan 22, 2008
I've just moved a website/database application from windows server 2000 and sql server 2000 to windows server 2003 sp2 and SQL 2005 Express SP2. Database intensive pages now take about 40 seconds where before they took 2-3 seconds.
Things I've tried that haven't helped...
- I changed the ADODB connection string
from: sCnString = "dsn=mydsn;Database=mydatabase;uid=myuid;pwd=mypassword"
to: sCnString = "driver={SQL Native Client};server=myserverSQLEXPRESS;Database=mydatabase;uid=myuid;pwd=mypassword"
- Checked that autoclose is false.
What else can I look at?
View 1 Replies
View Related
Mar 8, 2007
Sql 2005 Express with XPP SP2 and the latest MS updates sometimes runs very slow.
A SELECT which should take a fraction of a second can take several 10s of seconds.
I have checked autoclose is OFF for database using
use master
go
exec sp_dboption 'your_db_name','autoclose'
And it is definitely showing as OFF
I've looked at the Activity Monitor and when stalled it shows one or two processes for my database which are sleeping with 1 or 2 open transactions. When I look at their details they are simple select statements.
Often when my computer should be idle SqlServer.exe can be consuming 20 - 30% of cpu
I've noticed that I have TWO sqlservr.exe showing in my Task Manager, Processes display
One sqlservr.exe is 27K using about 17% even tho computer is idle has username NETWORK SERVICE
Other sqlservr.exe is 343K using 0% has user name SYSTEM
I don't know why.
Wayne
View 1 Replies
View Related
Feb 19, 2007
Hi all,
In the past if we wanted to provide an application with simple (multi-user) database facilities, we would use an Access mdb database which we could basically xcopy deploy to the client. Share the folder across the network and apart from the limitations of mdb databases it would work !!!
With all the advancements in databases ! we have moved on to SQL Express - touted as the thing to use and the replacement for MSDE and MDB databases. But hang on a minute !! It doesn't work like that ! You can't deploy Express like we used to with MDB databases - the default Express database doesn't allow multi-access ?? and if you can't xcopy deploy the Express database. The 'user Instance' thing is useless - basically every user gets their own copy of the database !!! How many developers asked Microsoft for that one!! It's crazy!!
We just need to copy our exe files and the mdf file share across a workgroup and bingo network version of our software - it's not brain surgery - Is it! We don't need mountains of security - we need (FIRST OF ALL) easy deployment.
Please tell me I've got it wrong and you can deploy a SQL Express based application without jumping thru hoops ????
Regards
Steve
View 10 Replies
View Related
May 5, 2007
Hi everybody!
I have made a simple application with VB6 and SQL 2005 Express.
And after testing it in a network simulated with Virtual-Machine Workstation, the "real world" application was first getting slower and slower, and finally giving timeout errors.
It is even difficult to connect. The application times out always at 30 secs although the ado connection timeout was established longer (45)
I have checked on the machine where the server is installed, just in case the slow down was due to network problems, but it fail locally too.
Any help is wellcome
View 6 Replies
View Related
Dec 13, 2007
I want to refer in a table quotes to customers and itemes from another table.
here is my table list in database:
"Customers"
"PriceList"
I want to create another table which through it I can create qoutes for customers suing a collection of items in PriceList table.
for example I want to be able to create something like this:
Title:
my quote example
QuoteID:
46543
Items (retrieved from PriceList table):
370
474
456
belongsTo (a relation to CustomerID in Cstomers table):
6234876
Discount, Date, WrittenBy, etc.
how many tables do I have to use for it, and what queries I have to write, and do I have to create any special relationships?
regards
View 9 Replies
View Related
Apr 18, 2008
Hi there,
I was wondering if someone can point out the error or the thing I shouldn't be doing in a stored procedure on SQL Server 2005. I want to switch from SQL Server 2000 to SQL Server 2005 which all seems to work just fine, but one stored procedure is causing me headache.
I could pin the problem down to this query:
DECLARE @Package_ID bigint
DECLARE @Email varchar(80)
DECLARE @Customer_ID bigint
DECLARE @Payment_Type tinyint
DECLARE @Payment_Status tinyint
DECLARE @Booking_Type tinyint
SELECT @Package_ID = NULL
SELECT @Email = NULL
SELECT @Customer_ID = NULL
SELECT @Payment_Type = NULL
SELECT @Payment_Status = NULL
SELECT @Booking_Type = NULL
CREATE TABLE #TempTable(
PACKAGE_ID bigint,
PRIMARY KEY (PACKAGE_ID))
INSERT INTO
#TempTable
SELECT
PACKAGE.PACKAGE_ID
FROM
PACKAGE (nolock) LEFT JOIN BOOKING ON PACKAGE.PACKAGE_ID = BOOKING.PACKAGE_ID
LEFT JOIN CUSTOMER (nolock) ON PACKAGE.CUSTOMER_ID = CUSTOMER.CUSTOMER_ID
LEFT JOIN ADDRESS_LINK (nolock) ON ADDRESS_LINK.SOURCE_TYPE = 1 AND ADDRESS_LINK.SOURCE_ID = CUSTOMER.CUSTOMER_ID
LEFT JOIN ADDRESS (nolock) ON ADDRESS_LINK.ADDRESS_ID = ADDRESS.ADDRESS_ID
WHERE
PACKAGE.PACKAGE_ID = ISNULL(@Package_ID,PACKAGE.PACKAGE_ID)
AND PACKAGE.CUSTOMER_ID = ISNULL(@Customer_ID,PACKAGE.CUSTOMER_ID)
AND PACKAGE.PAYMENT_TYPE = ISNULL(@Payment_Type,PACKAGE.PAYMENT_TYPE)
AND PACKAGE.PAYMENT_STATUS = ISNULL(@Payment_Status,PACKAGE.PAYMENT_STATUS)
AND BOOKING.BOOKING_TYPE = ISNULL(@Booking_Type,BOOKING.BOOKING_TYPE)
-- If this line below is included the request will take about 90 seconds whereas it takes 1 second if it is outcommented
--AND ADDRESS.EMAIl LIKE '%' + ISNULL(@Email, ADDRESS.EMAIL) + '%'
GROUP BY
PACKAGE.PACKAGE_ID
DROP TABLE #TempTable
The request is performing quite well on the SQL Server 2000 but on the SQL Server 2005 it takes much longer. I already installed the SP2 x64, I'm running the SQL Server 2005 on a x64 environment.
As I stated in the comment in the query it takes 90 seconds to finish with the line included, but if I exclude the line it takes 1 second.
I think there must be something wrong with the join's or something else which has maybe changed in SQL Server 2005. All the tables joined have a primary key.
Maybe you folks can spot the error / mistake / wrong type of doing things easily.
I would appreciate any help you can offer me to solve this problem.
On the web I saw that there is a Cumulative Update 4 for the SP2 which fixes the following:
942659 (http://support.microsoft.com/kb/942659/)
FIX: The query performance is slower when you run the query in SQL Server 2005 than when you run the query in SQL Server 2000
Anyhow I think the problem is something else, I haven't tried out the cumulative update yet, as I think it is something different, more general why this query takes ages to process.
Thanks again for any help
Best regards,
Pascal
View 9 Replies
View Related
May 26, 2004
Hey,
I have MS SQL database.
I have procedure:
code:--------------------------------------------------------------------------------
CREATE PROCEDURE dbo.Reg_DropTable
@ModuleId varchar(10)
AS
declare @TableName varchar, @kiek numeric
set @TableName = 'reg_'+@ModuleId
begin
DROP TABLE @TableName <- HERE I GOT ERROR
end
GO
--------------------------------------------------------------------------------
I got error when using variable with tables names.
How to do this?
Ps. Number is send to this function and it must drop table with name Reg_[That number]
View 1 Replies
View Related