Trying To Get Last Ten Clients

May 29, 2008

I'm trying to get the last ten unique clients viewed by each user. I have tried using the TOP (N) but it does not show the last ten just any ten.

When a user views a client record, a record is saved to the tblUserRecentViewedClients table and includes logID (key), client_id (int), username (nvarchar), lastviewed (datetime).

Here is what I have so far. Can anyone offer any suggestions?SELECT TOP (10) tblUserRecentViewedClients.UserName, tblUserRecentViewedClients.Client_ID, tblClient.FirstName, tblClient.LastName,
tblClient.CompanyName
FROM tblUserRecentViewedClients INNER JOIN
tblClient ON tblUserRecentViewedClients.client_ID = tblClient.client_ID
WHERE tblUserRecentViewedClients.UserName=@UserName
GROUP BY tblUserRecentViewedClients.UserName, tblUserRecentViewedClients.Client_ID, tblClient.FirstName, tblClient.LastName,
tblClient.CompanyName 

View 8 Replies


ADVERTISEMENT

Do You Need The Clients

Jan 15, 2004

If i use sql server as my backend and microsoft access as my frontend do i need to purchase client access lisences??

View 1 Replies View Related

Installing SQL 7.0 On Clients - Do I Need IE4?

Feb 15, 2000

I have to install SQL 7.0 Client software (query analyzer, client connectivity) on A LOT of workstations that only have Internet Explorer 3.0 ... Is there any way of getting around not upgrading to 4.0 sp1? If I try to just install 7.0 client, it errors out saying I need IE 4.0sp1. I really don't want to have upgrade IE!!!

Thanks in advance.
Laura

View 4 Replies View Related

Mail Clients

Sep 2, 2000

Is anyone using a mail client other than Outlook to work with SQL Server 7.0? If so, what are you using, and what is your opinion of it?

Doug

View 1 Replies View Related

6.5 - 7.0 Clients On Same Machine?

Nov 4, 1999

Are there any issues with retaining both the SQL 6.5 and SQL 7.0 clients as
installed components on our desktops? We have a number of SQL 6.5 and 7.0
Servers which have some fairly specific client side requirements and I am
trying to ascertain what the potential impact is to rolling out SQL 7.0
components to a separate directory to allow all applications to coexist. My
specific concerns are with the shared DLL's in system32 and with updated
7.0 executables that share the same name (i.e. BCP, etc) and resultant path
issues.

Any feedback or articles that cover this subject would be appreciated.

Thanks,
A

View 2 Replies View Related

Mdac 2.8 And Clients

Mar 11, 2004

We use mdac 2.7 on all servers and clients

We want to update servers to 2.8
Do we MUST update clints to 2.8 or they
can continue to run with 2.7


Thank you
Alex

View 1 Replies View Related

Clients In Different Domains

Oct 25, 2005

I have situation like this:

Company with one head office and one remote office. In the two offices I have two domains with two PDCs. The two networks are connected with eachother through leased line and the routers are configured properly. The SQL Server is on the PDC in head office and "local" clients connect fine. I cannot connect from the remote office. I think that I have folowing solutions:

1. make trust relationships between two domains - it will be hard a little bit because second PDC is samba on linux

2. make all clients in remote office to be members of the head office domain - potential problems if the leased line drops

3. make all clients to log in with same account as SQL Server logs locally - stupid

4. something else - what?

Thanks in advance!
Daniel

View 3 Replies View Related

Tool For Clients

Oct 24, 2005

Can anyone recommend a tool where I can email to someone both the SQLquery and the result set? Right now, I'm just copying the results to aspreadsheet. No, I can't use Reporting Services or Crystal Reports.

View 2 Replies View Related

Database For Multiple Clients

Jun 2, 2007

I have a SQL Server 2005 Express database that was designed to be used by one client. What is the best way to change the design so it can contain multiple clients that can only see data entered by users of each client organization?
Also I'm using the asp.net membership database to handle login and profiles. Can this be used with my multi client database?

View 3 Replies View Related

Help !! Lost Clients Sites

Sep 24, 2005

“HELP !! We’ve lost about 25 client’s websites. The databases were backed up along with all the actual files contained within each CSK….in addition, all the original databases are intact & can be reattached to the new SQL server…..the problem that exists where the original CSK files do not recognize the original database once it is reattached to the new SQL server. Any help would be most appreciated.
 This is the error……
 Login failed for user 'DARRYL1ASPNET'.
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.SqlClient.SqlException: Login failed for user 'DARRYL1ASPNET'.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:




 
[SqlException: Login failed for user 'DARRYL1ASPNET'.]
   System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction) +472
   System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) +372
   System.Data.SqlClient.SqlConnection.Open() +384
   System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState) +44
   System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +304
   System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +77
   System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +38
   ASPNET.StarterKit.Communities.CommunityUtility.GetAllCommunitiesFromDB() +93
   ASPNET.StarterKit.Communities.CommunityUtility.GetAllCommunities() +58
   ASPNET.StarterKit.Communities.CommunityUtility.GetCommunityInfo() +327
   ASPNET.StarterKit.Communities.CommunitiesModule.Application_BeginRequest(Object source, EventArgs e) +221
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute() +60
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +87

View 1 Replies View Related

Raiserror Messages Not Sent To Clients

Jul 20, 2002

We’re having trouble getting error messages to show up on clients. Our ADO research indicates that the Errors collections is populated, “automatically” – what you do with it is up to the application. Our collection is not being populated. MS says the SQLOLEDB provider has a problem (the collection is not filled) if SET NOCOUNT is OFF. We have SET NOCOUNT ON and still have the problem. We have narrowed the problem down (the example below is an abbreviated version) to “the Errors Collection is not populated if the Raiserror follows a SELECT statement that returns a recordset”.

In the code below the simple select run after the first RAISERROR appears to “block” the Error Collection. Is this by design? Are you never supposed to be able to return records and messages from the same program? We can code around it if we have to, but the documentation seems to indicate our approach is viable.

Any ideas would be most appreciated.

SQL Stored Procedure:

CREATE PROCEDURE Address_Ck
(
@Address_ID INTEGER OUTPUT
, @MailOnly_LG BIT
, @Ctry_ID SMALLINT
, @StPv_ID SMALLINT
, @PostCode_ID INT
, @PostCode_Ext_CH CHAR(10)
, @Add1_VC VARCHAR(60)
, @Add2_VC VARCHAR(60)
, @Add3_VC VARCHAR(60)
, @Add4_VC VARCHAR(60)
, @City_VC VARCHAR(30)
, @City_Lock_LG BIT
, @Directions_VC VARCHAR(2000)
)

AS

DECLARE
@Finder_VC VARCHAR(20)
, @Label1_VC VARCHAR(60)
, @Label2_VC VARCHAR(60)
, @Label3_VC VARCHAR(60)
, @Label4_VC VARCHAR(60)
, @Label5_VC VARCHAR(60)
, @Label6_VC VARCHAR(60)


-- the error in the next line shows up when not commented out
--RAISERROR ( ‘ This error always shows up.’ ,16,1)


SELECT Address_ID
, Label1_VC
, Label2_VC
, Label3_VC
, Label4_VC
, Label5_VC
, Label6_VC
FROM Address_T
WHERE Finder_VC= @Finder_VC


RAISERROR ( ‘ Why won’t this error showup?. ’ ,16,1)
-- the error above never shows up


************************************************** ****
************************************************** ****


THE VB CODE:

Option Explicit
Dim db As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim rs As New ADODB.Recordset

Private Sub Command1_Click()
On Error GoTo errmsg

Set rs = New ADODB.Recordset
Set cmd = New ADODB.Command

With db
.Provider = "SQLOLEDB"
.ConnectionString = "Data Source=Jeanne;trusted_connection = true;integrated security=sspi"
.Open
.DefaultDatabase = "DevTime21"
End With

With cmd

.ActiveConnection = db
.CommandType = adCmdStoredProc
.CommandText = "address_findck_okinsert_m"
.Parameters.Append .CreateParameter("@address_id", _
adInteger, adParamOutput, 4)
.Parameters.Append .CreateParameter("@Mailonly_lg", _
adBoolean, adParamInput, 1, False)
.Parameters.Append .CreateParameter("@ctry_id", _
adInteger, adParamInput, 4, 1)
.Parameters.Append .CreateParameter("@stpv_id", _
adInteger, adParamInput, 4, 1)
.Parameters.Append .CreateParameter("@postid_id", _
adInteger, adParamInput, 4, 0)
.Parameters.Append .CreateParameter("@postcode_ext", _
adChar, adParamInput, 10, "")
.Parameters.Append .CreateParameter("@add1_vc", _
adVarChar, adParamInput, 60, "")
.Parameters.Append .CreateParameter("@add2_vc", _
adVarChar, adParamInput, 60, "")
.Parameters.Append .CreateParameter("@add3_vc", _
adVarChar, adParamInput, 60, "")
.Parameters.Append .CreateParameter("@add4_vc", _
adVarChar, adParamInput, 60, "")
.Parameters.Append .CreateParameter("@city_vc", _
adVarChar, adParamInput, 30, "")
.Parameters.Append .CreateParameter("@city_lock_lg", _
adBoolean, adParamInput, 1, False)
.Parameters.Append .CreateParameter("@directions_vc", _
adVarChar, adParamInput, 2000, "")
End With
rs.CursorLocation = adUseClient

rs.Open cmd, , adOpenStatic, adLockBatchOptimistic
If Not IsNull(cmd("@address_id")) Then


Else

MsgBox "Please contact System Administrator. There was a problem adding address."
End If
Exit Sub
errmsg:
Call errormsginfo

End Sub

View 2 Replies View Related

Pushing Data To Clients

Jun 8, 2007

I am someting of a newbie to SQL Server, but I am an experienced C++/C# programmer.

I have a SQL Server 2005 DB to which are connected 50 or so clients.
The clients are running my software, written in C# and connected to the server by an OleDBConnection.
These connections are long-lived; in some cases they remain for days or more.
Now and again, one of the clients causes a change to the DB (not structural, just normal adds, update and deletes).
But most of the time the clients are just viewing data in the DB.

What I need to happen is that when any item of information changes, the display of that information on any of the clients which are viewing it must be updated quickly.
It doesn't have to be instant, but a delay or more than, say, 5 seconds is unacceptable.

It is like a share-dealing or foreign exchange system (although that is not what it is) where the traders' screens have to have up-to-date information at all times.
Note that the information received by the clients does not have to describe the change in detail, just a hint to the client as to what change has happened so that the client can refresh its views.

I can think of a way of doing this but it is really nasty.
The hints would be recorded in a time-stamped table. Each client would poll every couple of seconds by calling a SP, which would return the hints which have been added since the last time that client polled.
But polling is horrible and I am sure that there must be a better way.

A route that looks promising is InfoMessages. But, reading around the subject, it looks like these cannot be unsolicited and spontaneous; they only arrive on a Connection as a result of some action on that Connection.

I may have missed something, or maybe InfoMessages are not the way to go.
Can anyone offer me any advice, please

TIA,
Paul

View 3 Replies View Related

Synchronization Of Multiple Clients

Jul 20, 2005

Hi all,I've got a question concerning synchronization of multiple database clients.Consider a database, accessed by two clients. Is it guarantted, that ifclient 1 succefully commits a transaction, client 2 _instantly_ sees thechanges made by client 1?thx and regards,StephanP.S..: For MS Jet databases I know there _is_ a delay between writing datato the database and being able to read this updated value from anotherconnection,so the question refers to "real" DBMs (esp. SQL Server) only ;)

View 1 Replies View Related

How Toi Interact With Other Clients Over SQL 2005?

Jan 17, 2007

how can i communicate with other clients over SQL 2005?

I mean, i change data of database from a client, how to make othere clients do some actions acording to the data change .( let other client print some report ect.)



Thanks



View 1 Replies View Related

SQL Disconnecting Multiple Clients

Jul 5, 2007

We have a situation where multiple-random client connections to SQL server get disconnected.

The workstations are not consistent, the time is not consistent, and the functions being run are not consistent. One thing that we can reproduce is that sometime, but not always, if a workstation runs a function that calls a specific stored procedure (SQL native client, ADO, SQL Server 2005 SP2), during the course of the parameter validation (after the .execute) SQL sends an ACK, RST followed by two RST TCP packet back to the client and disconnects the connection.

At the same time, several other connections across multiple computers are also dropped by SQL. However, some computers may have multiple connections to SQL and some, but not all of these will be dropped. Other computers will
not have their connections dropped at all.

No SQL server errors are logged. Trace flags 4029 and 3689 have been set.

We have the network packet traces and the SQL profiler output to show this.

This is not reproducable at any other site.

Any ideas on what this could be would be greatly appreciated.
--
Dana Comolli
MS ISV Partner

View 1 Replies View Related

SSMSE On Multiple Clients

Aug 6, 2007

Hi all,

I've been running SQL Server 2005 for over three months, and have got the database up to speed. Using SSMSE for an interface.

I've have been trying to get the Intranet to link to the database (ASP), but after a little research i found we needed to change the Authentication from 'Windows Authentication' to a mix of windows auth and sql login. Needing to restart the server for the changes to take effect.

After the restart things started to go pear shaped.

Before the restart we were able to run queries from different clients at the same time (4 workstations). Now we are unable to access anything on the database if a query is running on a seperate client. As in table properties, running a query. As i've said, we were able to do this perfectly fine before the restart.


We also use other programs to generate records for the database. These programs now have difficulty connecting to the database. We've gone through the wizards and as far as we are aware things should be working. We have created extra username/logins for these programs so not one computer/client/program uses the same connection login. However, they are unable to connect even after the wizard says there is no problem connecting to the server.

Is there any *restore to factory/default settings* button? We've even tried reverting to Windows Authentication to try and solve the problem, but it didn't work, we're pretty dependant on the database for day to day operations.


Anyone with an idea as to what's wrong?

Thanks in advance

Gary.

View 3 Replies View Related

SQL 7.0 Clients Are Locking Up (memory Leak?)

Dec 1, 1999

Hi all,

I have a couple of client programs continuously dumping data into a SQL 7.0 database. I use ODBC connections that remain open as long as the client programs are running.

The memory consumed by SQL grows until all the system memory is consumed at which point the clients freeze (SQL no longer responds). Restarting SQL Server "cures" the problem for a few hours.

I've tried limiting the amount of memory used by SQL, but this only accelerates the eventual client freeze-up. At the moment, I let SQL dynamically consume memory.

These same client programs ran fine under 6.5

Thanks for any help..

SQL 7.0/SP1
P3-500
256MB

View 3 Replies View Related

MDAC2.6 With Sql7 And Sql2k Clients

May 10, 2001

hi,

iam under process of upgrading sql7 to sql2000.
already i upgraded clients to sql2000. then i got problem with some of our applications to connect to sql7 server. then i replaced in clients new ntwdblib.dll with old one then it works fine. to overcome this problem shall i install MDAC2.6 on server, where sql7 is there.

Is there any problem to SQLserver7.0 with MDAC2.6 ? because i want to install MDAC2.6 on production server with sql7.0.

thanx
keerthi

View 1 Replies View Related

What Must Have Clients To Work With Mssql Data

Mar 10, 2004

reading help i know that client for working with mssql remote db must have installed oledbprovider for XXX

i always use ole db provider for ODBC
, this ole db provider is installed with mssql, but what exactly must to have the clients which are not familiar with this ole bd provider, what files ?

View 2 Replies View Related

Counting Clients On First Day Of Month Adhoc

Apr 17, 2015

I am trying to write a query that counts how many clients were part of program at the first of each month.To make it simple, the data comes out of one table which looks like this:

Client # Program Start_date End_date
1 Fruit eater 03-27-2014 01-10-2015
2 Veggi eater 01-16-2015 null
3 Veggi eater 12-05-2013 04-16-2015
4 Fruit eater 10-01-2014 11-30-2014

Currently I have a very ugly solution that I know is not the best one:

Select
sum(convert(int,Jan_2014))as Tiers_in_Jan_2014
, sum(convert(int,Feb_2014)) as Tiers_in_Feb_2014
, sum(convert(int,Mar_2014 )) as Tiers_in_Mar_2014
, sum(convert(int,Apr_2014 ))as Tiers_in_Apr_2014

[code]....

Is there a better way to write this query?

View 3 Replies View Related

Insert Trigger - RaiseException To All Clients

Dec 13, 2007

Hey guys!, is there a way to raise an exception through an insert trigger... and that exception will be able to raise on every single application connected to that database at the time? not just the app that actually triggered the insert...

Thanks in advance!

View 1 Replies View Related

Conecting Over The Internet For Getting Data From Clients.

Jul 23, 2005

I want to connect over the internet to get data from clients.What wouldbe the easiest method and the most stable methos to do it1.Use a Point to Point prtotcol from the client pc and then upload thedata to our sql server2.Export the data from the clint pc in XML format and then Enter it inour computer.3.Have all clienst ftp the data in a dirctory and then upload the xmlfiles from the directory?Thanking you in anticipation.Would love it if we could discuss anddistribute our thoughts on this.Ajay

View 1 Replies View Related

Setting Up SQL Server For Remote Clients

Jul 20, 2005

Hi,I am having a hard time setting up an SQL Server 2000 DeveloperEdition instance for remote clients. The instance is running well andI can connect to it on the local computer. When I try connecting fromanother computer using Enterprise Manager with the server's IP as theinstance name, I always get the usual "Specified SQL Server not found"error. I have used Enterprise Manager many times to connect to localand remote servers (which were set up by someone else obviously).I used the client network utility on the client to make an alias forthis server and have it use the TCP/IP library for port 1433.I understand that SQL Server listens on port 1433 for connections. Ihave a firewall on the server and setup 1433 forwarding. But when Iuse Enterprise Manager to try to register the server, the firewalldoesn't even show a connection attempt on port 1433 (it logs allconnection attempts).When I use telnet to port 1433, the firewall logs the attempt butthere is still no connection, as if the server isn't actuallylistening on 1433 at all. I can't seem to find any help on getting theserver listening, as if it supposed to be easy to set up so I don'tknow what I'm missing. I guess I have the following questions:1) Does anything have to be done on the server side to set it up tolisten for remote client connections?2) How do I set the port on which the server listens in case I want tochange from 1433?3) Does anything have to be set up on the client side other than usingthe client network utility?4) Why does Enterprise Manager not seem to even attempt a connectionon port 1433 when I try to register this server?Any help is appreciated.

View 2 Replies View Related

Asynchronous Events To Database Clients Via DAL?

Sep 19, 2006

Greetings, I have a requirement for a SQL Server 2005 database to
notify 3rd Party applications of a table change. As is stands now, 3rd
Party applications access the database via a Data Access Layer (DAL)
dll (C#). I'd like to somehow implement an asychronous event
notification scheme via the same DAL to these clients.

Can someone offer a clever way to implement such events?

Broker Services? I am under the impression the SSBS is typically deployed when databases are to communicate with one another.

Triggers to call some CLR code?

Other?

Thanks in advance,
Loopsludge

View 3 Replies View Related

How To Enable Clients To Access The Same DB Via SQL Express

Nov 12, 2006

Hi to all!

My problem comes from this situation: I have two PC connected via a network calble; on the first I have SQL Server 2005 Express, an MDF data file in a shared directory under the "Document and Settings" path, and my program written in VB .NET 2005. On the second PC I have only my program, and I would like to have it connect to and work on the MDF on the first PC.

The program on the first PC works well and uses a connection string like the following:

Data Source=.SQLEXPRESS;AttachDbFilename=<path><name>.mdf;;Integrated Security=True;User Instance=True
I am able to access to SQL Express from the second PC (I have enabled the Client to use the right TCP ports, told the firewall to let them work and enabled the Guest user on the first PC to use SQL Express), but from Visual Studio Server Explorer I cannot reach my data file: any attempt fails telling me that I cannot open it because is in a shared location... I can only open the DBs located in the "Data Directory" of SQL Express...

In other words, what should I do to have two or more clients work on the same DB under SQL Express? Is it mandatory that the DB .MDF file resides in the "C:ProgramsMicrosoft SQL ServerMSSQL.1MSSQLData" directory so that it can be permanently attached to SQL Express?

Thanks for your help!!!

Roberto

View 6 Replies View Related

Setting Up A SQL Server For Remote C# Clients

Apr 25, 2008



Hello, I know that this has been asked several times, but none of the answers that I've found seem to help me.
I've been programming a C# client app that helps netadmins at my school file and solve tickets. I use an SQL 2005 backend; it works just fine on my dev computer (with C# express installed) which doubles as the SQL server. Now, when I move to a different computer, w/o Visual C# or SQL installed, I get.
"Request for the permission of type 'System.Data.SqlClientPermission, System.Data, Version=2.0.0.0,Culture=neutral,PublicKeyToken=(RANDOMVALUE)' failed."

my connection string

@"Server=FLHS7T-39312914SQLEXPRESS;Integrated Security=True;Database=msdb"


I've previously been able to get it to run both on client and server, but this error cropped up after a bit of a hiatus...

View 1 Replies View Related

SQL Database Access - Multiple Clients Issue

Sep 28, 2006

Hi Everyone,I have one database file which needs to be accesable to both a .net website and a vb.net application.The application collects data from the 'real world', processes it and adds the data to the database. The Website reads data from the database and displays the data in a graphical format.Now for the problem; While the Application is connected to the database (adding data), the Website is denied acces to the database. All connections to the DB are disposed when the Application is not uploading data, but the Website continues to be locked out (making it pretty useless) Closing the Application makes the Website work fine, but of course this means no 'real world' data can be updated.Can anyone suggest what is happening here, and more importantly how to fix it? A walkthrough must be available for this problem somewhere,... I just can't find it :(Thanks all,*The Stressed One* 

View 11 Replies View Related

Problem Getting The Most Recent Record For A Range Of Clients

Apr 13, 2007

I have a fairly complex SP with 3 tables the idea being to display a Region, Client and EventI want to show only the last event for each client
I have replaced my event table with a View which returns the TOP 1 but all I get is the most recent of all records I want eg:Region 1, Client 1, Most recent event Region 1, Client 2, Most recent event Region 1, Client 3, Most recent event 
 
 

View 2 Replies View Related

How To Manage Concurrency Between Multiple, Disconnected Clients

Sep 25, 2007

I have a system use MS SQL 2005 & .NET 2.0, my tables don't have rowversion, but I heard SQL 2005 manage a rowversion by itself, can I use this to do a "ConflictDetection".All I try to do is I want to get a error when I try to update a row which been modified by someone else after I read row. Thanks.   

View 1 Replies View Related

SQL 2012 :: How To Purge Old Store Procedures From Clients

Jul 11, 2014

I do have very old versions of duplicate store procedures on my databases. I know there is no "safe" way to do this using DMVs, so I am planning to combine that with a trace. But I would like to get others opinions about that.

Here's the DMV I am planning to use:

SELECT
CASE WHEN database_id = 32767 then 'Resource' ELSE DB_NAME(database_id)END AS DBName
,OBJECT_SCHEMA_NAME(object_id,database_id) AS [SCHEMA_NAME]
,OBJECT_NAME(object_id,database_id)AS [OBJECT_NAME]
,cached_time
,last_execution_time
,execution_count

[Code] ....

I will save that on a local table and run it every 5 min maybe? Or at an interval equal or lower than PLE?

View 5 Replies View Related

SQL Server 2014 :: Run Same Script For Multiple Clients

Jul 30, 2014

I have a script that needs to be run for 50 different @ClientID. I dont want to run this script individually for each clientid. Would 'SET @clientID in (111, 222, 333) work? I've been told that it wouldn't. Short version of the script is.....

DECLARE @ClientID varchar (MAX)
DECLARE @UserID varchar (MAX)

SET @ClientID = 111 -- Replace with Client ID
SET @UserID = 5656 -- Replace with your ID

[Code] .....

View 9 Replies View Related

Table Design - Log Number Of Visits From Clients

Dec 5, 2013

I am creating a simple database to log the number of visits from clients. The table is as follows :

tbl_statistics

--------------------------------------------------
p_key | client_id | client_datetime
--------------------------------------------------
1______4________2013-12-05 21:00:00
2______3________2013-12-05 21:02:11
3______1________2013-12-05 21:07:31
4______3________2013-12-05 21:12:42
.....

It will probably be logging about 2-3 rows in this table per second maximum so there will be some rows ... My question to you experts now is how the design of this table is done in the best way ( performance wise) in terms of "primary keys" , " clustered index" , "non clustered index"...

The only type of query that will retrieve data from this table is a standard "SELECT FROM" where " client_id " is of a certain value and " DATE_TIME " is between a specific date range.

example:

SELECT Count ( client_id ) AS totantal FROM tbl_statistics
WHERE ( client_datetime ) Between '2013 - 01-01 00:00:00 ' And '2014 - 01-01 00:00:00 '

Or is this better?

SELECT Count ( p_key ) AS totantal FROM tbl_statistics
WHERE ( client_datetime ) Between '2013 - 01-01 00:00:00 ' And '2014 - 01-01 00:00:00 '

View 3 Replies View Related

Blocks Of Time - Log Number Of Visits From Clients

Oct 30, 2014

I have the following SQL that I want to log the number of visits from clients. a session is a block of time, for example, any time between 9-12 is a morning sessions, 12-5 is an afternoon session etc. I need to count the number of sessions in a month not the appointments within the session, make sense?

select sr.resourceid, st.TimeStart, datename(m,sr.scheduledate) as sesmonth, datename(yy,sr.scheduledate) as year,
(CASE
WHEN DATEPART(hour, st.TimeStart) BETWEEN 0 AND 12 THEN 'MORNING SESSION'
WHEN DATEPART(hour, st.TimeStart) BETWEEN 12 AND 17 THEN 'AFTERNOON SESSION'
WHEN DATEPART(hour, st.TimeStart) BETWEEN 17 AND 24 THEN 'EVENING SESSION'

[Code] ....

View 2 Replies View Related







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