Transact SQL :: Last X No Of Tests

Jun 3, 2015

I have one requirement where i have multiple tests conducted on different dates where i have to calculate last 'x' no of tests

Test Date
Test  Seq
Subject

1/12/2014
1
English

[code]....

If i enter @testcount=2 then it should pull the data for only data related to test date 1/12/2014 & 10/06/2014...Above data is only sample data but logic should be dynamic..

View 9 Replies


ADVERTISEMENT

SQL 7.0 Admin Tests

May 19, 1999

Has anyone who has taken and passed the SQL 7.0 test for SQL Admin
have any recommendations on the best sources to help pass?

View 2 Replies View Related

Speed Tests (in Vs. Specified)

Jul 30, 2007

Hi Everyone -

We were discussing select speeds the other day,
the question comes in at...

what is faster, a standard query with specifies the search critera
i.e. select * from xyz where a='A' or a='B'
or is the IN a better way to go....

select * from xyz where a in ('A', 'B')

we ran the tests in performance analyzer,
but they were the same results....

maybe i'm smoking the stuff - but i thought the
useage of the IN causes a full table scan for each
of the items in the in clause

please advise

take care
tony

View 4 Replies View Related

Pre-certification Tests

Apr 23, 2007

Anyone know of a site or company that provide good pre-tests for certification?
I don't mind paying for downloadable test either.


Peter Larsson
Helsingborg, Sweden

View 5 Replies View Related

IT Tests. SQL, XML, ASP.NET, C, C++, C#, VB.NET, HTML...

Feb 17, 2006

http://www.testyourabilities.com/it/IT tests. SQL, XML, ASP.NET, C, C++, C#, VB.NET, HTML...

View 2 Replies View Related

SQL Sever Performance Tests

Jul 28, 1998

I am currently investigating tools that are available that would enable us to performance test SQL tables/databases- can anyone recommend any?

Thanks

View 1 Replies View Related

Web Tests Of Reports Working For Anyone?

Feb 11, 2007

Has anyone been successfull in creating a Web Test with Team System to test a Reporting Services report? I can record the test just fine but I can't run the test without errors being reported. I suspect that the session state has to be parameterized but I have no clue how to do this.

Why is this so hard? Why aren't there samples for this kind of thing? I've been all over the SSRS and Team Test forums and the MSDN site and can't find anything about Reporting Services reports being tested with Team System Web Tests.

View 1 Replies View Related

How To Modify This Code So That It Also Tests For NULL

Aug 2, 2004

Hi,
I'm trying to extend the usage of the code below. This method returns a variable of type SQLParameter and what I want is to accomodate even a check for a null in the parameter. This is a code which I got from one of my co-workers who isn't anymore working here. Any help would be appreciated. I do not want to throw an exception here when a field's type doesn't fall into one of the categories below. The method where this methos is called is the first part of my below code. Any help would be appreciated.

Part 1

private void AddCommandParameters(SqlCommand Comm, string sProcName, ArrayList aParams)
{
string sSQL = "sp_helptext @objname = '" + sProcName + "'";
SqlDataReader dr = this.GetDataReader(sSQL);
int i = 0;

if(dr.Read())
{
while(dr.Read())
{
//CLOSING PARENTHESIS
//When at the closing paren of the stored procedure's variable
//declaration, quit adding parameters.
if(dr[0].ToString().Trim() == ")")
{
break;
}
//ENDING PARENTHESIS
//When at the closing paren of the stored procedure's variable
//declaration, do nothing and skip to next record.
else if(dr[0].ToString().Trim() == "(")
{
//Nada
}
//PARAMETERS
//Add all the parameters listed in the stored procedure's variable
//declaration.
else
{
string [] sParamDef = dr[0].ToString().Trim().Split(Convert.ToChar(" "));
int cs = sParamDef.Length;
string st = sParamDef[0].ToString().Trim();
SQLParameter s = GetSQLParameter(sParamDef[0].ToString().Trim());
Comm.Parameters.Add(sParamDef[0], s.Type, s.Size);
Comm.Parameters[sParamDef[0]].Value = aParams[i];
i++;
}
}
}
else
{
throw(new Exception("Stored Procedure: " + sProcName + " NOT FOUND."));
}
dr.Close();
}


Method being called

private SQLParameter GetSQLParameter(string sVarTypeDec)
{
SQLParameter oParameter;

//VARCHAR
if(sVarTypeDec.IndexOf("varchar") >= 0)
{
int iOpen = sVarTypeDec.IndexOf("(");
int iClose = sVarTypeDec.IndexOf(")");
int iSize = Convert.ToInt16(sVarTypeDec.Substring(iOpen + 1, iClose - iOpen - 1));
oParameter = new SQLParameter(SqlDbType.VarChar, iSize);
}
//CHAR
else if(sVarTypeDec.IndexOf("char") >= 0)
{
int iOpen = sVarTypeDec.IndexOf("(");
int iClose = sVarTypeDec.IndexOf(")");
int iSize = Convert.ToInt16(sVarTypeDec.Substring(iOpen + 1, iClose - iOpen - 1));
oParameter = new SQLParameter(SqlDbType.Char, iSize);
}
//SMALLDATETIME
else if(sVarTypeDec.IndexOf("smalldatetime") >= 0)
{
int iSize = 4;
oParameter = new SQLParameter(SqlDbType.SmallDateTime, iSize);
}
//DATETIME
else if(sVarTypeDec.IndexOf("datetime") >= 0)
{
int iSize = 8;
oParameter = new SQLParameter(SqlDbType.DateTime, iSize);
}
//FLOAT
else if(sVarTypeDec.IndexOf("float") >= 0)
{
int iSize = 8;
oParameter = new SQLParameter(SqlDbType.Float, iSize);
}
//REAL
else if(sVarTypeDec.IndexOf("real") >= 0)
{
int iSize = 4;
oParameter = new SQLParameter(SqlDbType.Real, iSize);
}
//SMALLMONEY
else if(sVarTypeDec.IndexOf("smallmoney") >= 0)
{
int iSize = 4;
oParameter = new SQLParameter(SqlDbType.SmallMoney, iSize);
}
//MONEY
else if(sVarTypeDec.IndexOf("money") >= 0)
{
int iSize = 8;
oParameter = new SQLParameter(SqlDbType.Money, iSize);
}
//BIT
else if(sVarTypeDec.IndexOf("bit") >= 0)
{
int iSize = 1;
oParameter = new SQLParameter(SqlDbType.Bit, iSize);
}
//TINYINT
else if(sVarTypeDec.IndexOf("tinyint") >= 0)
{
int iSize = 1;
oParameter = new SQLParameter(SqlDbType.TinyInt, iSize);
}
//SMALLINT
else if(sVarTypeDec.IndexOf("smallint") >= 0)
{
int iSize = 2;
oParameter = new SQLParameter(SqlDbType.SmallInt, iSize);
}
//BIGINT
else if(sVarTypeDec.IndexOf("bigint") >= 0)
{
int iSize = 8;
oParameter = new SQLParameter(SqlDbType.BigInt, iSize);
}
//INT
else if(sVarTypeDec.IndexOf("int") >= 0)
{
int iSize = 4;
oParameter = new SQLParameter(SqlDbType.Int, iSize);
}
else
{
throw(new Exception("Parameter type not supported."));
}

return oParameter;
}



Thanks,

View 1 Replies View Related

Remote Connection Tests Fine, But Nothing Works On The Page Itself.

Mar 26, 2008

If this post belongs somewhere else I appologize. I have spent several days trying to solve this problem with no luck. My site is online. Hosted at NeikoHosting. I can connect to the database remotely when adding a datacontrol. It tests fine. But when running the page it won't connect. Even if I go in and change the Web.Config connection string to a local Data Source provided to me by Neiko, it still won't work. It just won't connect. Here are the two connection strings in the Web.Config, minus my login info: Only the remote string will pass testing. Neither works on the site. <add name="yourchurchmychurchDBConnectionString" connectionString="Data Source=MSSQL2K-A;Initial Catalog=yourchurchmychurchDB;Persist Security Info=True;User ID=me;Password=pwd" providerName="System.Data.SqlClient" />
<add name="yourchurchmychurchDBConnectionString2" connectionString="Data Source=66.103.238.206;Initial Catalog=yourchurchmychurchDB;Persist Security Info=True;User ID=me;Password=pwd" providerName="System.Data.SqlClient" />
 Here is the stack trace, if that helps.
[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied.
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.OleDb.OleDbException: [DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied.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:



[OleDbException (0x80004005): [DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied.]
System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection) +1131233
System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject) +53
System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup) +27
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +47
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +105
System.Data.OleDb.OleDbConnection.Open() +37
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.FormView.DataBind() +4
System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82
System.Web.UI.WebControls.FormView.EnsureDataBound() +163
System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +69
System.Web.UI.Control.EnsureChildControls() +87
System.Web.UI.Control.PreRenderRecursiveInternal() +50
System.Web.UI.Control.PreRenderRecursiveInternal() +170
System.Web.UI.Control.PreRenderRecursiveInternal() +170
System.Web.UI.Control.PreRenderRecursiveInternal() +170
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2041

So....... HELP!!!!
 
Thank you!

View 3 Replies View Related

SQL 2012 :: No Disks Were Found On Which To Perform Cluster Validation Tests

Sep 9, 2014

I am getting following errors in my Cluster Validation report when trying to create a Windows Cluster.

I have 2 nodes DB01 and DB02 . Each has 1 public ip, 1 private ip (for heartbeat), 2 private ips for SAN1 and SAN2. The private ip's to SAN are directly connected via Network Adaptor in DB01 and DB02.

Validate Microsoft MPIO-based disks
Description: Validate that disks that use Microsoft Multipath I/O (MPIO) have been configured correctly.
Start: 9/9/2014 1:57:52 PM.
No disks were found on which to perform cluster validation tests.
Stop: 9/9/2014 1:57:53 PM.

[Code] ...

View 9 Replies View Related

SqlDataSource Set To Stored Procedure, Tests OK In Wizard, Does Not Return Data When Executed

Apr 27, 2007

With a  Gridview Control, I set the SqlDataSource to be a stored procedure in a Sql Sever database. 
Using the wizzard to configure the datasource, the test returns lots of rows.  After completing the wizzard, the gridview control does not show the column names in the VS2005 designer.  For the gridview column headers the values are Databound Col0, Databound Col1, Databound Col2, ....)   This tells me I have a problem.
 I tried the same thing with a  simpler stored procedure. This test stored procedure does not call anything else, takes several input parameters, returns rows.  The column names show in the gridview control as expected.
 So I am trying to figure out why the first case of gridview with sqldatasource is not working and the second case works .  The stored procedure that is not working with my gridview calls multiple inner stored procedures and has #TEMP tables. My complex stored procedure ends with Select * from #Temp.
 Could the calling of other inner stored procedures and use of #temp tables contribute to the problem?  If yes then what is the strategy for using a gridview and loading it with the data that the complex stored procedure returns? 

View 8 Replies View Related

SQL Server 2008 :: Linked Server Tests Fine But Query Does Not Work

Apr 16, 2015

Using a 32-Bit SQL Server 2008 Express on my LOCAL PC. I downloaded the Advantage 8.1 OLE DB Provider and created a linked server to a REMOTE Advantage 8.1 database server. There is no data dictionary on the Advantage server.

Here is my linked server:

EXEC master.dbo.sp_addlinkedserver @server = N'1xx.1xx.xx.1xx', @srvproduct=N'Advantage', @provider=N'Advantage OLE DB Provider', @datasrc=N'1xx.1xx.xx.1xxeccET', @provstr=N'servertype=ads_local_server;tabletype=ads_cdx;'--tabletype=’ADS_ADT’ (this test works too)
EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'1xx.1xx.xx.1xx',@useself=N'False',@locallogin=Null,@rmtuser='adssys',@rmtpassword=Null

Testing the link succeeds with above. Using “ads_REMOTE_server” instead of “ads_local_server” and the test fails. Here is my problem, using the following queries will not work. Perhaps it’s a permissions issue? When I specify my local credentials for the remote server in the linked server it still does not work.

SELECT * FROM OPENQUERY([1xx.1xx.xx.1xx], 'SELECT * FROM ActType')

OLE DB provider "Advantage OLE DB Provider" for linked server "1xx.1xx.xx.1xx" returned message "Error 7200: AQE Error: State = HY000; NativeError = 5004; [Extended Systems][Advantage SQL][ASA] Error 5004: Either ACE could not find the specified file, or you do not have sufficient rights to access the file. Table name: ActType SELECT * FROM ActType".
Msg 7321, Level 16, State 2, Line 2

An error occurred while preparing the query "SELECT * FROM ActType" for execution against OLE DB provider "Advantage OLE DB Provider" for linked server "1xx.1xx.xx.1xx".

View 0 Replies View Related

Transact SQL

Jan 7, 2008

I have the following SELECT statement. It returns the first record from EVENT_TEACHERS. I want the last record. 'iID' is the unique identifier so I want to select this stuff where iID is max. How can I add this to my string? I can't get the block out of my head of wanting to put the aggregate in the WHERE clause.
str = "SELECT vwStaffList4Assessment.*, EVENT_TEACHERS.iID, EVENT_TEACHERS.iAsmtID, ASMT.* FROM EVENT_TEACHERS INNER JOIN ASMT ON EVENT_TEACHERS.iAsmtID = ASMT.iAsmtID INNER JOIN vwStaffList4Assessment ON ASMT.DVN=vwStaffList4Assessment.DVN"
Thanks

View 5 Replies View Related

Help With Transact

Feb 28, 2008

I am trying to insert to our DB. Here is my insert statement.
str = "INSERT INTO SURVEY (q3) VALUES (" & q3 & ") WHERE iID="&iID
Here is my debug:
DEBUG: INSERT INTO SURVEY (q3) VALUES (1) WHERE iID=23
And here is my error:
Incorrect syntax near the keyword 'WHERE'.
Can someone please tell me what I am doing wrong? Thanks in advance.

View 3 Replies View Related

Transact SQL

Mar 15, 2006

I have the following string in Access as a field
SpecCmplDate: IIf([SaleStatus]="Spec",[Close],"")
How do I create this field in SQL Server?

View 2 Replies View Related

Transact SQL

Jul 27, 2001

I am new to SQL and need some help. Would anyone be able to tell how to write a statmement, that would bring back several columns with specific amounts of spaces in it? I don't want to change the sizes of the columns forever, just for this one query.

Thanx in advance.

sql amateur

View 2 Replies View Related

Transact SQL

Jul 29, 1998

Hello all,

I`m trying to do a "order by" on a datefield in a query (month only), and I would like my result set to be sorted started with a value that I provide.

For example, I would like the result set to be sorted begining with october:

October ...
November ...
December ...
January ..
February ...
March ...

But of course it gave me:
January ..
February ...
March ...
November ...
December ...

I attempted to do it in 2 selects with a union but it wouldn`t let me do an "order by" in both select statements with the union operator.


-skye

View 3 Replies View Related

Vb6, Transact Sql, Asp

Sep 5, 2004

CALL CENTER IT SUPPORT

I START A NEW JOB WITH A COMPANY PROVIDES IT SUPPORT TO CALL CENTERS. WE USE VB6 CONNECTING
VIA ADO TO SQL SERVER 2000 STORED PROCEDURES. OUR ONLINE REPORTING TOOL USES CRYSTAL REPORTS &
ASP (LITTLE VB6). CAN ANYONE RECOMMEND GOOD BOOKS AND WEBSITES TO PREPARE ME FOR MY NEW POSITION
WITH THIS COMPANY?

ALSO, HOW DOES ONE GO ABOUT BUYING RELEVANT CODE IN VB6, TRANSACT SQL, ASP?

WITH CALL CENTERS (OUR CLIENTS) MOVING OVERSEAS-OUTSOURCING, WHAT ABOUT ENRICHING OUR
POTENTIAL CLIENT BASE...FOR EXAMPLE, RECOMMENDING MARKETING EFFORTS TO 'NAILED DOWN' CLIENTS
LIKE PHARMACEUTICAL COMPANIES WHERE THE GOVERNMENT DEMANDS SUCH WORK BE DONE IN AMERICA. OR
EXPANDING OUR ROLE TO ALSO DO...?

ANY IDEAS TO ABOVE THREE ISSUES PLEASE-PLEASE EMAIL mikelynn@comcast.net

View 1 Replies View Related

Transact SQL

Jan 9, 2007

Hi: Can any one please tell me the difference b/w TSQL and simple SQL. Also there is a a TSQL use in my VB6 Program, how to i find that SQL in SQL Server?
cnADOSQL.Execute "DBCC CHECKIDENT ('tbl_distlist_balrange', RESEED, 0)"


Thanks.

View 3 Replies View Related

TRANSACT-SQl

May 14, 2004

Hi,
What is the sql syntaxe to specify which database can be accessed by a login.

View 2 Replies View Related

LIKE (Transact-SQL)

May 30, 2008

I am trying to use LIKE in a statement but I can't seem to pull all the rows for Age of Empire. I have at least 50 rows with the word Age of Empire but I only get two rows. What is the best way to use LIKE in the statement below so that it pulls all rows with the words Age of Empire?

Select * from dbo.proddesc
where codeabbreviation Like '%Age of empire%'

View 2 Replies View Related

Transact SQL

Mar 12, 2006

Hi Im reading about active and temporal databases. I have a quesiton though.
In which category does SQL server falls into?
Also
What is the difference between Transact SQL and TSQL2?

thanks

View 4 Replies View Related

Transact-SQL SUM Help!

Jul 11, 2006

I am trying to tally up information from two tables, but I am runningin to trouble and I can't seem to figure this out. I have aCreditsTable and a DebitsTable and I am trying to create a querry thatsums up the info from each per UserID and returns TotalCredits,TotalDebits, and a Ballance.CreditsTableUserID Ammount Applied+----------+----------+----------+| 192 | 1 | True || 192 | 2 | True || 207 | 1 | True || 207 | 1 | True || 207 | 2 | True || 212 | 3 | True |DebitsTableUserID Ammount Applied+----------+----------+----------+| 192 | 1 | True || 207 | 1 | True || 207 | 1 | True |***This is the Function I have tried, but it doesn't return the correctresultsALTER FUNCTION [dbo].[BallanceTotals]()RETURNS TABLEASRETURN(SELECT DISTINCTdbo.CreditsTable.UserID, SUM(dbo.CreditsTable.Ammount) AS TotalCredits,SUM(dbo.DebitsTable.Ammount) AS TotalDebits,SUM(dbo.CreditsTable.Ammount - dbo.DebitsTable.Ammount) AS BallanceFROMdbo.CreditsTable FULL OUTER JOINdbo.DebitsTable ON dbo.CreditsTable.UserID = dbo.DebitsTable.UserIDWHERE(dbo.CreditsTable.Applied = 1) OR (dbo.DebitsTable.Applied = 1)GROUP BYdbo.CreditsTable.UserID)*** This is what it returns, it is not adding things up correctly (itlooks like it is adding NULL values as 1 instead of 0 or something)BallanceTotalsTotal TotalUserID Credits Debits Ballance+----------+----------+----------+----------+| 192 | 3 | 2 | 1 || 207 | 4 | 3 | 1 || 212 | 3 | | |*** This is what I want it to return!BallanceTotalsTotal TotalUserID Credits Debits Ballance+----------+----------+----------+----------+| 192 | 3 | 1 | 2 || 207 | 4 | 2 | 2 || 212 | 3 | 0 | 3 |I would really appreciate some help in getting this to work correctly!-Daniel

View 5 Replies View Related

Transact SQL :: Add Where To CTE

Aug 10, 2015

Why is my where skewing data?  This 1st statement shows everything perfectly, but this go around Ineed to add one more stipulation and adding in the where returns 0 results.  But if I run a simple select with the where added, I get the intended result set.

--works
with cte as(select *, row_number() over(partition by time1, time2, userID
order by userID ) as rn from timetable)
delete from cte where rn > 1

--no work
with cte as(select *, row_number() over(partition by time1, time2, userID
order by userID ) as rn from timetable where timeadded > 0)
delete from cte where rn > 1

View 5 Replies View Related

Transact SQL :: Can't Get SUM Value

Jul 10, 2015

Below is my SQL code and after that output i get. For result i would like to get SUM of column Expr1 (which is 60.668,66) so that means only 1 row not 5. I know it's not that hard but i've been searching around and trying but no luck...

SELECT INVENTTABLE_1.ITEMID AS MA, INVENTDIM_1.INVENTLOCATIONID, SUM(INVENTSUM_1.PHYSICALINVENT) AS Expr1
FROM dbo.INVENTDIM AS INVENTDIM_1 INNER JOIN
dbo.INVENTSUM AS INVENTSUM_1 ON INVENTDIM_1.INVENTDIMID = INVENTSUM_1.INVENTDIMID INNER JOIN
dbo.ECORESPRODUCTTRANSLATION AS ECORESPRODUCTTRANSLATION_1 INNER JOIN
dbo.INVENTTABLE AS INVENTTABLE_1 ON ECORESPRODUCTTRANSLATION_1.PRODUCT = INVENTTABLE_1.PRODUCT ON

[Code] ....

View 4 Replies View Related

Transact-SQL Help

Feb 28, 2008

I have 3 tables in SQL 2005. I have dumbed them down significantly, to illustrate my question.

1) Item Table - Contains a list of 2 items, "Coca-Cola" and "Pepsi-Cola".
2) Market Share - Contains the 'market share' information for the items in "Item Table". 1 to 1 relationship.
3) Retail Price - Contains the 'average retail' price data for the items in "Item Table". 1 to 1 relationship.

All three tables are linked by "iItemID".

I am trying to build a simply query that generates the following results:

----------------------------------------------------------
Item Name Market Share Retail Price
-----------------------------------------------------------
Coca-Cola mm.mm% $xx.xx
Pepsi-Cola mm.mm% $xx.xx


If, I first focus on retrieving the Market Share data, using the following query, it retrieves what I want.

SELECT tblItems.sItemName, tblMarketShare.sYTD
FROM tblItems INNER JOIN
tblMarketShare ON tblMarketShare.iItemID = tblItems.iItemID

----------------------------------
Item Name Market Share
----------------------------------
Coca-Cola mm.mm%
Pepsi-Cola mm.mm%


However, if I then add the RetailPrice price table (using the following query), I get the following incorrect results.

SELECT tblItems.sItemName, tblMarketShare.sYTD, tblRetailPrice.sYTD
FROM tblItems INNER JOIN
tblMarketShare ON tblMarketShare.iItemID = tblItems.iItemID INNER JOIN
tblRetailPrice ON tblRetailPrice.iItemID = tblItems.iItemID

----------------------------------------------------------
Item Name Market Share Retail Price
-----------------------------------------------------------
Coca-Cola mm.mm% $xx.xx
Pepsi-Cola mm.mm% $xx.xx
Coca-Cola mm.mm% $xx.xx
Pepsi-Cola mm.mm% $xx.xx

Where the first two values for Market Share are repeated again for row 3 and 4.

How do I syntax my SQL statement to return a single data set in the following fashion?
----------------------------------------------------------
Item Name Market Share Retail Price
-----------------------------------------------------------
Coca-Cola mm.mm% $xx.xx
Pepsi-Cola mm.mm% $xx.xx

I know this is simple for someone who write queries all the time. But this is driving me crazy. I have tried various JOINS (LEFT OUTER, RIGHT, etc.), but I am missing something.

Anyone's help greatly appreciated.

Thanks,

Vance

View 6 Replies View Related

Transact SQL

Mar 18, 2008

Is it possible to create a Server Role without have the Drop Database option

View 2 Replies View Related

How To Write This In Transact-SQL

Dec 23, 2004

I need to return a computed value and have no idea how to do it.

I have a table of dates:
Column DataType
RowID int
Person nvarchar(20)
Percent real
Date smalldatetime

What I need is the Annual Fiscal Year Average. The fiscal year starts and ends in June. I need it to add all Percent values between the months of June 2001 - June 2002, June 2002 - June 2003, and so on and on....

A result set like this...

Person - FiscalYear - FiscalYearResult
John D - 2001 - .58
John D - 2002 - .52
John D - 2003 - .50
Jane D - 2001 - .58
Jane D - 2002 - .52
Jane D - 2003 - .50

so on and so on...

How do I write this in Transact-SQL to get this result set...

Thanks,
Roger

View 1 Replies View Related

Transact-SQL Programming

Aug 3, 2000

I have a table containing almost 700000 records. The table contains the following fields:

table_id, member#, car_eff_dt, car_term_dt, mbr_occur.

A member can occur more than one time and his effective date/termination date are sorted sequentially.

An example would look like this:

table_id member# car_eff_dt car_term_dt mbr_occur
1 12345678901 01/01/1995 12/31/1995 null
2 12345678901 01/01/1996 12/31/1996 null
3 12345678901 01/01/1997 12/31/1997 null
4 10987654321 07/15/1998 02/16/1999 null
5 10987654321 04/01/2000 12/31/9999 null

Using Transact-SQL, is it possible to generate a unique number for each occurance of a particular member#?

table_id member# car_eff_dt car_term_dt mbr_occur
1 12345678901 01/01/1995 12/31/1995 1
2 12345678901 01/01/1996 12/31/1996 2
3 12345678901 01/01/1997 12/31/1997 3
4 10987654321 07/15/1998 02/16/1999 1
5 10987654321 04/01/2000 12/31/9999 2

Currently, I am running the code in an Access/VBA module through an ODBC connection, but I would like to be able to run all my code directly on the server.

Thanks in advance for any help you might be able to provide.

View 1 Replies View Related

SQL 6.5 - Transact SQL Possibilities...

Aug 28, 2002

Dear SQLGuru,

I came to know one of the better option in Oracle SQL for TOP-N Analysis-To find the top 5 usage accounts, top 10 users, etc. Is there any such way in SQL server ?

Is there any ways of using JOINS ( using keyword INNER & OUTER ) ? Some of the scripts that is generated automatically in Microsoft access with Join condition is not even working in MSSQL server 6.5. Is it true ? Or is there any other way that I can use these scripts in SQL 6.5.

If possible, pls. help me with some sample scripts ?


Thanks a lot in advance.
Naga

View 1 Replies View Related

Transact.log Is Full

Sep 2, 1999

Hi!
I need help!
We have 98% transact log full.
After run
DUMP TRANSACTION WITH TRUNCATE ONLY it still doesn't purge the log.
How can we resolve problem.

Thank you,
sev

View 2 Replies View Related

Transact-SQL And XML Help Needed.

Jul 4, 2004

Ok here is the situation I need a little help with.

I am passing an XML document to a stored procedure. My XML document looks like this:
<ROOT>
<customer ID="10" Address="1234 Somewhere"></customer>
<customer ID="20" Address=""></customer>
</ROOT>

Now I use sp_xml_preparedocument and OpenXML to Insert the XML ID and Address attributes into a table in my database. The table has 2 fields (ID int) and (Address varchar(100) nullable)

The result of the insertion is 2 rows in my table with the ID field containing (10 and 20) and the Address field containing (1234 Somewhere and an empty string).

My first question is, why isn't the second row Address field in my database null instead of an empty string since thats what I would like happen. Is it because the XML Address atribute = "".

If that is the case then that should bring up my second question. Since the OpenXML inserts Address="" as an empty string instead of NULL, why doesn't a regular TransactSQL INSERT statement called from ASP does the same thing?? If I lost you here then let me give a quick example.
An html web form with a text field (txtAddress). The user leaves the text box empty and submits the form. My ASP takes the value of the form, Request.Form("txtAddress") and passes it to stored proceudre through an ASP parameter object. My stored procedure simply does an INSERT into tablename (ID, Address) VALUES (@passedID, @PassedAddress). Now the outcome in the database is that the Address field is NULL and not an empty string.

That is why im confused. Why arent the OpenXML and the straight-forward insertion yield the same result (either null or empty string). It seems to me that an empty text box is an empty string and not null. ASP's ISNull(txtAddress) agrees and returns false.

Any insight ot help on this issue is greatly appreciated.

View 1 Replies View Related

HELP! Transact SQL Cursors

Aug 19, 1999

What I am trying to do is iterate through a set of records from a table, and setting one field to a common value on each record, and setting another to an incremented value. Here it is:

Table contains columns A, B, and C.
A is a unique ID.
B is an ID.
C is another value.

I want to, for all records where field B = "AAA", Set B to "AAB", and set A on each record to the next unique ID that I get from somewhere else. Here's my SQL Stored Proc:

DECLARE MYCURSOR SCROLL Cursor FOR SELECT A, B FROM MyTable where B = 1 FOR UPDATE.

Loop:

FETCH NEXT INTO @vcA, @vcB FROM MYCURSOR.
UPDATE MYTABLE SET A = @nctr, B = "AAB" WHERE CURRENT OF MYCURSOR
SELECT @nctr = @nctr + 1
If @@FETCH_STATUS = 0 goto Loop:

I hit an error as soon as I get to the Update -
"Cursorfetch: Number of variables declared in the INTO list must match that of selected columns"

Go Figure. I really need an answer on this ASAP! Help!

View 1 Replies View Related







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