Help I M New To SQL And Weak At Making Queries

Apr 30, 2007

plzzzzzzzzzzzzzzzzzzzzz !!!!!!!

help i m new to SQL and weak at making queries


can u please suggest me some books or site from
where i can pratice making queries


u can mail me at
rastogi.akash@gmail.com

View 1 Replies


ADVERTISEMENT

Making Multiple Queries

Feb 26, 2008

Hi,

I have some questions about making muliple T-SQL queries againt an SQL-server. I retrieve all rows from an SQL-server table called ActivityGroup and add the result to a Radio Button List. Suppose, I also wish to add the total sum of every "ActivityGroup" value to the Radio Button List. I guess this ought to be done using a SELECT COUNT statement and then retrieved using the Executescalar method?

The question is do I need to copy the code for the SELECT ('*) statement and make the neccessary changes for the SELECT COUNT statement and Executescalar method or is there a more simple way? Is it possible to use two command statements in the same code block?

The total sum is going to be calculated using the values from both an SQL-server and an Access database. The OleDb sample below is what I refer to as a code block. I appreciate any help!



string connectionString = ConfigurationManager.ConnectionStrings["ServetteConnectionString"].ConnectionString;

string sQuery = "SELECT * FROM Aktivitetsgrupper where aktivitetsid = " + Request["AktivitetsId"];



OleDbConnection oOleDbConnection = new OleDbConnection(connectionString);

oOleDbConnection.Open();

OleDbCommand command = new OleDbCommand(sQuery, oOleDbConnection);

OleDbDataReader reader = command.ExecuteReader();

int test = 12;

while (reader.Read())

{



rblAktivitetsgrupper.Items.Add(new ListItem(String.Format("{0}, platser", reader["aktivitetsGruppNamn"]), reader["aktivitetsGruppID"].ToString()));



}

View 4 Replies View Related

Containstable Queries Not Making Sense.

Jan 2, 2008

I have a few questions related to using CONTAINSTABLE in a query that I hope someone can help with.

I am working on a project to add document search capabilities to my companies product using fulltext indexing. Part of this requirement is an ability to breakdown the component parts of of the search query and provide information on *why* documentX ranked higher than documentY.
This is a bit convoluted, but taking this (very simple) example - the user wishes to search for 2 skills - "HTML" and/or "XML".
The generated query looks a little like :-

Select DOC.DOC_ID, RANK1.RANK, RANK2.RANK, RANK3.RANK
from DOCS DOC
inner join CONTAINSTABLE(docs, doc, 'HTML AND XML') as RANK1 on RANK1.DOC_ID=DOC.DOC_ID
inner join CONTAINSTABLE(docs, doc, 'HTML') as RANK2 on RANK2.DOC_ID=DOC.DOC_ID
inner join CONTAINSTABLE(docs, doc, 'XML') as RANK3 on RANK3.DOC_ID=DOC.DOC_ID

This returns the "overall" rank, and a rank for the 2 component parts, so I can say this doc ranked XXX overall because it scored "rank1" for HTML and scored "rank2" for XML etc....

My question on this part is about the values for the "overall rank". If the query contained an OR it always seems to return the highest of the "rankX" values, and if it doesnt, it returns the lowest.
e.g. for the example
for java and word and excel and access - the overall ranking is 2 , java=36, word=2, excel=16 and access=36
for java and word or excel and access - the overall ranking is 16 , java=36, word=2, excel=16 and access=36
for (java and word) or (excel and access) - the overall ranking is 16 , java=36, word=2, excel=16 and access=36

So in the first example, regardless of what the other values are, the rank returned is always 2 (the score for "word"). My resultset has 100ish rows, all with a rank of < 5 for word, but all with ranks of 18-100 for the other 3 values - yet the "overall" rank always matched the "word" rank.....??
This doesnt feel right to me somehow, I would expect a different value as if the document ranked really highly for one value but low for the other, it doesnt feel right the value is clamped to the lowest? Or am I just understanding it wrong?
If I use "freetexttable" the overall rank is a little more meaningful - but unfortunately I also need to use weighting, which brings me to my next question . . .


This question is about rankings returned from the ISABOUT function.
In the following example,
select * from documents as DOC
inner join containstable(docs,doc,'project') as doc0 on DOC.DOC_ID=doc0."key"
inner join containstable(docs,doc,'ISABOUT (project weight (1.0))') as doc1 on DOC.DOC_ID=doc1."key"
inner join containstable(docs,doc,'ISABOUT (project weight (0.5))') as doc2 on DOC.DOC_ID=doc2."key"
inner join containstable(docs,doc,'ISABOUT (project weight (0.1))') as doc3 on DOC.DOC_ID=doc3."key"
inner join containstable(docs,doc,'ISABOUT (project weight (0.0))') as doc4 on DOC.DOC_ID=doc4."key"
order by doc0.rank desc

The values I get from the doc1/2/3/4.RANK columns dont seem right.
In this example,

doc0.rank = 133
doc1.rank = 150
doc2.rank = 330

doc3.rank = 924

doc4.rank = 0

These values dont make any sense to me, as the rank seems to go UP when the documentation on ISABOUT says it goes down (I think it says somewhere the calculated rank is multiplied by the weight?).
Once again, is there something I missed or am I understanding it wrong?

Thanks in advance for any help into understanding the whys of this...

View 1 Replies View Related

Making A View That Shows The Results Of Several Different Queries.

Dec 21, 2005

Hello,I am trying to create a view that shows the followingField1: Sum of Amounts from Table AField2: Count of Amounts from Table AField3: Sum of of Amounts from Table BField4: Count of Amounts from Table B......Field3: Sum of of Amounts from Table HField4: Count of Amounts from Table H......Things are a bit more complex but this is the gist.I am using SQL 2000.I know how to do this pretty easily using a stored procedure. But howcan I do it in a view? A SQL server won't meet my needs in thissituation.I tried OpenQuery ('myserver', 'exec myprocedure') but get the messagethat my server is not configured for data access. I tried the systemstored procedure to set data access to true but nothing seemed tohappen.I also tried Select * from (Select Statement1, select statement2)but got syntax error at the comma between statement1 and statement2.Trying to use select Statement1 as ABC to does not seem to work either.Is there a way to do what I want without making 15 views and then afinal view that shows them all together? I know I could probably dosomething by creating a ton of functions, but it really seems thisshould not be that hard...I am definitely open to any easy suggestions!Thanks,Ryan

View 3 Replies View Related

SQL Server 2014 :: Making Dashboard In Excel From Queries?

Jul 20, 2015

Currently i have set of queries which i run for data extraction and result pasted in Excel table so that my pivot table and Chart gets populated along with the summary in Excel file.

I would like to automate this thing and want to know if i can achieve excel output for dashboard on a click of button.

View 2 Replies View Related

Weak Performance And SQL-Server Hang-Ups

Dec 2, 2004

Greetings everybody,

lately we are experiencing some very strange behaviour on the part of our
SQL-Server.

We are using SQL-Server as a combined Database for one COM+ application and one J2EE-Application. All of this is installed on the same machine (dual-CPU, 2 GB RAM).

This setup has been up and running for almost a year now.

In the last two weeks there have been incidences where the performance of SQL-Server is decreasing steadily until it finally hangs completely (just SQL-Server, not the machine itself).

This happens 2-3 times a week, curiously always between 9 and 10 a.m.!

After stopping and restarting the actual SQL-Server "Service", everything is back to normal (until the next morning or the morning after that).

There are a few automated batches that access the database via the COM+ Server. These run at night and are completed before work begins at ca. 7 a.m.

Profiler-Logs show a few "Escalate Locks", but those alone cannot account for this strange behaviour.

Any help or info would be greatly appreciated.

View 4 Replies View Related

The Difference Between Composite And Weak Entities

Mar 21, 2008

Hi,

A Composite entity can be made out of two Primary Keys (PK) of two different entities. Therefore it can be called as a link table. Therefore the composite entity depends upon the other two entites. Therefore the composite entity is a exsitence dependent on the other two entities.

Therefore do every composite is a weak entity?

TY

View 3 Replies View Related

Making A League

Apr 14, 2007

Hello, I have a table of data with the following columns:ParticipantResult (win or lose)The table has other data in, but I want to make a league to sort by the amounts of wins. For example: Participant            Won            PlayedA                          5                  10B                           4                  7C                          3                   3 I want this to show up on web page. I was hoping to do this through the source code on the web page, but I am struggling to do it.Is there a better way to do this, or a place where I can see an example of the code. Many Thanks, Oliver 

View 1 Replies View Related

Ok I'm Making A Webpage But

Dec 7, 2003

with SQL desktop engine installed where do I even begin working with it?

View 1 Replies View Related

Help Making A Selection

Feb 25, 2005

I hope I can explain this somewhat coherantly. Here goes..

I have a products database. I want to select product details for items having distinct style codes. IE if there are 20 products that different from one another in some way, and 3 different style numbers throughout them, I want to end up with 3 products selected. I don't care which ones, as long as i have a sample product for each style.
I've attemped to use GROUP BY to do this, but it's not giving me what I want. I managed to get right number of products, but the query seems to have mixed and matched the fields together in an undesireable way. I guess this kinda makes sense, since providing aggregate functions for each of the extra fields is necessary.
SO THE QUESTION IS: How do I select (number of distinct styles) products, and still keep the records in tact as they should be?

Here is a sample...


Code:

SELECT DISTINCT Min(team) as team, min(pict) as pict, min(colors) as colors, min(league) as league, min(product_description) as product_description, min(category) as category, min(subcategory) as subcategory, min(style) as style
FROM prods
WHERE (style='style1' or style='style2' or style='style3')
AND league='leaguex'
AND soldout=''
GROUP by style
ORDER by style




Thanks very much for any help!! I'm sure I'm going about this all wrong.

View 2 Replies View Related

Making Changes To A DB With Replication

Jun 2, 2006

Hi,

What is the best method/model for having real time replication set up and also needing the ability to drop and recreate SP's/Tables/UDF's etc? I keep getting the error of the SP is being used in replication so it cannot be dropped...

Thanks in advance.
Adam

View 1 Replies View Related

Making JOINS

Oct 20, 2006

Hi alllI have these tables below with 3 fields each. I want to get the recordin table 1 whose field number value is same in table 2 but field number2 on both tables are different. I mean i want the record1500 800 2. Insight: Table 1 is modules ordered and table 2 is modulesdelivered. I want to get 1500 800 2.beacuse module 800 was ordered butin table 2 module 503 was delivered. can some one help me with a joinnice weekeendTable 110 5012 101600502100 502 31500800 2Table 21500503 114004000100502 10100600100502 3

View 3 Replies View Related

Needs Help In Making Database

Jul 20, 2005

Please see the detail of tables with fields in SQL server 2000.·TableStudent .Table Good Qualities( It is a list of Students) (It is a list of Good Qualities)1-Student Id (P.Key)1- Serial No. (P. Key)2-Student Name 2- Good Quality· Table Bad Qualities .Table Future Plans(It is a list of Bad Qualities) (It is a list of Plans)1-Serial No. (P. Key) 1- Serial No. (P. Key)2-Bad Quality 2- Future Plans·Table-Personality1-Student Name/ID2-Good Qualities3-Bad Qualities4-Future PlansData will store in Personality table like thatStudent IDG.Q.No B.Q.NoF.P.No101 3 2 1101 4 5 NUll101 8 Null Null202 4 8 9202Null 3 1Required ResultNow I have to generate a report of One student andsometimes of many students comprising of their Name, G.qualities, BadQualities and Future Plan. To generate report User input will be onlystudent id.I Need help in making relationship of these tables as well as inMaking a Query. Any suggestion to get the required result. Speciallyplease look at the Personality Table because I do not understandPrimary key for it. Should I just include the Serial No. as Primarykey.Please make necessary changes to get the required result.I shall be really thankful to you for your kind favor.

View 3 Replies View Related

Making Subtotals

Jun 18, 2007

Hello Everyone,



I have a dimension that has the following members:

Directors

Senior Managers

Managers

Senior Associates

Associates



But they way they need to be displayed includes subtotals. Senior Managers and Managers are placed into Management and Staff is a total of everyone except Directors. They should appear on the report in something like this:



Directors 10

Senior Managers 15

Managers 9

Management 24

Senior Associates 17

Associates 40

Staff 81

Total 91





What is the best way to do this? Right now I am using a matrix because I am also showing headcounts by Period. Is a table a better way to go? Is it something that should be done in my dimension?



I can do the Total part. I am just not sure how to make the subtotals inbetween the other lines.



Thank you for the help.



-Gumbatman

View 3 Replies View Related

Making A Report

Feb 10, 2006

how can i create a report for my database? how can i create bar graphs, etc.? im using msde and sql express. pls help. thanks.

View 3 Replies View Related

Making Schema Changes

May 9, 2007

I have been reading up on how replicating schema changes work, but I must be missing something. When I configured a database for replication, it added a rowguid column to each table. This I understand.



I want to test making a schema change and replicating that change. For example, I tried to add a column to an existing table. When I tried to save the table i get the following error:



"Error validating the default for column rowguid".

"- Unable to modify table.
It is invalid to drop the default constraint on the rowguid column that is used by merge replication.
The DDL operation failed inside merge DDL replication manipulation.
The transaction ended in the trigger. The batch has been aborted."



So, what am I missing? Do i need to drop the rowguid column, add the new column, and then re-add the rowguid column?



Many thanks...



View 6 Replies View Related

Making Use Of The ScriptTask

Oct 2, 2007

Hi,

I have the following flow in which i am looping through a folder containing textfiles

Foreach loop
[
ScriptTask -> DataFlowTask -> Execute SQL
]

In my ScriptTask, i am checking the file validity. Now if the file is found incorrect, I do not want the DataFlowTask and other to execute. Instead i want the file to be moved to Error and the loop to proceed with the next file. If the file validity is correct, DFT and ExecuteSQL execute. How do i do this?

Some explanation supported by examples would help.

Lalit

View 1 Replies View Related

Error While Making Connection

Jul 9, 2006

hi
I am not able to create connection string through vwd express for sql express database file n getting a error:
An error has occurred while establishing a connection to the server.  When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
plz tell me where is the problem n how can i resolve it
Thanks n with regardsCN

View 1 Replies View Related

Making 2 Columns Unique With Each Other

Feb 21, 2008

Hi Guys, I came here again to ask something about my application, Is there a way to make 2 columns unique with each other even if they don't have a primary key? If there's a way how? I wanna make a rule so, my application wont replicate its record.   Graciaz,Nhoyti 

View 3 Replies View Related

Making Random Names!!!

Aug 19, 2005

Hi

I have no idea but want to learn it how to make random names with sql server...
I have a table, called table1, for colums Firstname and Last name
I want it to make random names, so much it is possible it can get, in table2 where the colums is named Names

PLEASE HELP :)

View 2 Replies View Related

Making A SQL Update Query Run Once

Aug 22, 2005

I have a datagrid in my file along with an Update Query.

My Update Query basically adds the numerical values in two columns
together when the page is loaded. This means whenever the page is
Refreshed the Update query is fired.

This is my Update Query (which is in an Stored Procedure):

UPDATE Rental
SET TotalFee = ExtraFee + TotalFee
WHERE DaysOverdue >= 0

I have declared my query in the 'Page_Load' part of the coding, because
I want the query to run automatically. Not manually by a button.

My main question is that how can I get the query to run only once a day, no matter how many times the page is loaded.

View 7 Replies View Related

DTS Decision Making & Email

Nov 13, 2001

Playing with DTS for converting text data to SQL Server table and sending email messages. Package is to be scheduled hourly.

1. Is there any easy way to force DTS to choose Success or Failure based on a SQL Task? Wish to check contents of a table for new values and branch accordingly in DTS.

2. When new records are brought in I wish to build a custom email message rather than attaching a text file. Any Idea how to build a custom message?


I am attempting to auto scan an error log on a Unix based system and email myself when errors occur. This is an exercise to test scheduling of jobs, bridging between technologies and sending out meaningful messages based on the process via email.

Thanks,

Mike Hoyt

View 1 Replies View Related

Making Rows A Column

Jul 26, 2002

Can anyone help me retrieving that result.

take an example
EXEC-ID JOB-CODE
0001 20
0001 63
0001 03

i want result in the following format:

EXEC-ID JOB-CODE1 JOB-CODE2 JOB-CODE3
0001 20 63 03

View 1 Replies View Related

Making Fields Equal Each Other...

Jun 28, 2005

Sorry if this is a total n00bie question but...


I have table A and table B

I want a field in table B to be equl to the primary key in table A, and i'm not sure how to do that.

Thanks

View 1 Replies View Related

Making Database Empty

Oct 12, 2005

Hello Experts,
Can anyone tell me, how can I make SQL server database empty.I mean i need to keep only restore the table structur, no table data.

View 1 Replies View Related

Making A Row Delete Itself At A Certain Time?

Dec 2, 2006

Is there any possible way to make a row delete itself at a certain date and time? I am tring to make an "On_Sale" table and perticular items(rows) must expire at a certain Date and time. I have an idea to delete a row when it expires but it will cause an extra burden on my application. So is it possible to have SQL responsible for deleting a row at a certain time and date?

Also, I have another question:
when I asign a PK Identity to a certain column is there a way I can enforce consecutive order of PK values? For example if I delete a row and the PK value was 5 it will reoder the whole table so all PK values are in consecutive order:


PK-----------Item----------price
1------------XYZ1----------$$$$
2------------XYZ2----------$$$$
3------------XYZ3----------$$$$

when I delete PK 2 this is what happens

PK-----------Item----------price
1------------XYZ1----------$$$$
3------------XYZ3----------$$$$

the PKs are not in consecutive order


What I want is this to happen: when PK 2 is deleted I need it to show as follows

PK-----------Item----------price
1------------XYZ1----------$$$$
2------------XYZ3----------$$$$

The PKs stay in consecutive order.



See how the PK are still in consecutive order?

View 2 Replies View Related

Making A Statistics Table....

Jan 31, 2007

hi. i'm trying to make a report in asp that sums up a whole bunch of statistics. the report is quite lengthy and takes about 2 minutes to load. i thought i would solve that problem by making a table to dump the statistics into instead of calculating the statistics every time the report is viewed. this way, the page would just read the table with the statistics already put in it. these statistics would be updated every day or two so i don't need anything up to the minute.however, i have run into a small problem which is actually updating the information in the table. my new table is called OfficeReport and it looks like this:UserID Stat1 Stat2 Stat3 ...... Stat3223 0 0 0 056 0 0 0 072 0 0 0 0this is a query for one of the statistics i am currently using:SELECT DefendantCase.UserID, COUNT(DefendantCase.UserID) AS CountOfUserID FROM DefendantCase LEFT JOIN UserDescription ON DefendantCase.UserID=UserDescription.UserID WHERE UserDescription.Status=1 AND UserDescription.UserType=1GROUP BY DefendantCase.UserIDif i run this query, this is what i get:UserID CountOfUserID54 2160 1052 294 427 22how can i modify this query so its output updates the same UserID column in the OfficeReport table? Thanks!

View 3 Replies View Related

Making DATEDIFF Flexible

Feb 26, 2007

I have the following SQL statement that works out how many days are between todays date and the first of April 2007.

SELECTDATEDIFF(dd,'2007-04-01 00:00:00.000',GetDate()) AS 'Days Left'

This works fine, however: After the 1st April 2007 I want to start counting down the days till 1st April 2008 - and so on and so forth.

How can I do this? Hopefully you understand my question - if not, ask me any questions needed!

Cheers - GeorgeV

View 14 Replies View Related

Making A String Shorter

Mar 9, 2012

I have a table to which data is being imported via bcp. When I get this data there are some fields nvarchar that has some decimal, for instance 1098.000000 is always 6 zeros..What I want to achieve is to make the above number only 1098

So what I did was this:
LEFT (AMOUNT, LEN(AMOUNT)-7) AS AMOUNT

But i get an error saying invalid lenght parameter passed to the left or substring

View 2 Replies View Related

Making A Single File

Feb 5, 2004

i m having 2 Database files for the same DB and 2 Logfiles ,i want it to make a single file..... is it possible with DTS or any other thing.....

View 1 Replies View Related

Making A Table From A Query

Feb 10, 2004

I have a Query named qryQuery1 from which I would like to make a Table named tblTable1. I need to do this within a VBA Microsoft Access module.

Can anyone help me with the proper code?

Thank you for any help.

Jim

View 14 Replies View Related

Case Not Making The Select?

Aug 2, 2013

The following code is a front end parameter - Quantity but when the user enters '0' it is not returning any rows (there are). Is there something wrong here or to add something?

(Select {?Quantity}
CASE "ALL":
1=1
CASE "Negative":
({ACBALMPK.IRQOH#}<0) OR ({ACBALMPK.IEQOH#}<0)
CASE "Zero":
({ACBALMPK.IRQOH#}=0) OR ({ACBALMPK.IEQOH#}=0)
CASE "Greater than Zero":
({ACBALMPK.IRQOH#}>0;) OR ({ACBALMPK.IEQOH#}>0;))

View 4 Replies View Related

Making A Copy Of A Database

Dec 9, 2005

I want to make a copy of our production database so I can do some testing stuff on it...

I basically want to just save the complete database with a name like testingXYZ.

Can I just do that through the normal file explore manager or is there some SQL Things I need to do?

View 3 Replies View Related







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