General SQL - Need Same Inner Select In FROM And WHERE Sections...

Feb 29, 2008

Hi, I've got the query below which works as needed, but it performs the same inner select twice at present. What is the best way of eliminating the second evaluation of the inner select statement?

SELECT TOP 1 condition FROM

  (SELECT condition, COUNT(condition) AS total FROM [JCM].[dbo].[jcmresults] GROUP BY condition)

WHERE total = (SELECT MIN(total) FROM

  (SELECT condition, COUNT(condition) AS total FROM [JCM].[dbo].[jcmresults] GROUP BY condition))

 

Thanks,

Andrew

View 5 Replies


ADVERTISEMENT

Does Computed Column Update On Select General Question

Sep 22, 2006

Okay, newb question alert!!!I created a computer column that is based on the difference between the column start_date and getdate().Does the computed column only update when you update the column or does it change when you select it also? 

View 1 Replies View Related

General Stored Procedure, For Insert, Update, Select, Delete?

May 7, 2007

Hi All,
As known its recommended to use stored procedures when executing on database for perfermance issue. I am thinking to create 4 stored procedures on my database (spSelectQuery, spInsertQuery, spUpdateQuery, spDeleteQuery)
that accept any query and execute it and return the result, rather than having a number of stored procedures for all tables? create PROCEDURE spSelectQuery
(
@select_query nvarchar(500)
)
as
begin

exec sp_executesql @select_query, N'@col_val varchar(50) out', @col_val out


end
 
Is this a good approach design, or its bad???
 
Thanks all

View 5 Replies View Related

Underlay Following Sections

Mar 5, 2008

Hello there.

With my team we have to convert all our CrystalReports-Reports to ReportingServices-Reports.
Now i have a problem with on functionality in CR.

I just have a table. One group, two columns. like this:


Column1 Column2
-----------------------------------------------------------
GroupTextBox1 empty
-----------------------------------------------------------
empty DetailTextBox1
-----------------------------------------------------------

Now i want to underlay the following DetailRows to the Group.
There can be many DetailRows and the GroupTextBox1 is bigger than one line.
If its possible i dont want to use subreports

Can somebody help me?

Thanks in advance, Tobi

View 1 Replies View Related

Cleaning Up Hardcode Sections

Jan 5, 2005

Hey,

Does anyone know of a neat and easy way to modify this section of hardcode:

SELECT CASE dbo.requestsbyyeartemp.themonth when '1' then 'January' when '2' then 'Febuary' when '3' then 'March'
when '4' then 'April' when '5' then 'May' when '6' then 'June' when '7' then 'July' when '8' then 'August'
when '9' then 'September' when '10' then 'October' when '11' then 'November' when '12' then 'December' end as 'themonth', etc...

Requestsbyyeartemp is a table where the numbers corresponding to the months are stored. This statement is used to make a new table where the months are stored with the proper names and not numbers.

I would sooner not have any hardcode at all if there is a simple way to do it.

Thanks

View 4 Replies View Related

SQL XML :: How To Parse Different Sections XML With OPENXML

Aug 26, 2015

I am learning how to parse XML data into SQL table.  Below partial XML data contains multiple sections.  I used OPENXML to parse one section but need to parse the remaining sections into a table.  For example, below openxml code can only retrieve elements under "NewHires/Newhire/EmployeeInfo/PersonName" section.  I also need to parse elements under "NewHires/Newhire/EmployeeInfo/ContactMethod" sections.  Notice that there are three subsections underneath the ContactMethod section ("/Telephone", "/InternatEmailAddress", and "/PostalAddress") sections.  Not to mention there are EmergencyContact section follow behind. 

OpenXML can only extract one section at a time.  Does it mean I have to write multiple OpenXML, store them into multiple temp tables then merge them into a single table?  If that is the case, how to save all these data into a single table? 

parse all the elements in lieu of OpenXML?

Here is the partial XML data:

<?xml version="1.0" encoding="UTF-8"?>

View 11 Replies View Related

Hiding Sections Of Text

Feb 15, 2008

I'm new at Reporting Services. I need to know if the Reporting Services will meet my needs.

I need to create a report that looks much like a Word document with large sections of text. Is it possible to hide some sections of text based on boolean fields in a SQL table/query?

Alternatively.. will it handle rich text? I could then select the appropreate section to display by query.


Thanks in advance

View 1 Replies View Related

Hiding/Collapsing Report Sections

May 16, 2007

I have lot of information to display on one report. I am trying to come up with a reasonable layout, that could include all the information on one page without over whelming the user. Essentially I would like to divide the report in three sections, ideally with a collapse/expand functionality. Is it possible with Reporting services. How?



- Section1 Heading....(Expanded/Visible)

<Table, text boxes, lists go here>

<data region>

<data region>

<...>

<...>



+ Section2 Heading (Collapsed/Hidden)

<Table and other data regions are hidden>



+ Section3 Heading (Collapsed/Hidden)

<Table and other data regions are hidden>



Any help will be appreciated.



Thanks.



DNG

View 3 Replies View Related

Multiple Sections In SQL Server Reports..

Nov 15, 2007

Hi,
Am using SQL Server Reporting service to generate reports.Actually i want is a reports containng two sections,How can i achieve that?
Cheers
Jan

View 7 Replies View Related

Creating Sections And Subsections In Report

Feb 26, 2008



Hi,
I am new to Microsoft SQL Server Reporting Services.
Please tell how to create sections and subsections in the report.
Pls provide if any document is there ..


Thanks
Rajiv Gupta

View 9 Replies View Related

Retrieving Random Sections From A Data File

Jun 2, 2007

On my company's website, we have a quote of the day. I would like to be able to type a hundred or so quotes into a mdf file. Then, I would like to have code that randomly selects one of the quotes every day and posts it.
 
....What I want is very similar to the "Image Of the Day" section on many websites.
 
Any ideas?

View 3 Replies View Related

General T-sql Help.

Oct 19, 2005

The following is my code.  What I am trying to do is find all the students a teacher as assessed during a give time.  Then find out which assessment was done the most recently.  After that I will then be aggregating those results.  I have never written any pl/sql or T-SQL... heck I don't even know what to call it!The first sql command is doing what I want it to.  I can only assume the cursor is working correctly.  Any help would be greatly appreciated.BryanALTER procedure Domain@UserID numeric,@StartDate datetime,@EndDate datetime
AS-- Variable DeclerationDECLARE @SessionID varchar(1000)DECLARE @EachSessionID numeric
--Cursor to find all Children that the teacher has assessed for the given timeDECLARE ChildID_cursor CURSORFORSELECT DISTINCT childID FROM capsessionWHERE userid = @UserIDAND sessiondate BETWEEN @StartDate AND @EndDate-- looping through all Children to find there most recent assessment.OPEN ChildID_cursorDECLARE @ChildID numeric FETCH NEXT FROM ChildID_cursor INTO @ChildIDWHILE (@@FETCH_STATUS <> -1)BEGIN IF (@@FETCH_STATUS <> -2) BEGIN  DECLARE SessionID_cursor CURSOR   FOR  SELECT  TOP 1   CAPSessionID  FROM         CapSession  WHERE     (ChildID = @ChildID) AND (SessionDate BETWEEN @StartDate AND @EndDate)  ORDER BY SessionDate DESC END FETCH NEXT FROM ChildID_cursor INTO @ChildIDENDCLOSE ChildID_cursor
OPEN SessionID_cursorFETCH NEXT FROM SessionID_cursor into @EachSessionID SET @SessionID = ''WHILE (@@FETCH_STATUS <> -1)BEGIN IF (@@FETCH_STATUS <> -2) BEGIN  SET @SessionID = @SessionID + @EachSessionID+ ',' END FETCH NEXT FROM ChildID_cursor INTO @ChildIDENDCLOSE SessionID_cursorRETURN @EachSessionID

View 3 Replies View Related

GENERAL QUERY

May 30, 2008

Hi, I wanna know if one has to undergo the 'sql video tutorials' on this website before trying to understand data access tutorials, again on this site.
Are the two related by any chance. Also I am not able to find the customer database files he has created in tutorial # 5, dumb to ask, but what to do?,...so anyone willing to shed light!!!

View 2 Replies View Related

General SQL Abilities...

Jan 12, 2003

Hello everyone,

as you might have seen, I'm a total newbie to this Site and M$ SQL.
I browsed the forum to see if there are already matching answers to my question, with no success.

My question:
As a MySQL & PHP user I ask myself if there is a possibility to use M$ SQL the way I use MySQL and PHP!?
Is there a way to generate dynamic websites with M$ SQL 2000 and a webserver running PHP sources?
A brief yes or no would really help me, if you have any links or resources on this topic, I'd be glad to hear about it.

Thanks
Tom

View 2 Replies View Related

&#34;General SQL Error&#34;

Mar 1, 1999

I get the error "General SQL Error" when reading or writing to a memo field in Sql Server through a frontend build in Delphi 4.
I'm Using the latest BDE.
I have recently installed this onto a NT enviroment in the same manner as my own enviroment but get the error message above.

On my own enviroment and a friends enviroment I do not get any errors.

Can someone please give me some help on this or a direction to run in ?

Thanks

Dave.

View 1 Replies View Related

General SQL Questions

Apr 3, 2008

1. What is the SQL error you receive when you try to fetch data from a cursor after it has run out of data?

2. After a SQL statement is executed, what does a negative value in the SQLCODE variable indicate?

View 7 Replies View Related

General Recommendation

Sep 26, 2004

Hi, folks. I've a production SQL machine with more than 20 users making transactions 24 hrs in 6 days a week. I've only Sunday for maintenance. The server has fixed 2 GB RAM allocation for SQL. Is it good to Restart SQL ( or machine) to clear the Buffer-Cache( or is it good to keep the cache) .... :rolleyes:


Howdy!

View 3 Replies View Related

General DB Help Needed

Mar 16, 2006

:eek: I am not going to lie, I am taking a DB course and am finding it extremely difficult to understand. :o

We are doing Relational DB & ER modeling as well as table normalization.

I only have 1 hour to take an upcoming and know I will score poor on my own.

Anyone want to help me out with my quiz?

I can post the Q's here.

Thanks much

View 14 Replies View Related

General DB Query

May 3, 2004

Hi! How do you query an entire db for a value?

I know how to do table queries from the SQL Analyzer, but not a full DB search.

Like, if I wanted to find a value '137.51 in a DB, what would I use?

Many thanks!

JJ

View 1 Replies View Related

Best General SQL Forum

Apr 28, 2008

I'm not impressed with the speed/quality of responses from this forum...

Can anybody recommend a more active forum?

View 20 Replies View Related

General Search

Oct 5, 2007

Hi,

is there a search function in MS SQL server 2005 to search for a name of a table or a name of field or entry in a field?

what/how should be the fastest way to do it?

thank you

View 4 Replies View Related

General Questions

Mar 11, 2008

Maximum Number of rows allowed in sql server 2005 tables ?
Maximum Number of columns allowed in sql server 2005 tables ?
What are all the built in string functions can be allowed for 'TEXT' DataType in sql server 2005?

View 1 Replies View Related

General Q About Formulae

Aug 3, 2005

Before I go into specifics, this is my problem. I've have a tablethat gets updated with large amounts of data on a monthly basis.Sometimes (rarely) identical rows of data are on one months import thatalready exist from the previous month. I can identify these rows from acombination of two fields (sampleID and testname).My question is this. Would it be an appropriate 'fix' if I created anew 'formula' field on the table comprising of a concatentation ofthese two fields and then made that an index field (no duplicates)? Myguess would be that if we then tried to import a record with a sampleIDand testname that already existed, then the import for that recordwould simply fail.Would this work? Is there a better way? My background is more withAccess so apologies if I'm not using the right terminology.Simon Harris

View 4 Replies View Related

General Question

Jul 26, 2007

hi...i would like to know best practice when assigning a value to a variableexample belowsetorselectdeclare @var1 varchar(25)set @var1='abc'select @var1='abc'to meset is implicitselect implies conditionsi see both used all over the place here at my new company....so witch is better practicetksMJ

View 6 Replies View Related

Which General SQL NG Is More Active??

Jul 27, 2007

Is comp.databases.ms-sqlserver more active thanmicrosoft.public.sqlserver.server, or is it the other way around??Which NG is better for general and 'learning SQL 2005' types ofquestions??Thank you, Tom

View 2 Replies View Related

General Questions

Jul 20, 2005

New to using databases that are NOT Access. New to MS SQL Server. I'dlike help understanding some concepts.Firstly, I'd like to know how to connect to a database using MS SQLServer on a remote web server using Windows XP; I know the IP and havethe username and password to connect...but what program do I use?Suggestions, appreciated.Secondly, I'd like to make changes to the remote database - anyonesuggest programs to use?Regards,OZ

View 1 Replies View Related

General Question

Mar 28, 2006

I have a general question about transactions and commands that are replicated in a Transactional replication.

My screen shot says:

A total of 5 transaction(s) with 85 command(s) were delivered.

I know what a transaction is, but what is a command?

I am assuming a transaction is

begintrans

committrans, correct?

View 4 Replies View Related

General Question

Sep 21, 2006

I am currently upgrading my companies database from 6.5 to 2000. Including the replication. I am curious about something. Currently we are using the commands in 6.5 to do the replication instead of stored procedures. (except for one table that requires custome filters). When I reestablished replication on 2000, the default is to create stored procs on the subscribers to hande the replication. (sp_MSins_tablename). My question whether anybody knows why it defaults to using sp's? Is there a reason or is that just the way it is. I want to know if using sp's is better than just sing the commands before I change my setup.



Thanks for any responses.

Johnny

View 3 Replies View Related

General Question About RS

Jul 16, 2007

Hello,



Can someone please answer the following questions:



1) Am I correct that SSRS 2005 can access a remote data source on SQL Server 2000? (this one I'm pretty sure about). I'm also trying to determine whether I can move up to SSRS 2008 when it is released and keep running all the same report types against SQL 2000.



2) Where is the bulk of the reporting services calculations performed (e.g. NOT the database query itself)? The Reporter Server? Or the Reporter Server Database?



3) Is it advisable to have the Report Server and Report Server Database on the same server? How do people typically handle this?



4) Is it advisable to have the Report Server and the Datasource database on the same server?



Thanks!



Michael

View 4 Replies View Related

General Question

Apr 19, 2007

I have a website. It is a SAS Site. It has a structure similar to

tbClient (ID, Username, password)

tbData (ID, ClientID, info)

tbDatax(ID, tbDataID, info)

tbDatay(ID, tbDataXID, info)





This is a reporting nightmare for me. I Ihave a sollution, but i was wondering if SRS has an out of the box sollution or if anyone knows of an out of the box sollution.



It is a reporting nightmare because clients want to be able to create reports out of the system, but I can't let them see other clients data.



My sollution is give them a username CLientA



They log into The database with CLientA login



I have views that mask the data by enforcing all of the relationships through the view.

create view vutbDatax as

Select tbDatax.*

from tbDataX

Inner Join tbData on tbData.ID = tbDataX.tbDataID

Inner Join tbClient on tbClient.ID = tbDataX.ClientID

where tbCLient.Username = User



User is a Database function that returns me the Username they logged into the database as.



Imagine doing that for 100 views. And managing the security on it. I have done it and it is in the process of testing right now but Does anyone have a better sollution.















View 1 Replies View Related

General Question About SQL Efficiency

Apr 14, 2008

I have a website that is probably going to hold a sizable amount of data.  The data will be specific to groups of users based on login credentials.  Would it be more efficient to create a whole new database for each group of users, or create new tables for the groups in the existing database? 
Any thoughts on the topic would be appreciated.
Thanks

View 3 Replies View Related

General Question On Triggers

Jun 16, 2008

If I have a foriegn Key stored in a primary table, are triggers used to automate routines in the foreign table when ever the foreign key is changed.
 Is there a forum reference with practicle examples of where to use triggers?
 

View 3 Replies View Related

General Network Error

Apr 20, 2005

Hello.
I'm running into a rather intermittent problem when a search query is run on an ASP.Net web application.
The error is 'General Network Error' Check your Network Documentation...
As I said, it doesn't happen everytime which leads me to beleive that there is a problem with the database connection
There's probably no more than 50-60 max users hitting the app at any one time.
Anybody familiar with this?

View 1 Replies View Related







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