Retrieve Even If No Hits?

Apr 29, 2005

Hello!

is it possible to have the count(*) to display 0 when there is no matching hits for that n_id?

my query looks like this but only displays the n_id and it's respective count(*) when count(*) is more than 0...

select n_id, count(*) from tblTable
where nSomething > nSomethingElse AND nSomething IS NOT NULL
group by n_id

any idaes?

View 1 Replies


ADVERTISEMENT

When DTS Hits A Bad Date

Aug 24, 2006

This routine works in most cases, but fails when a bad date is enteredsuch as:19910631 -- there is no June 31st.Instead of ignoring the bad date the entire DTS job fails. Obviouslythis is something that should be validated at data entry, butunfortunately the only control I have is when appending to the tablewith these data quirks. Any suggestions appreciated!!!'************************************************* *********************' Visual Basic Transformation Script' Copy each source column to the' destination column'************************************************* ***********************Function Main()'DTSDestination("Col002") = DTSSource("Col002")if DTSSource("Col002") = "99999999" or DTSSource("Col002") =Null thenMain = DTSTransforStat_SkipRowelseDTSDestination("Col002") = mid(DTSSource("Col002"),1,4) & "/"&mid(DTSSource("Col002"),5,2) & "/" & mid(DTSSource("Col002"),7,2)End ifMain = DTSTransformStat_OKEnd FunctionRBollinger

View 3 Replies View Related

Updating Hits Without Looping

Sep 6, 2007

Hi.
This is my first attempt at a using stored procedures and I'm a bit confused.
I'm trying to follow as many best practices as I can to improve speed, security and scalability. However, I can't find a solution to what I think should be a simple problem.
I have a search page where users enter the criteria of properties they are interested in (bedrooms, price etc...). That takes them to a results page where the properties are displayed.
The problem is that I want the amount of times each property has been shown on the results page to be tracked so the property owner gets statistics.
The property details are all held in a single table along with the amount of times each property has be shown:
Table Name:   zk_Property_USA




ID
INT


User_ID
INT


Property_Type
TINYINT


Market_Status
TINYINT


Price
INT


Bedrooms
TINYINT


Address_State
VARCHAR


Address_Location
VARCHAR


Property_Description
VARCHAR


Searched
INT
0

Contacted
INT
0
I'm trying to find a way to SELECT all the property details to be returned to my results page and UPDATE the "Searched" field by 1 without re-scanning the table for the UPDATE.
Is there a way to update "Searched" at the time when the record is chosen to be a result? I am using SQL Server 2005 and Visual Basic ASP.NET 2.0.
Many Thanks

View 4 Replies View Related

Monitoring Database Hits

Nov 8, 2007

In any asp.net application, whats the simplest way to monitor how many times a page hits the database (opens and closes a connection)? 

View 1 Replies View Related

Lookup With Multiple Hits

Sep 27, 2007

In a Lookup component I've defined a SQL query which returns a sorted resultset. For each Lookup component input row I want to have a single output row. Problem is that for each input row there is possibility of multiple matches in SQL query resultset. From all of the possible multiple hits I want only the first one to be returned, and if no match is found then no output row. How to implement this?

View 10 Replies View Related

Hits Table And Counter Reports

Jan 22, 2008

Using MSSQL (pre 2005):
I have a Link table:
int id (primary key/identity)
varchar(50) linkName
varchar(255) linkHref
//some other stuff
and my Hits table:
int id (primary key/identity)
int linkId (foreign key to Link)
datetime dateCreated
//some other stuff
Hits gets an insert whenever a link is clicked.  (All this works just fine)
I'm trying to create a report that shows each link by its name and href, a counter and the last date each link was visited.  What I currently have is an accurate listing for those that have been clicked on, but it does not show anything for links that haven't been clicked on.  Any suggestions as to how I can modify the following SQL to return "0" and "never" (or DBNULL) if no entries are found in Hits that have the same id?  Or do I have to do this in a couple queries?
SELECT COUNT(h.id) as counter, MAX(h.dateCreated) as lastVisited,
l.id as id, l.linkName as linkName, l.linkHref as linkHref
FROM Link as l INNER JOIN Hits as h ON l.id=h.moduleId
GROUP BY l.linkName, l.id, l.linkHref
 

View 6 Replies View Related

Getting Estimated Total Hits Of Fulltextsearch

Apr 20, 2006

Hello,
i am making a Fulltextsearch on MS SQL Server 2005 (indexed, with "Contains").
Because of performance reasons i am only showing the first 200 rows mssql finds ("select top 200...:").
Is there any possibility to get the estimated totalnumber of all rows? i have heard something that is possible to get this in mssql-server. The server then estimates how many rows with that searchword could be in the whole database. google i.e. makes the same thing....
is that true? what do i have to do to get this?
greetings and thx
cpt.oneeye
 

View 1 Replies View Related

Capturing Client Logins And Hits

Apr 1, 2002

I'd like to capture the avg. # of user logins and # db hits per a 5 interval for a weeks time. I'm guessing there are sys tables containing this info. and by using temporary tables and/or creating/modifying SPROCS this info. can be retrieved. If I'm on the right track, a little direction would be very appreciated. If I'm not on track, please assist this rookie dba.

Thank you,
Eoin

View 2 Replies View Related

Tracking/Reporting Record Hits.

Feb 7, 2008

I am serving ad-units. In each ad-unit I show somewhere between 3 and 10 article headline. I track the headline impressions to get an idea of the headline click through rate. I save the output from the stats process in another table. I am currently evaluating the stats every hour, and then truncating the table every night at midnight. The problem is that I get lots of impressions and the database gets bogged down evaluating the data such as...
SELECT COUNT FROM articleimpressions WHERE articleid = x

But the issue isn't the reporting of the data...so much as it's the capture. I had to add caching on the ad-server because the database couldn't handle the number of inserts.

I thought about parsing the web server log files the next day, but the file sizes seem to be too large, and I can't process them all in one day. (At least not on the hardware that I am using.)

I've thought about splitting log files by hour, but was wondering if there may be a more "native" solution within SQL Server? Maybe a trigger, and/or multi-threaded SP that fires and forgets an insert statement to a linked server. But performance is the key here.

Thoughts?

View 2 Replies View Related

Sort Results By Number Of Hits

Jul 23, 2005

In MSSQL, is there a way to count the number of instances of asubstring within a string, so that I can sort by that?For example:table tst contains one column: tst_dataif tst_data = "the man with the plan"I'd want a function that counts the occurances of "the"count_substring(tst_data,'the') = 2Basically, I'm making a search engine and I'd like to put the mostrelavent hits at the top of the page.

View 2 Replies View Related

Need Clever Way To Count Outside Hits In Sql Table

Dec 19, 2007

hi . would greatly appreciate a clever way to make an internal "counter" on an sql table that contains 6000 articles.(one in each row). these are being accessed from a web page and i would like to know which are the most read ones. so i thought of adding a column that would in some way count each time that the row is being accessed. is there a way for this to be done?? please be detailed since i am quite new to all this.
thanks beforehands.

View 3 Replies View Related

How To Handle Users Hits To Single Table

Feb 4, 2008

Hello friends

I am new to SQL database design.I am having a table name customerletter_master in which all details of customer letters are saved.At a time i.e in single second around 200- 400 entry are made in customerletter_master table. Hits to customerletter_master table are more.

Following fields are used in customerletter_master – CID (autogen number), letterno(primary key),consignee, consignor, letterstatus1, letterstatus2, letterstatus3, POD, and some more fields. When letter passes to different stages letterstatus1 is filled to yes and then letterstatus2 and letterstatus3 are filled according to passage of letter.

And at same time many user can accesses the customerletter_master table to search any letter according to letterno. Therefore customerletter_master is used to enter data and to search data at same time and there can be more than 200-400 users doing add and search records to and from customerletter_master

how should i design this table. What should i use to enter and search record and minimize the table hits made by the user at same time. Should i use store procedures or any other method to add and search record. Plz help me out by giving some example.

View 1 Replies View Related

Transact SQL :: Query To Get Web Page Hits On Website

Sep 24, 2015

I'm trying to piece together some code on how to find members of our organization who have visited our website.

View 2 Replies View Related

Multiple Database Hits Vs Bulk Data Parameters

Apr 11, 2006

I was curious to know if it the amount of data sent to the sql server mattered.

I am working on a web application and I have three stored procedures that most likely will be called one after the other. Each procedure accepts at least 4 parameters. Instead if I create one stored procedure, then I will be passing at least 12 parameters. Some of the parameters could be quite bulky(at least 1000 characters).

So which one is better, 1 stored procedure with 12 parameters or 3 stored procedures with 4 parameters each called one after the other.

Thanks

View 1 Replies View Related

Nested CASE WHEN - Create A Field To Show If Measure Hits Threshold Or Not To Be Later Picked Up In SSRS

Oct 28, 2015

I am trying to script a case when to achieve the following.

I have a table of measures with certain threshold. The threshold direction can either be > or < so I want to create a field that shows if the measure hits that threshold or not to be later picked up in SSRS. So a nested case when?

CASE WHEN M.[Threshold Direction] = '>' THEN
CASE WHEN A.[Value] > M.[Threshold] THEN 'GREEN'
CASE WHEN A.[Value] < M.[Threshold] THEN 'RED'
ELSE ''
END END END AS 'Condition'Is this at all possible?

View 2 Replies View Related

Retrieve AM Or PM

Aug 10, 2006

HI Chaps

very simple question this time

Is there any method availabe to retrieve AM or PM value from date, IN TSQL

hoping will get answer shortly

regards,

Anas

View 7 Replies View Related

RETRIEVE VALUE AFTER ADD FROM SQLDATASOURCE

Jun 29, 2007

I am using an SQLDataSource to add a product, this works fine, but I would like to know what syntax is used to retrieve the product ID in this case which is return by the SPROC
 
Thanks
 
Steve

View 1 Replies View Related

Retrieve Data

Jan 18, 2008

I need to retrieve points column from my database for the specific user that is signed on and sum all of them. How can I do it using the Gridview and also code in vb for a label? Thanks.  

View 4 Replies View Related

Retrieve Bit Type Value

May 7, 2004

I am trying to populate some controls on a web page with values retrieved from a sql server database recordset. The text type controls work fine. However I have a Check Box on my form. I get a runtime error when I try to write into it. So tried wrting the value into a text control and was suprised to see the value retrieved was "S00817". Heres the relevant line of code

Message.Innerhtml=MyDataset.tables(0).Rows(0)(12)

I would expect this to come up with a 1 or a 0. I get S00817 if the database record holds a 1 or a 0. So what is going on here?

View 2 Replies View Related

Retrieve A Particular Row From A Result Set

Aug 21, 2004

Hi all,

Is it possible to retrieve a particular row from a result set? For eg if my query returns 5 rows and i want to just retrieve the 3rd row from the result....is it possible? If yes...can someone tell me the syntax for it....would appreciate the gr8 help...

Thanks,
SQL Novice

View 1 Replies View Related

How Can I Retrieve Data?

Nov 19, 2005

Here is my sql procedure:
ALTER PROCEDURE dbo.SoftWareShow /* ( @parameter1 int = 5, @parameter2 datatype OUTPUT ) */ @SoftID uniqueidentifierAS SELECT [SoftID], [SoftName], [SoftJoinDate], [SoftSize], [SoftMode], [SoftRoof], [SoftHome], [SoftDemo], [SoftFirstClassID], [SoftSecondClassID], [SoftDesc], [SoftReadCount], [SoftDownCount],ltrim(rtrim([SoftUrlOne])) SoftUrlOne, ltrim(rtrim([SoftUrlTwo])) SoftUrlTwo, ltrim(rtrim([SoftUrlThree])) SoftUrlThree, ltrim(rtrim([SoftUrlFour])) SoftUrlFour FROM [SoftWare] WHERE ([SoftID] = @SoftID) RETURNwhere I retrieve data using sqldatasource, an error appear. how can do ?

View 1 Replies View Related

Best Way To Retrieve One Row For Use In Code

Mar 14, 2006

i have a SQL backend and some of the data in my tables is more or less configuration data and some times i only want to pull one row of data which i can do just fine with a SQL query but whats the best method to pull it. 
assume i have a query like this.
Select A, B, C from Table1 where ID=xyz
whats the easiest way to get A, B and C in to string variables?
I know i can use the sqldatasource control but i just feel there is too much overhead there.
whats your suggestions?
Thanks
Justin

View 1 Replies View Related

How To I Retrieve The First Value From A Table In T-SQL?

May 21, 2006

I want to do something similar to ExecuteScalar in ADO.net but instead in T-SQL.Basically I want to do a query that will return the first value in the table queried and put it into a variable.  How do I do this?Thanks in advance.

View 3 Replies View Related

How Can I Retrieve Nth Record Only?

Jul 6, 2001

Could you help me out?

I am interested in retrieving certain record among outputs.

For example, if I use the following sql,

select * from info order by name asc
====================================

then I can retrieve 25 rows from info table.

What I want to do is that I want to retrieve 15th record only among possible 25 records.

How can I solve this problem?

Thanks in advance.

View 2 Replies View Related

Retrieve Second Max Value In A Sql Table

Feb 25, 2004

Hi all,
I want to retrieve the second maximum value of a column data present in SQL table.Please help....

A
----
10
25
23
15


here I want 23 as the result.

View 5 Replies View Related

Retrieve Insertiondate

Nov 23, 2004

Hi folks,

Does anyone know how to retrieve the date when data has been inserted

thnx in advance

View 4 Replies View Related

Retrieve Only 1 Row For Each ID (was Help On SQL! Urgent..)

Feb 3, 2005

i have a table called tblpictures which look something like this..

filename|ID
----------
1 |p1
2 |p1
3 |p2
4 |p2
5 |p3

is there a way to retrieve only 1 row for each ID? how will the select statement looks like?? please help me..

View 3 Replies View Related

Retrieve Using Bcp-urgent

Feb 25, 2005

hi gurus,
how to get " using bcp
e.g
select '"'+name+'"' from sysobjects
results
"name"
"name1"

I want to get the same using bcp ,so that i can populate into a file
something like

set @cmd='BCP "select '"' +name +'"' ,uid from sysobjects" QUERYOUT "' + 'vrs.txt' + '" -w -T -S -t , '
-- Executing the BCP Command
EXEC MASTER..XP_CMDSHELL @Cmd

View 3 Replies View Related

How To Retrieve One Record

May 23, 2006

I have a question, one user made mistake that she delete one record from a database. How can i retrieve this only one record. I just know how to restore the database.

Thanks.

View 3 Replies View Related

How To Retrieve Timestamp

Apr 28, 2004

Can any one please tell me how to retrieve values from timestamp column.
I am getting 1900-01-01 00:02:09.457. It is not storing current timestamp when record is created or modified.

Is there anything I need to set it up.

thanks

View 3 Replies View Related

ADO Doesn't Retrieve Value From This Sp..why?

May 12, 2004

Hi, all.
I tried to get result of sp.
Dim rst As Recordset
Set rst = New ADODB.Recordset
rst.Open sp, cnn

doesn't get result.
when i call rst.EOF, it thows error: Can do this since rst is closed...

I found it's problem of sp which is little complex.
But, still I think it should work!
My question is how can I get the returned value from following sp in VB?


--- return list of tables that needed to update
--- list is one string separated by '&' delimeter
--- @listOfUpdateTime: [TableName=UpdateTime]&[...] eg) tblDeptList=12/25/2004&tblHoliday=12/24/2004&...
CREATE procedure spGetListOfTableToDownLoad
@listOfUpdateTime varchar(500)
as
SET NOCOUNT ON
Declare @listOfTable varchar(300), @item varchar(300)
Declare @tbl varchar(50), @uptime datetime
Declare @list varchar(500)
Declare @sep varchar(1)
SET @list = ''
SET @sep = '&'
DECLARE cur CURSOR FAST_FORWARD FOR
SELECT * FROM fnSplit(@listOfUpdateTime, @sep)

OPEN cur

FETCH NEXT
FROM cur
INTO @item

Declare @re bit, @tp varchar(50)
WHILE @@FETCH_STATUS = 0
BEGIN

-- get tablename, update time
Declare cur2 CURSOR FAST_FORWARD FOR
SELECT * FROM fnSplit(@item, '=')
OPEN cur2
FETCH NEXT FROM cur2 INTO @tbl
Print @tbl
FETCH NEXT FROM cur2 INTO @tp
print 'tp:' + @tp
SET @uptime = CAST(@tp as datetime)
print @uptime
-- @re =1: true, 0: false
EXEC spIsUpdate @tbl, @uptime, @re output
IF @re = 1
SET @list = @list + @tbl + @sep
CLOSE cur2
DEALLOCATE cur2

FETCH NEXT
FROM cur
INTO @item
END
if LEN(@list) > 0
SET @list = LEFT(@list, Len(@list)-Len(@sep))
CLOSE cur
DEALLOCATE cur

SELECT @list as Result

SET NOCOUNT OFF


GO
__________________
--- PARAM:: @tbl: table name,
--- @uptime : update time (passed from local db) that will be compared on HQ table
--- return 1 if Max(UpdateTime) of @table > @uptime
--- otherwise return 0
CREATE Procedure spIsUpdate
@tbl varchar(50), @uptime datetime, @result bit output
as
BEGIN
Declare @bit bit

DECLARE @SQLString NVARCHAR(500)
DECLARE @ParmDefinition NVARCHAR(500)
declare @uptimeHQ datetime
/* Build the SQL string once.*/
SET @SQLString = N'SELECT @tp = MAX(UpdateTime) FROM ' + @tbl
SET @ParmDefinition = N'@tp datetime OUTPUT'
EXECUTE sp_executesql @SQLString, @ParmDefinition
,@uptimeHQ OUTPUT

If @uptimeHQ > @uptime
SET @result = 1
ELSE
SET @result = 0
--RETURN @bit
END


GO

View 5 Replies View Related

Retrieve Value From A Table With The Value From So

Apr 11, 2008

I am trying t get output for the following querry but I know am missing something. Can anyone help me out with it.


select distinct productnum, (SELECT SUM(quantity) FROM orderlineitem w WHERE w.productnum = e.productnum) as Quantity
from orderlineitem e where parentOrderlineitemid is null order by Quantity desc)

In the above query am getting the productnum and quanity and it looks like this

productnum quantity
abc 6
ttt 3
sss 1

What am tring to do to this query is that . From another table 'product' i want all the data to be retrieved with this productnum(the table 'product' has a column called prductnum). I don't know how to write a query for this.

my query is
select * from product where productnum in (
select distinct productnum, (SELECT SUM(quantity) FROM orderlineitem w WHERE w.productnum = e.productnum) as Quantity
from orderlineitem e where parentOrderlineitemid is null order by Quantity desc)

Thanks.

View 2 Replies View Related

Retrieve Records

Jun 5, 2008

Hi all

I've two tables
community, community_related.

I need to get community names for comm_relatedID from community table
where comm_id = 21 , please see my tables below

Community table Community Related
commID, comm_name comm_id comm_relatedID
21 test1 21 24
22 test2 21 22
23 test3 21 26
24 test 5 21 27
26 test6
27 test7

result am trying to display from community related table after joining community table on COMM_ID = 21 is

comm_id comm_relatedID comm_name
21 24 test5
21 22 test2
21 26 test6
21 27 test7

can anybody please help..with a query, am stuck at this point.

View 1 Replies View Related







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