Simple (peculiar ) Performance Issue.

Apr 4, 2007



Hi all,



When I execute a SELECT query on a table with around 25 million records, I get
performance difference based on the passed parameter value .



The below queries returns the output in 1 second.



SELECT TOP 10000 * FROM TestTable WHERE Column = 1
SELECT TOP 10000 * FROM TestTable WHERE Column = 2
SELECT TOP 10000 * FROM TestTable WHERE Column = 3



The below query alone takes 18 seconds to return the output.



SELECT TOP 10000 * FROM TestTable WHERE Column = 4



(FYI: The count of records for the column value 4 is lesser than the other column values)



Could anyone please let me know why this happens and how to resolve this ?



Thanks in advance,

DBLearner

View 2 Replies


ADVERTISEMENT

Peculiar Performance Issue.

Dec 1, 2007

Hi all,

We have a issue with the performance in SQL server database.

Scenario & Issue:
We have delivered a .net application to our client. This application is installed in newly built windows 2003 server.

The client is facing performance issues with the application. When compared with the performance in the development server , the performance of the production server is very poor.

Even when we execute the stored procedures in the backend, the performance is poor in the production server.

Example: A stored procedure that takes 16 seconds in the development server takes 17 minutes for the same parameters. The time remains the same even for HOT execution.

System Info:

Database Version - SQL Server 2005
Database Size - 120 plus GB
OS Platform - Windows 2003
Database Load - 50 users
CPUs - 4
RAM - 8 GB

The OS is Clustered ( failover clustering ).

Points to Note:

1.There is a huge table with 250 million rows ( this table itself takes upto 60 GB )

2.The huge table is partitioned ( SQL server 2005 table partitioning ) and placed in 20 different filegroups (.mdfs).

3.The .mdf's are placed in a SAN and .ldf is in local HD

4.Dynamic queries are used at few instances for performance benefits.

Questions:

1. Any thoughts on why this kind of performance issue arises ?

2. The client DBA wants us to clear the data and stored procedure cache before executing the stored procedure and test the performance.

Will this be would be the case in production scenario ?

3. Will the performance change based on the input parameters ?

4. The client DBA also have stated that a report server that pings the production database server is the cause for frequent clearing of the SQL Server cache.

When does the SQL Server database actually clears the cache memory? Is there any way to control it?

Any help would be highly appreciated.

Thanks & Regards,

Hariarul

View 12 Replies View Related

Peculiar Performance Issue.

Dec 1, 2007

Hi all,

We have a issue with the performance in SQL server database.

Scenario & Issue:
We have delivered a .net application to our client. This application is installed in newly built windows 2003 server.

The client is facing performance issues with the application. When compared with the performance in the development server , the performance of the production server is very poor.

Even when we execute the stored procedures in the backend, the performance is poor in the production server.

Example: A stored procedure that takes 16 seconds in the development server takes 17 minutes for the same parameters. The time remains the same even for HOT execution.

System Info:

Database Version - SQL Server 2005
Database Size - 120 plus GB
OS Platform - Windows 2003
Database Load - 50 users
CPUs - 4
RAM - 8 GB

The OS is Clustered ( failover clustering ).

Points to Note:

1.There is a huge table with 250 million rows ( this table itself takes upto 60 GB )

2.The huge table is partitioned ( SQL server 2005 table partitioning ) and placed in 20 different filegroups (.mdfs).

3.The .mdf's are placed in a SAN and .ldf is in local HD

4.Dynamic queries are used at few instances for performance benefits.

Questions:

1. Any thoughts on why this kind of performance issue arises ?

2. The client DBA wants us to clear the data and stored procedure cache before executing the stored procedure and test the performance.

Will this be would be the case in production scenario ?

3. Will the performance change based on the input parameters ?

4. The client DBA also have stated that a report server that pings the production database server is the cause for frequent clearing of the SQL Server cache.

When does the SQL Server database actually clears the cache memory? Is there any way to control it?

Any help would be highly appreciated.


Please let me know if you have any questions.

Thanks & Regards,

DBLearner

View 2 Replies View Related

Simple Performance Help

Nov 2, 2007

I am looking to take unique key value from some data
Check if that key value ( or record ) exists within a table
If it already exists then

update the row with my data based on the unique key
else

insert the data as a new row


for example ..........

DECLARE
@myNewID integer
@Result integer
@myNewValue VARCHAR(10)

@myNewId = 1234
@myNewValue = 'abcdefg'

SELECT @Result = SELECT count(*) FROM mytable WHERE keyID = @myNewID

if @Result > 0

UPDATE mytable SET colValue = @myNewValue
WHERE @KeyID = @myNewID
else

INSERT into mytable ( keyID, colValue ) values ( @myNewID, @myNewValue )


My question is, is there a better, faster way of doing this. I have to do this check around 100 times per minute 24x7x365
In reality the actual table I am checking is approx 2.5 million rows and growing fast. I'd like to eliminate the SELECT COUNT(*) step if possible, I know I could use SELECT 1, or an EXISTS type approach.

I'm thinking would it be better to just go ahead and INSERT and then check for a primary key constraint error and if found perform an Update. I was also thinking about INSERT and/or UPDATE triggers.

Any thoughts ?

KD


View 5 Replies View Related

Performance In Simple Scenarios

Aug 22, 2007

I have done some performance testing to see if asynchronous triggers performs any better than synchronous triggers in a simple audit scenario -- capturing record snapshots at insert, update and delete events to a separate database within the same instance of SQL Server.

Synchronous triggers performed 50% better than asynchronous triggers; this was with conversation reuse and the receive queue activation turned off, so the poor performance was just in the act of forming and sending the message, not receiving and processing. This was not necessarily surprising to me, and yet I have to wonder under what conditions would we see real performance benefits for audit scenarios.

I am interested if anyone has done similar testing, and if they received similar or different results. If anyone had conditions where asynchronous triggers pulled ahead for audit scenarios, I would really like to hear back from them. I invite any comments or suggestions for better performance.

The asynchronous trigger:



Code Snippet
ALTER TRIGGER TR_CUSTOMER_INSERT ON DBO.CUSTOMER
FOR INSERT AS
BEGIN
DECLARE
@CONVERSATION UNIQUEIDENTIFIER ,
@MESSAGE XML ,
@LOG_OPERATION CHAR(1) ,
@LOG_USER VARCHAR(35) ,
@LOG_DATE DATETIME;

SELECT TOP(1)
@CONVERSATION = CONVERSATION_HANDLE ,
@LOG_OPERATION = 'I' ,
@LOG_USER = USER() ,
@LOG_DATE = GETDATE()
FROM SYS.CONVERSATION_ENDPOINTS;

SET @MESSAGE =
( SELECT
CUST_ID = NEW.CUST_ID ,
CUST_DESCR = NEW.CUST_DESCR ,
CUST_ADDRESS = NEW.CUST_ADDRESS ,
LOG_OPERATION = @LOG_OPERATION ,
LOG_USER = @LOG_USER ,
LOG_DATE = @LOG_DATE
FROM INSERTED NEW
FOR XML AUTO );

SEND ON CONVERSATION @CONVERSATION
MESSAGE TYPE CUSTOMER_LOG_MESSAGE ( @MESSAGE );
END;






The synchronous trigger:



Code Snippet
ALTER TRIGGER TR_CUSTOMER_INSERT ON DBO.CUSTOMER
FOR INSERT AS
BEGIN
DECLARE
@LOG_OPERATION CHAR(1) ,
@LOG_USER VARCHAR(15) ,
@LOG_DATE DATETIME;

SELECT
@LOG_OPERATION = 'I' ,
@LOG_USER = USER() ,
@LOG_DATE = GETDATE()

INSERT INTO SALES_LOG.DBO.CUSTOMER
SELECT
CUST_ID = NEW.CUST_ID ,
CUST_DESCR = NEW.CUST_DESCR ,
CUST_ADDRESS = NEW.CUST_ADDRESS ,
LOG_OPERATION = @LOG_OPERATION ,
LOG_USER = @LOG_USER ,
LOG_DATE = @LOG_DATE
FROM INSERTED NEW
END;





View 4 Replies View Related

Network Performance For Simple Select Statement

Jul 23, 2005

I've just inherited a system and have some concerns about the speed ofconnections to a remote server (SQL2000). If I do a simple selectstatement on the table below, it takes 14 minutes to retrive 6 millionrows across a 2Mb line. Obviously it's a reasonable amount of data toretrieve, but I would have thought this would be quicker if I'm honest.Run locally, this is 50 seconds.My thoughts are that there may be some issues with our connection (weget general network errors sporadically, which are being looked at),but wanted some thoughts if the performance is acceptable for what itis doing with what is available. I don't think there is a SQL issue,but want to check if this sounds about right.It's early days, so I'm after a general impression of the speed ofretrieval for the amount of data on the available bandwidth. Assuming abest performance scenario, what is the minimum time it should take as abest guess ?ThanksRyanCREATE TABLE [FIELD_VALUES] ([DEALER_DATA_ID] [int] NOT NULL ,[FIELD_CODE] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NOTNULL ,[FIELD_VALUE] [numeric](15, 5) NULL ,[CHANGED_TYPE] [int] NULL ,CONSTRAINT [PK_FIELD_VALUES] PRIMARY KEY CLUSTERED([DEALER_DATA_ID],[FIELD_CODE]) WITH FILLFACTOR = 90 ON [PRIMARY]) ON [PRIMARY]GO

View 1 Replies View Related

Slow Performance With A Simple Query In A Small Table?

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

Performing A Very Peculiar Task

Jun 1, 2007

Hello All,

I am tackling with unique request. I have to download the ".zip" files from the https and uncompress them. Now, the fetch process works fine when I am downloading the files. Using .net and .IO namespaces from system library.

Similarly after downloading I have to uncompress the files as these files are treated by compressed file folders by windows xp. I know it can be achieved by using the IO.compression class form system namespace.
But the only trouble here is IO.compression supports ".gz" and "Gzipstream.Uncompress" and I wonder how I would be able to get the ".zip" and "Zipstream.uncompress" done.

Thanks a million in all your help and advice. Also I appreciate for your time.

Regards
Sandesh

View 1 Replies View Related

Cannot Install SQL Express; Peculiar Error

Jul 26, 2007

SQL Express installation is bombing out with the "A beta version of the .NET Framework 2.0 or SQL Server was detected on the computer...".

From the log file:
Running: PerformSCCAction2 at: 2007/6/26 8:17:27
Loaded DLL:C:WINsystem32msi.dll Version:3.1.4000.2435
Product "{7131646D-CD3C-40F4-97B9-CD9E4E6262EF}" versioned 2.0 is not compatible with current builds of SQL Server.Expected at least version: 2.0.50727.42
The Product Name is ".NET Framework"


Now what is peculiar to me is that
1) this machine should have never had the beta software on it;
2) I have seen people with similar issues except their versioned info always said "versioned 2.0.50727" and the product guid is different, this one only says "2.0"; and
3) I thought that product guid was for the RTM 2.0.50727.42 release!

What is going on here and where is it getting this version information?

brian

View 1 Replies View Related

Peculiar Problem With Seemingly Identical Data

Jul 20, 2005

Hello,I have this peculiar problem concerning MS SQL Server.My company works with an mailing application (ASP) which uses SQLServer as it's repository. What I want to do is send data directlyfrom my own application to this SQL Server in order to feed themailing application.To test if this was possible I linked the tables from SQL Server in MSAccess and entered the data. This worked fine and the data was pickedup correctly by the mailing application.The problem occurs when I send the data from my application (Javaapplication with JDBC connection). The data is in this case no longerpicked up by the application. The strange thing is that the data whichis entered through Access and the data from the Application lookidentical in de database view. The problem also occurs when the datais send with the tool winSQL and when I view the data in here it stilllooks identical.Even more strange is when I select the record which is not working inAccess and copy it into a new record (only changing the key) itsuddenly works!Has anyone have an idea how this can be?Thanks in advance,Sander Janssen.

View 3 Replies View Related

Peculiar Behavior In The Act Of Setting RS Parameter Values...

Jan 21, 2008

we're trying to get a better understanding of how RS behaves when parameters are being set. We see quirky behavior that is a little difficult to describe. Right now we assume that if the revolving green circle (with the phrase "Report is being generated" beneath it) doesnt appear, the report really wasnt rendered properly, even if the report region changes.

One peculiarity that seems pretty consistent is on reports we've prototyped with "from" and "to" date parameters. It seems that when we set one date (doesnt matter which is 1st) things progress normally, ie no "report clearing event" occurs as a result of setting cursor focus in the calendar control and changing its value. The report region doesnt change from what showed previously. But trying to set focus on 2nd (doesnt matter if its "from" date or "to" date, just that its the 2nd date being set) always seems to trigger some kind of event that 1) doesnt allow focus to be on that text box, 2) blanks out the report region including headings. Only after this "event" occurs, can we set focus on the 2nd date, change the value and click the "view report" button for rerendering.

We see similar types of behavior with other types of parameters that include multi value dropdowns and booleans. The toughest part of this is trying to explain it to our users. On some parameters, the event always occurs every time they are changed. On other parameters, it appears that the event only occurs if another parameter was changed beforehand.

I believe we've even seen headings with no data rendered, thinking temporarily that no rows were returned, just to find out that by clicking the "view report" button there really was data to be reported based on current filters. Unfortunately I cant reproduce this scenario when I want to.

View 3 Replies View Related

Peculiar Behavior In Stored Procedure (outputs Are Returning Proper Vals For Uniqueidentifiers And Ints, Not Nvarchars)

Apr 27, 2005

Rather than the real code, here's a sample we came up with.
 
Here's the C# Code:
public class sptest : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label1;
private DataSet dtsData;

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
string strSP = "sp_testOutput";
SqlParameter[] Params = new SqlParameter[2];
Params[0] = new SqlParameter("@Input", "Pudding");
Params[1] = new SqlParameter("@Error_Text", "");
Params[1].Direction = ParameterDirection.Output;
try
{
this.dtsData = SqlHelper.ExecuteDataset(ConfigurationSettings.AppSettings["SIM_DSN"], CommandType.StoredProcedure, strSP, Params);
Label1.Text = Params[0].Value.ToString() + "--Returned Val is" + Params[1].Value.ToString();
}
//catch (System.Data.SqlClient.SqlException ex)
catch (Exception ex)
{
Label1.Text = ex.ToString();

}
}
 
Here is the stored procedure:
 
CREATE PROCEDURE [user1122500].[sp_testOutput](@Input nvarchar(76),@Error_Text nvarchar(10) OUTPUT)AS
SET @Error_Text = 'Test'GO
When I run this, it prints up the input variable, but not the output variable.

View 2 Replies View Related

Difference In Performance Between Constant Scalar UDF Vs. Simple Constant

Oct 4, 2007

Is there a perf difference between:

create function dbo.zzz
returns uniqueidentifier
return '0000-0000-0000-00000000'

select dbo.zzz

vs.


se;ect '0000-0000-0000-00000000'





Thanks,
J

View 4 Replies View Related

Simple Simple Linking Tables & Perform Calculation

Mar 22, 2007

found it

View 3 Replies View Related

Simple Question (Hope Simple Answer Too)

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

[Performance Discussion] To Schedule A Time For Mssql Command, Which Way Would Be Faster And Get A Better Performance?

Sep 12, 2004

1. Use mssql server agent service to take the schedule
2. Use a .NET windows service with timers to call SqlClientConnection

above, which way would be faster and get a better performance?

View 2 Replies View Related

Extremely Poor Query Performance - Identical DBs Different Performance

Jun 23, 2006

Hello Everyone,I have a very complex performance issue with our production database.Here's the scenario. We have a production webserver server and adevelopment web server. Both are running SQL Server 2000.I encounted various performance issues with the production server with aparticular query. It would take approximately 22 seconds to return 100rows, thats about 0.22 seconds per row. Note: I ran the query in singleuser mode. So I tested the query on the Development server by taking abackup (.dmp) of the database and moving it onto the dev server. I ranthe same query and found that it ran in less than a second.I took a look at the query execution plan and I found that they we'rethe exact same in both cases.Then I took a look at the various index's, and again I found nodifferences in the table indices.If both databases are identical, I'm assumeing that the issue is relatedto some external hardware issue like: disk space, memory etc. Or couldit be OS software related issues, like service packs, SQL Serverconfiguations etc.Here's what I've done to rule out some obvious hardware issues on theprod server:1. Moved all extraneous files to a secondary harddrive to free up spaceon the primary harddrive. There is 55gb's of free space on the disk.2. Applied SQL Server SP4 service packs3. Defragmented the primary harddrive4. Applied all Windows Server 2003 updatesHere is the prod servers system specs:2x Intel Xeon 2.67GHZTotal Physical Memory 2GB, Available Physical Memory 815MBWindows Server 2003 SE /w SP1Here is the dev serers system specs:2x Intel Xeon 2.80GHz2GB DDR2-SDRAMWindows Server 2003 SE /w SP1I'm not sure what else to do, the query performance is an order ofmagnitude difference and I can't explain it. To me its is a hardware oroperating system related issue.Any Ideas would help me greatly!Thanks,Brian T*** Sent via Developersdex http://www.developersdex.com ***

View 2 Replies View Related

Simple Join Not So Simple

Feb 21, 2007

I am receiving funny results from a query. To simplify, I have 2 tables (todayyesterday). Each tbl has the same 8 columns. My query joins the two tables then looks where either of two columns has changed. What is happening is that when checking one of the columns it seems as though sql is flipping the column, causing it to be returned in error.

result set

colA colB colC colD colE colF colG colG (from yesterday)
1 1 a b c d e m
1 1 a b c d m e

So what's happening is that the record above is actually the same record and should not be returned. There is a daily pmt column that changes but I am not using that in the query. Aside from that the two records are identicle.

Any help is appreciated.

View 7 Replies View Related

Simple Join Not So Simple

Aug 19, 2006

Hi,

I have the following situation (with a site that already works and i cannot modify the database architecture and following CrossRef tables -- you will see what i mean by CrossRef tables below)

I have:


Master table Hotel

table AddressCrossRef (with: RefID = Hotel.ID, RefType = 'Hotel', AddrID)
joins
table Address (key = AddrID)


table MediaCrossRef (with RefID = Hotel.ID, RefType= 'Hotel', MediaID)
joins
table Media (with MediaID,mediaType = 'thumbnail')


foreach hotel, there definitely is a crossRef entry in AddressCrossRef and Address tables respectively (since every hotel has an address)

however not all hotels have thumbnail image

hence i have hotel inner join AddressXReff inner join Address ..... however i must have
left outer join mediaXref left outer join media


the problem is that if there is no entry in Media or mediaXref, I don't get any results

i tried to get over it by using
where (media.mediaTyple like 'thumbnail' or media.mediaType is null)
but then i started getting multiple results for each hotel because media's of type movie or full_image or etc... all got returned


any clue?

thanks

View 5 Replies View Related

Very Poor Performance - Identical DBs But Different Performance

Jun 22, 2006

Hello Everyone,I have a very complex performance issue with our production database.Here's the scenario. We have a production webserver server and adevelopment web server. Both are running SQL Server 2000.I encounted various performance issues with the production server witha particular query. It would take approximately 22 seconds to return100 rows, thats about 0.22 seconds per row. Note: I ran the query insingle user mode. So I tested the query on the Development server bytaking a backup (.dmp) of the database and moving it onto the devserver. I ran the same query and found that it ran in less than asecond.I took a look at the query execution plan and I found that they we'rethe exact same in both cases.Then I took a look at the various index's, and again I found nodifferences in the table indices.If both databases are identical, I'm assumeing that the issue isrelated to some external hardware issue like: disk space, memory etc.Or could it be OS software related issues, like service packs, SQLServer configuations etc.Here's what I've done to rule out some obvious hardware issues on theprod server:1. Moved all extraneous files to a secondary harddrive to free up spaceon the primary harddrive. There is 55gb's of free space on the disk.2. Applied SQL Server SP4 service packs3. Defragmented the primary harddrive4. Applied all Windows Server 2003 updatesHere is the prod servers system specs:2x Intel Xeon 2.67GHZTotal Physical Memory 2GB, Available Physical Memory 815MBWindows Server 2003 SE /w SP1Here is the dev serers system specs:2x Intel Xeon 2.80GHz2GB DDR2-SDRAMWindows Server 2003 SE /w SP1I'm not sure what else to do, the query performance is an order ofmagnitude difference and I can't explain it. To me its is a hardware oroperating systemrelated issue.Any Ideas would help me greatly!Thanks,Brian T

View 2 Replies View Related

This All Seemed Simple Enough...

Mar 24, 2007

...when I started this endeavor.
I have a previously developed Lotus Notes App. The idea was simple; as
I am sefl taught on Lotus Script, I figured I'd be able to stumble my
way through VB.Well,
it started OK. I used VB Express to get familiar with the stuff, but
decided to go with a full version of VS 2005 and try and get this thing
properly developed as a web app. I purchased several reference books
etc., and have become relatively familiar with the forums here.First
issue I have is that I simply want to use code to update or add records
to an SQL DB. I know about datagridview etc., but I want to update the
DB using forms, not the tabular view those controls provide. I thought
it would be relatively straight forward, but found my ignorance runs
deeper than I thought. When I tried to do so I am finding I am not
really clear on where to make declarations etc. in the web app.  If anyone could point me in the right direction that would be great. The
issue with searching these forums is most posts deal with datagridview
or something similar.I have spent a ton of time trying to find relevant
posts or articles, but have had no luck yet.Again, all Ireally
need is a nudge in the right direction. I am more than willing to plod
through reference materials or articles/posts to find what I need to
know, I just can't find where to even start on the info I need. Regards, Joe
 

View 3 Replies View Related

Its Got To Be Simple....

Feb 24, 2008

 Hi
I have a problem with my sql WHERE query, if i manually type ([Area] = 'The First Area')  then it is okay but if i try and pass the variable 'The First Area' using the

([Area] = @Area) it doesnt work. 
 ALTER PROCEDURE dbo.StoredProcedure1(@oby nvarchar,@Area char,@Startrow INT,@Maxrow INT, @Minp INT,@Maxp INT,@Bed INT)ASSELECT * FROM(SELECT row_number() OVER (ORDER BY @oby DESC) AS rownum,Ref,Price,Area,Town,BedFROM [Houses] WHERE ([Price] >= @Minp) AND ([Price] <= @Maxp) AND ([Bed] >= @Bed) AND ([Area] = @Area)) AS AWHERE A.rownum BETWEEN (@Startrow) AND (@Startrow + @Maxrow) Please Help I know it must be something simple as the sql works but not when i pass the variable.... Thanks In Advance  

View 2 Replies View Related

Simple SQL

Dec 30, 2004

How can i get an output like this from this sql??

HEM_PATIENT_ID is primary key...

Output:
First row: initial values of the fields
Second row: average of the same fields

Please help me...



select * from (
select HEM_LOKOSIT, HEM_NNS
from LPMS.HEMOGRAMS
where HEM_PATIENT_ID = 33
union
select AVG(HEM_LOKOSIT), AVG(HEM_NNS)
from LPMS.HEMOGRAMS
where HEM_PATIENT_ID = 33)
order by HEM_LOKOSIT desc nulls last;

View 1 Replies View Related

Simple Help

May 20, 2001

Am new to SQL Server , can any1 tell me is there anyway to display date in this format month and year like Apr 2000 ,excluding the day.

eg: 01/28/2000 should b displayed like Jan 2000

View 5 Replies View Related

Should Be Simple !!!!

Jan 25, 2001

Hi,

I'm relatively new to SQL7 but I did use 6.5 a fair bit.
I'm trying to test the restore of the Transaction log backup and having a bit of difficulty. The idea is that I make a complete database backup at 1am backup the transaction log every 30 minutes between 7am and 7pm. I need to be able to restore the database to a known state between 7am and 7pm with a max data loss of 30 minutes.

What I am trying to achieve is (as a test):

1)Create a small test database with a test table
2)Add some data to the test table
3)Back up the transaction log
4)Restore the transaction log to 'undo' the data added in step 2

Should be simple I think !!! The problem I am encountering is that in step 4 it won't let me restore only the transaction log (a tick automatically appears in the database backup as well). Bah !

Can someone please tell me what simple steps are required to get this to work. I need specifically on what options to chose during the backup and restore processes.

Thankyou,

Tim

View 4 Replies View Related

Simple SQL

Nov 8, 1999

Given one table with one column and two rows, one containing the string 'Bill', one containing the string 'Gates'.

Write a select statement which gives you the result 'Bill Gates'.

???+

View 1 Replies View Related

Simple SQL

Apr 2, 2003

Hi All,

I have a table with 2 columns which looks like the following.

IDText
-------------
1AAA
1BBB
1CCC
2DDD
2EEE
2FFF
3GGG
3HHH
3III

Each ID can have multiple texts associated with it. I want to write a query that gives me the following output.

IDText
-------------
1AAA; BBB; CCC
2DDD; EEE; FFF
3GGG; HHH; III

I appreciate your help

Thanks

View 1 Replies View Related

Simple SQL

Apr 2, 2003

Hi All,

I have a table with 2 columns which looks like the following.

IDText
-------------
1AAA
1BBB
1CCC
2DDD
2EEE
2FFF
3GGG
3HHH
3III

Each ID can have multiple texts associated with it. I want to write a query that gives me the following output.

IDText
-------------
1AAA; BBB; CCC
2DDD; EEE; FFF
3GGG; HHH; III

I appreciate your help

Thanks

View 1 Replies View Related

Looks Simple But ...

Jan 11, 2007

Hi,
I have a table with two columns. I need to find distinct value of col1 and the correspondin repeated value of col2 for that col1 value with comma seperated list. Is there any function
for this in MS SQL?
I need somethgn like
a 1,2,3
b 4,5
c 7
d 5,55,5

I can do that with creating 2 cursors but looking for some easy way around.

Any suggestion and help highly appretiate.

Thanks

View 2 Replies View Related

Simple Sql ?

Jan 20, 2006

incorrect syntax near #
how do i fix this and did i make any other errors?


SELECT Master.CheckNum, Master.CheckDate, Master.ExpenseType, Deal.Alias, Detail.InvoiceDate, Detail.InvoiceAmount, Detail.Person, Detail.Deal, Detail.InvoiceNum, Detail.Reference, Detail.idDetial
FROM Master INNER JOIN (Deal INNER JOIN Detail ON Deal.Deal = Detail.Deal) ON Master.CheckNum = Detail.CheckNum
WHERE (((Master.CheckDate)>#12/5/2005#) AND ((Deal.Alias)="aic"));

View 3 Replies View Related

Using And In Simple Sql

Apr 15, 2008

Originally i had:

DELETE FROM #RptDetails WHERE StructureType <> @StructureType
AND #RptDetails WHERE #RptDetails.TraderId <> @TraderId OR #RptDetails.TraderId is null


But it didnt delete the structure types i changed to :
DELETE FROM #RptDetails WHERE StructureType <> @StructureType --AND
DELETE FROM #RptDetails WHERE #RptDetails.TraderId <> @TraderId OR #RptDetails.TraderId is null

and it did, how do i format the 2nd sql into 1 statement and what was i doing wrong?

View 1 Replies View Related

Simple SUM

Apr 5, 2006

Hi,

How do I sum all of the returned values into my output param ? This returns multiple rows, all data is oftype decimal.

Thanks
Bob


ALTER proc
spPSICalcA9

@iReturn int output,
@Contract varchar (8)

as

Select
sd.HoursLostRain,
sd.HoursLostMaxT,
sd.HoursLostMinT,
sd.HoursLostFrost,
sd.HoursLostWind,
sd.HoursLostVis

from
SiteDiary sd
where
sd.Contract = @Contract



"I dislilke 7am. If &am were a person, I would kick 7am in the biscuits." - Paul Ryan, dailyramblings.com

View 5 Replies View Related

Simple AND OR

Apr 5, 2006

Hi,

I need to return all records where ..
Contract = @Contract

AND

CrossReference is null or ""

I have this but I dont think its right..

Bob

where
a.Contract = @Contract AND a.crossreference is null OR a.crossreference = ""


"I dislilke 7am. If &am were a person, I would kick 7am in the biscuits." - Paul Ryan, dailyramblings.com

View 8 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved