Select Newest Entry

Feb 22, 2006

How can I select from a table the newest entry.
I'm inserting in a table user info and then want to get the users id number

View 9 Replies


ADVERTISEMENT

Trying To Select Newest Row For Each Category...

Feb 6, 2004

Hi everyone -

I am building from the Time Tracker Start Kit, trying to get a better feel for how MS thinks we should do things.

In my editing, I have built a new Stored Procedure, trying to pull the newest entries for a specified person.

I have the following that will return all entries for a specific person, sorted by date, newest first:


SELECT
EntryLogID, TT_EntryLog.Description, Duration, EntryDate, TT_EntryLog.ProjectID AS ProjectID,
TT_EntryLog.CategoryID AS CategoryID, TT_Categories.Abbreviation AS CategoryName, TT_Projects.Name AS ProjectName,
ManagerUserID, TT_Categories.Abbreviation AS CatShortName
FROM
TT_EntryLog
INNER JOIN
TT_Categories
ON
TT_EntryLog.CategoryID = TT_Categories.CategoryID
INNER JOIN
TT_Projects
ON
TT_EntryLog.ProjectID = TT_Projects.ProjectID
WHERE
UserID = @UserID
ORDER BY
EntryDate Desc


This will return something like:


EntryLogId Description Duration EntryDate ProjectID CategoryID CategoryName ProjectName ManagerUserID CatShortName
14Can type date in date... .00 2004-02-04 10:28:00116Pros ITS Project Management App 3 Pros
12Changed "Entry Date"... .00 2004-02-03 13:28:00116Pros ITS Project Management App 3 Pros
13Added default button ... .00 2004-02-03 00:00:00116Pros ITS Project Management App 3 Pros
11Removed hours per p... .00 2004-02-03 00:00:00116Pros ITS Project Management App 3 Pros
6Isn't this cool .00 2004-02-02 00:00:00229Pros Knowledge Base 3 Pros
9Added week-by-week... .00 2004-02-02 00:00:00116Pros ITS Project Management App 3 Pros
10Fixed Update comma... .00 2004-02-02 00:00:00116Pros ITS Project Management App 3 Pros
1Built initial framewor... 6.00 2004-01-30 00:00:00116Pros ITS Project Management App 3 Pros
5Adding up to 8 hours... 2.00 2004-01-30 00:00:00229Pros Knowledge Base 3 Pros
3Debugged - fixed a f... 1.00 2004-01-23 00:00:00229Pros Knowledge Base 3 Pros



What I would like to accomplish is to return only the newest entry for each ProjectID (so in the above example, there would only be 2 entries, EntryID 14 and 6)

Any ideas?

Thanks in advance-

View 4 Replies View Related

I Want To Select The SECOND Newest Record In A Table,....is This Possible?

Jun 10, 2005

Hi!I want to do a query against a SQL DB and by sorting a datetime field, I want to get the second newest record in the table, not the newest.Can I do that?/Johan Ch

View 1 Replies View Related

How To Select The Newest Records For Each Project ?

Oct 9, 2006

i have the following table











Project
Name
Date

1
Dennis
01-01-2004

1
Peter
03-03-2005

2
Henry
01-02-2003

2
Lisa
04-03-2003

2
Peter
05-05-2005

2
Simon
05-06-2005

2
Lisa
12-12-2005

3
Henry
02-02-2004

4
Peter
03-04-2003

5
Joan
12-10-2005



For each project i would like to have the latest responsible person, so that i get a list like this









Project
Name
Date

1
Peter
03-03-2005

2
Lisa
12-12-2005

3
Henry
02-02-2004

4
Peter
03-04-2003

5
Joan
12-10-2005

Can someone please tell me how to do that in one query ?

View 4 Replies View Related

SELECT Only The Newest, But Based On Revised Letters

Feb 11, 2004

Ok here's a big one.

First I'm a big NEWBIE, so it'd be great if you can provide a little explanation as to how this should be done...

Here's what I want to do, but have no idea how to approach it.

I have a table with Quotes (table Quote) in them (for a Sale's Team). Each has a quote number (qtQN) and this number is sequencial but sometimes revised where a letter is added at the end. Like so:

qtQN__________Date
---------------------------
111q0001--------02/01/04
111q0002--------02/02/04
111q0002A------02/03/04
111q0002B -----02/04/04
222q0005--------01/15/04
etc... ------------- etc...

The first 3 digit are company codes and pretty unimportant to this problem. As you can see, 111q0002 has three versions. A, B, and no letter. The most up to date is B. So in this list I want to list only the most up to date quotes. So the resulting list would be:

111q0001
111q0002B
222q0005

Get it? Good, cuz I have no idea how to query that... any help at all is appreciated!

I'm using MS SQL Server 2k and scripting with ASP 3.0

View 6 Replies View Related

Select Last Entry Per Category?

Nov 8, 2005

Hello,

I am trying to select the last entry (by date) for each category in a table.

For example, if my table had the following fields;

id, category, product, datePosted,....

...how would I select the last product for each category posted by date?

Any guidance is appreciated.

Thanks,
AC

Probably a simple solution, but can't find it my brain right now!

View 7 Replies View Related

Can I Select Subset Based On Time Of Entry

Jul 5, 2001

A table gets data every 4 minutes, I only need spread of every 15 minutes. Can I select only records spread every 15 minutes apart from this table without having to run a scheduled job every 15 minutes and loading one record closest to getdate() at that point into another table(this is how I am doing it now) Is there a better way. Please help
Thanks

View 2 Replies View Related

Select Single Entry Found In All Rows (access2k)

Sep 8, 2004

I have to write a statement that answers the question:
"Which pilot is authorized to fly all the aircraft in the fleet?" implying that the individual aircraft could be of any of the three aircraft types.

Below are the tables with notation Tbl_name (important keys [clarification of keys]):

personnel (pers_id, name, crew_role [eg. pilot, stewardess]),
aircraft (craft_id, type_designation [eg. Boeing737], craft_name [eg. The Viking, Icarus]),
aircraft_type (type_designation), and
authorization (pers_id, type_designation).


In words my question should be something like:
"For all those who are authorized to fly aircraft (the only pers_id:s listed in the authorization table), show the names of those that have their pers_id:s next to all aircraft_type:s."

I've gotten this far:


Code:

SELECT DISTINCT p.name
FROM personnel AS p, authorization AS b, aircraft_type AS f
WHERE p.pers_id = b.pers_id
AND b.type_designation = ... ;



Now what I want to accomplish is to select the pilot which has a record for ALL type_designation entries in the aircraft_type table.

Is there a magic keyword that I don't know of? Is that magic keyword called "EXIST" and how do I use it?

Best regards,
rod

View 2 Replies View Related

Returning The Newest Rows

Jun 30, 2006

I have a query set up that returns the data that I would like, but Iwould only like the latest data for each vehicle number. The query Ihave set up isSELECT TOP 100 PERCENT dbo.vwEvents.EventName,dbo.luSessionAll.SessionName, dbo.luOuting.OutingNumber,dbo.luVehicle.VehicleName, dbo.luOuting.OutingID,dbo.tblOutings.OutingStartTime,dbo.tblSessions.Ses sionDate,dbo.tblSessions.SessionStartTimeFROM dbo.vwSessions INNER JOIN dbo.vwEvents ONdbo.vwSessions.Event = dbo.vwEvents.EventIDINNER JOINdbo.luSessionAll ON dbo.vwEvents.EventID =dbo.luSessionAll.Event INNER JOINdbo.luOuting ON dbo.luSessionAll.SessionID =dbo.luOuting.SessionID INNER JOINdbo.luVehicle ON dbo.luSessionAll.Vehicle =dbo.luVehicle.VehicleID INNER JOINdbo.tblOutings ON dbo.luOuting.OutingID =dbo.tblOutings.OutingID INNER JOINdbo.tblSessions ON dbo.tblOutings.[Session] =dbo.tblSessions.SessionIDGROUP BY dbo.vwEvents.EventName, dbo.luSessionAll.SessionName,dbo.luOuting.OutingNumber, dbo.luVehicle.VehicleName,dbo.luOuting.OutingID, dbo.tblOutings.OutingStartTime,dbo.tblSessions.SessionStartTime, dbo.tblSessions.SessionDateORDER BY dbo.luVehicle.VehicleName, dbo.tblSessions.SessionDate,dbo.tblSessions.SessionStartTime, dbo.tblOutings.OutingStartTimethis returns all the outings. I would like the outing that has, inorder of importance, the latest session date, latest session time andlatest outing start time. Outing start time can sometimes be <<Null>>but the other two always have values. How would I go about doing this?thanks in advance for any help

View 2 Replies View Related

Help - Finding The Newest Date Without Using Max()

Sep 18, 2006

Hi,Can anyone help please?select notefield, modifiedonFROM Table1WHERE id = '100426' and(statusfield like '%criteria1%' ORstatusfield like '%criteria2%')Produces a list of records based upon the criteria. I would like to beable to only show the newest dated record, from the modifiedon field.I've tried max(modified) on, but as I am using an aggregate function inthe query I have to use GROUP BY, which notefield does not like as thisis a ntext field.(I get:Server: Msg 306, Level 16, State 2, Line 1The text, ntext, and image data types cannot be compared or sorted,except when using IS NULL or LIKE operator.)Any ideas please?

View 1 Replies View Related

Only Need One Record Per Newest Date.

Feb 7, 2008

Hey all,

I just discovered this cool forum. I am fairly new to T-SQL, so please bear with me.

Here is my problem. I am trying to return 1 record for each distinct MachineName, based on the most current CreateTime.

I have tried a bunch of different things, but the follwing query seems to get me close, except for all of the records, per MachineName, that aren't the newest CreateTime. Can anyone offer a suggestion I may be missing?

Here is my query:

SELECT
rcv.Name AS MachineName, r.CreateTime, rpv.Path + rpv.Name AS ResourcePool

FROM
dbo.Result_View AS r WITH (NOLOCK) INNER JOIN
dbo.ResourceConfiguration_View AS rcv WITH (NOLOCK) ON r.ResourceConfigurationId = rcv.Id INNER JOIN
dbo.Resource_View AS rv WITH (NOLOCK) ON rcv.ResourceId = rv.Id INNER JOIN
dbo.ResourcePool_View AS rpv WITH (NOLOCK) ON rv.ResourcePoolId = rpv.Id

WHERE
(rpv.Name NOT LIKE 'Archive')
AND
(r.CreateTime > '2/1/2008')
AND
(r.CreateTime = (SELECT TOP (1) r.CreateTime FROM dbo.Result_View))

ORDER BY MachineName


I have added the '2/1/2008' filter, so as not to hammer the DB too hard. It goes back for some time.

Thanks in advance,

Allen

View 3 Replies View Related

SQL 2012 :: SSIS Jobs Not Using Newest One

Jul 10, 2015

I have just started to use Integration Services Catalog with SQL Server Agent. After I deploy a new version of the project the any Server Agent job that uses any of dstx still uses the old one. How do I fix this?

View 1 Replies View Related

Get Newest Input For Each User From Table

Nov 20, 2014

I dont know how to get the newest input for each user from one single table.

Should be a very simple task but i cant work it out.

The table looks like this:

ID (A_I), userID, ip, date(timestamp)

Here is a SQL Fiddle Link with some data also: [URL] ....

I have tried a lot querys like this one:

SELECT userID, ip FROM userips GROUP BY userID ORDER BY ID DESC

But this one does not give me the latest ip which was entered by a user.

View 2 Replies View Related

Getting Last (newest) One Record (datetime Column Or Id)

Jul 23, 2005

Hello everybody,-------------------------------------------------CREATE TABLE [T1] ([IDX] [numeric](18, 0) IDENTITY (1, 1) NOT NULL ,[DateEvt] [datetime] NOT NULL,[Value] [varchar] (10) NOT NULL ,[DataX] [varchar] (10) NULL ,CONSTRAINT [PK_T1] PRIMARY KEY CLUSTERED([IDX]) WITH FILLFACTOR = 90 ON [PRIMARY]) ON [PRIMARY]GOinsert into T1 (DateEvt,Value, DataX) values('2004.10.10 10:00:00','0000000001', 'AAAAAAAAAA')insert into T1 (DateEvt,Value, DataX) values('2004.10.10 10:00:01','0000000002', 'AAAAAAAAAA')insert into T1 (DateEvt,Value, DataX) values('2004.10.10 10:00:02','0000000003', 'AAAAAAAAAA')insert into T1 (DateEvt,Value, DataX) values('2004.10.10 10:01:00','0000000001', 'BBBBBBBBBB')insert into T1 (DateEvt,Value, DataX) values('2004.10.10 10:02:00','0000000001', 'CCCCCCCCCC')insert into T1 (DateEvt,Value, DataX) values('2004.10.10 10:03:00','0000000001', 'DDDDDDDDDD')GO-------------------------------------------------and the question is:In which fastes and best for the preformance way, get the last IDX ofspecified Value.I could do this like this:-------------------------------------------------declare @nIDX numericdeclare @sValue varchar(10)select top 1 @nIDX = IDX from T1where Value = @sValueorder by DateEVT desc-------------------------------------------------But I know, this is not fast (even if I have index on DateEVT field),and I'm quite sure, that there is better way to get this IDX.Anyway, this table can be big (like 20 milions records).I could take the max of IDX, but is it a sure way?Any help? Thanks in advanceMatik

View 1 Replies View Related

Selecting The Newest Records For Distinct Users

Oct 5, 2007

I have the following Table:DataIDuserIDTimeStampI need to create a query that selects the "newest" records for all distinct users. I'm hoping to get this done in one query. I know I could write multiple queries to find all distinct users, and then the newest records based on that... and so on... but I'm not sure that's the most efficient. I have the following so far, but is it the most efficient (I have indexing on most of my columns)?  SELECT DATA.DataID, DATA.UserID, UN.vchName, UN.vchImage, U.vchFirstName + ' ' + U.vchLastName AS 'FullName' FROM [tblData] DATA INNER JOIN [tblUnits] UN ON DATA.UserID = Un.UserID INNER JOIN [tblusers] U ON U.UserID = UN.UserID WHERE GPS.intGPSDataID IN (SELECT MAX([tbLData].DataID) FROM [tbLData] GROUP BY [tbLData].UserID)  

View 4 Replies View Related

Query/View: The 2 Newest Periods For Each Indicator

Mar 24, 2006

Hi,I'm working on a simple performance-program, where I need to extractinformation from the 2 newest periods for every performance-indicator- And from there calculate a trend between these results.The problem is, that I can't find a simple way to extract the 2 latestresults.The Table (Table1) looks like this:kpiIDperiodIDActualAcceleration23Acceleration54Speed1100Speed4200Speed7220Speed9180Weight122Weight332Weight721Weight1033If I want to extract the newest I use something like this (made it inMS Access, so the syntax might differ slightly from SQLServer):SELECT table1.kpiID, table1.periodID, table1.ActualFROM table1 WHERE table1.periodID = (SELECT max(t.periodID) fromtable1 as t WHERE t.kpiID=table1.kpiID);BUT - how how do I get the second-newest period as well?Preferably I would like the final result to be a View with thefollowing fields:kpiID, periodID_newest, Actual_newest, periodID_sec_newest,Actual_sec_newestAlternatively a View with 2 posts for each performace-indicator.Thanks in advanceRyan

View 10 Replies View Related

Three Table Join - Display Newest Comments Left On Photos Created By Members

Jul 6, 2014

I am trying to tweak some code which is used to display the newest comments left on photos created by my members.

The existing code is this:

SELECT top 15 pnumber,pcomment,puser FROM photocomments order by pdate DESC

So the latest comment left was for photo #210879 from user "Cla" (redacted user names). The 2nd newest comment would be for photo #211072 from a member named "mo". pdate is a date field

However for the script I have coded I don't want all of the photo comments to show up. This is because I use access levels based on the type of location (higher levels mean more restricted galleries). I check the access levels as I go through the recordsets.

I use this method to get the top 15 comments:

SELECT top 15 pnumber,pcomment,puser FROM photocomments order by pdate DESC

Now I have to use two other tables to determine the access level. Since PHOTOCOMMENTS is just a list of photo #'s and the people who left comments for those photos, I need to:

a) determine what location the photo is from and
b) determine the access level of that location

I use: select creator,access from locations where id=(select dir from photos where id="&pnumber&")"

This is a two step process as you can see. The first part is:

select dir from photos where id=(pnumber)

ID is the same value as pnumber seen in PHOTOCOMMENTS. That is to say PHOTOS.ID = PHOTOCOMMENTS.PNUMBER

If I haven't confused you yet, the executed code for the first example would be:

select dir from photos where id=210879

which would get me a value for DIR. DIR is the location number which would be:

select creator,access from locations where id=(dir value)

Just to simplify it a bit....

There are three tables (shown below)

PHOTOCOMMENTS
PHOTOS
LOCATIONS

I need to: SELECT top 15 pnumber,pcomment,puser FROM photocomments order by pdate DESC (first table shown)

but then also

select creator,access from locations (The last table shown)
where id=(select dir from photos where id="&pnumber&")"

So the first table PHOTOCOMMENTS has to also join PHOTOS table where PHOTOS.DIR = PHOTOCOMMENTS.PNUMBER in order to get the value of "DIR" and then DIR is joined to the LOCATIONS tables where PHOTOS.DIR = LOCATIONS.ID

Here is the actual code, which I am trying to make into a single SQL command

strSQL = "SELECT top 15 pnumber,pcomment,puser FROM photocomments order by pdate DESC"
set ors = oconn.Execute(strSQL)
tl = 0
do until ors.eof or tl > 15
' until we have 15 results because not every recordset will be of the proper security level

[Code] ....

Bonus points if you can also get it to select from LOCATIONS only WHERE userlevel >= 2

View 4 Replies View Related

Find The Newest Date Of 2 Date Fields

Aug 20, 2007

I've 2 date fields clidlp,clidlc in my data base table. How do I find the newest dates between the fields? Thanks for your help!

View 1 Replies View Related

Could Not Add The Entry...

Nov 22, 2005

Can someone please help me solve the following error? I am not sure of the version my hosting company is using and where to get the manual.
Could not add the entry because: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '-id, title, entry, date_entered) VALUES ('testing', 'testing', . The query was INSERT INTO blog_entries (blog-id, title, entry, date_entered) VALUES ('testing', 'testing', 'testing'.


PHP Code:




if ($dbh = mysql_connect ('localhost', 'blu6592_money', 'rich')) {
    print '<p>Successfully connected to MySQL.</p>';

if (mysql_select_db ('blu6592_myblog')) {
    print '<p>The database has been selected.</p>';
} else {
    die ('<p>Could not select the database because: <b>' . mysql_error() . '</b></p>');
}

$query = "INSERT INTO blog_entries
(blog-id, title, entry, date_entered)
VALUES (0, '{$_POST['title']}',
'{$_POST['title']}',
'{$_POST['entry']}', NOW())";

if (mysql_query ($query)) {
    print '<p>The blog entry has been added.</p>';
} else {
    print "<p>Could not add the entry because: <b>" . mysql_error() . "</b>. The query was $query.</p>";
}

} else {
    die ('<p>Could not connect to MySQL because: <b>' . mysql_error() . '</b></p>');
}

mysql_close(); 






Thanks in advance.

View 1 Replies View Related

Last Entry In A Log

Aug 13, 2005

(I don't post here often, so in case I'm violating long-standing taboosof this newsgroup, I apologize in advance for calling a relation atable, using nulls, and other ignorant, destructive, and comtemptibleterminology.)I have a table that's keeping a sort of running log of different typesof changes to pieces of data. The table has a foreign key of the databeing changed, the foreign key for the type of change occuring, someinformation about the change in a couple more columns, and a timestampfor each entry. So it's:dataIDeventIDeventInfotimestampWhat I'd like to do, if at all possible, is a single SQL query that,given a dataID, returns the most recent eventInfo and timestamp foreach eventID. Is this possible?Many thanks.-Eric

View 3 Replies View Related

Advice On Entry In To IT

Apr 12, 2004

Anyone Got any other advice?

http://www.dbforums.com/t993214.html

View 3 Replies View Related

Anyone Know What Causes This Error Log Entry?

May 30, 2007

"High priority system task thread: Operating system error Exception 0xAE encountered."

we are seeing this on one of our development servers, running SQL 2005 Enterprise SP1. The symptom is that after the sql service has been running a while (order of days), this error starts getting written to the sql server log file over and over, and eventually the logfile fills the drive.

Apparently it's fixed by this hotfix, but our ops team doesn't want to install this - they'd rather just cycle the service and delete the log when it happens.

I was wondering if anyone else has seen it might know the root cause so we might be able to workaround it without cycling the service. I know, lame question. The correct answer is "install the hotfix" or "install sp2" but our ops team won't do that for now...

www.elsasoft.org

View 2 Replies View Related

Duplicate Entry

Jul 24, 2007

Hi All,

I have a table with name C1_Subscribers with three fields (1)-MobileNumber [varchar]
(2)-ReceivedTime [datetime]
(3)-Status [char].
Now here how to remove duplicate entry of same mobile number to MobileNumber field?

Regards
Shaji

View 4 Replies View Related

Selecting First Entry In Results By Name

Nov 28, 2006

Hello,
I have a table of names/dates as such:
Class 1     1/1/2007Class 1     1/3/2007Class 1     1/5/2007Class 2     2/1/2007Class 2     2/3/2007Class 3     3/1/2007
What I want to do is select only the nearest entry from the list for each distinct class, so the results are like this:
Class 1     1/1/2007Class 2     2/1/2007Class 3    3/1/2007
So basically, I want the first upcoming class in the list for each distinct class name.  How do I do this?  I'm using SQL 2005 Express.
Thanks.

View 3 Replies View Related

Verifying Entry Is Not In DB B4 Inserting

Jun 4, 2007

How do i do that... in sch lab, the lecturer said:    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click        Try            SqlDataSource2.SelectParameters("Title").DefaultValue = txtProductTitle.Text            GridView1.DataBind()            If GridView1.Rows.Count > 0 Then //if no repeated                 Label1.Text = "Existing Record Found. Please enter another Software."            Else                'SqlDataSource1.Insert()                'Label1.Text = txtProductTitle.Text & " successfully added to the database."            End If        Catch ex As Exception            Label1.ForeColor = Drawing.Color.Red            Label1.Text = "An error occured!" & ControlChars.NewLine & ControlChars.NewLine & _            ex.Message.ToString()        End Try    End Sub but its not working for me... the GridView1.Rows.Count is always 0, if there is a repeat, it should be > 0 

View 4 Replies View Related

DateTime From Database Entry

Nov 9, 2007

Hi, I know this is probably very simple but I am pretty new to this and have tried looking but cant seem to get the search criteria right. I have  a database with a storeDate field which is of shortdatetime type. I am connecting to the database (MSSQL)  via a stored procedure and returning all the records. I then use the code   foreach (DataRow dr in ds.Tables[0].Rows)  {      DateTime dtTo = DateTime.Now;      DateTime dtFrom = DateTime.Parse(dr["storeDate"].ToString());      TimeSpan diff = dtTo.Subtract(dtFrom);  } I am basically trying to find out the age of the database entry by subtracting it from the current DateTime so i can delete records over a certain age. The problem (at least one of them!) is retrieving the "storeDate" object from the database and storing it in the dtFrom object. I have tried just assigning it directly as dtFrom = dr["storeDate"] and various other methods but I just don't know enough to assign it!  Can anyone help me with this or spot any other mistakes in this process of removing old files automatically. Greatly Appreciated,Sean.  

View 4 Replies View Related

Automatic Field Entry

Nov 17, 2007

Hi,I'm creating a database using SQL Server 2005 Express Edition (Comes with Visual Web Developer). The table which I am creating has the following Fields - all don't allow nulls:IDUserIdDateDescription(UserId is a foreign key to asp_net_Users as I am supporting user accounts)Basically what I need to do is create a page where I as an Administrator can log onto and enter just the text for the field Description. Then once I upload this I wish all users to visit the site and view this Description on a page however with it also listing the Administrator who wrote it along with the Date. I wish both of these fields to be added automatically (UserId to display the User Name and the Date to display the date and time with which the Description was added - However these need to be editable by the Administrator if he/she wishes to change them).Can anyone point me in the right direction on the steps needed to create this scenario?Thanks for any helpDaniel    

View 4 Replies View Related

Identical Database Entry Already?

Aug 14, 2005

Here's some code that says it should identify if a user already exists in my database. I have changed the code to match my database, but it seems to have somewhat the opposite affect, rejecting all names (even new ones) or accepting all names (including existing ones). The switch in situations occurs in the "if" statement towardsd the end, when I change the sign of objDR.RecordsAffected.  Do you have any idea what could be wrong? Thanks.
Function DoesUserExist(ByVal userName As String) As Boolean
Dim connectionString As String = "server='(local)Netsdk'; trusted_connection=true; Database='AuthorizedUsers'"
Dim sqlConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(connectionString)

Dim queryString As String = "SELECT [Users].[UserName] FROM [Users] WHERE ([Users].[UserName] = @UserName)"
Dim sqlCommand As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand(queryString, sqlConnection)
Dim Cmd as New SQLCommand(queryString, sqlConnection)
With Cmd.Parameters
.Add(New SQLParameter("@username", username))
End With

sqlConnection.Open
Dim blHasRows As Boolean
Dim objDR As System.Data.SqlClient.SqlDataReader = Cmd.ExecuteReader(system.data.CommandBehavior.CloseConnection)

if objDR.RecordsAffected > 0 then
blHasRows="True"
else
blHasRows="False"
End If

Return blHasRows

End Function

View 4 Replies View Related

How To Prevent Doublicate Name Entry

Feb 23, 2001

hi I have a table I need to have a process which prevent a user from entering a name value( company Name ) in a field. how can I do that .

Ahmed

View 2 Replies View Related

Overwriting Entry In Table

Jan 26, 2005

Task:

To insert entries into a table. The table has a primary key based on a field 'ID'. When inserting into the destination table, I want to make sure that the new entry will overwrite the old entry.

What's the quickest/cleaniest way to do this ?

thanks,
Clayton

View 1 Replies View Related

Number Of Entry Query.

Aug 2, 2006

MSSQL2K
SP4

Howdy all. Im trying to write a query that will track a data modification grouped by employer ID and transaction date. I don't know if Im asking it right so here is what I have, plus my current and desired outputs.

--drop table #foo
create table #foo
(empID int,
transDate datetime,
transType varchar(10))

insert into #foo values(1, '01/01/06 01:01:01','Insert')
insert into #foo values(1, '01/01/06 01:01:02','Update')
insert into #foo values(1, '01/01/06 01:01:03','Delete')
insert into #foo values(2, '01/01/06 01:01:01','Insert')
insert into #foo values(2, '01/01/06 01:01:02','Update')

select f.empID, Change =
(select count(transDate) from #foo f2
where f2.empID = f.empID
group by empID),
f.transDate, f.transType
from #foo f

Current results:

132006-01-01 01:01:01.000Insert
132006-01-01 01:01:02.000Update
132006-01-01 01:01:03.000Delete
222006-01-01 01:01:01.000Insert
222006-01-01 01:01:02.000Update

Desired results:

112006-01-01 01:01:01.000Insert
122006-01-01 01:01:02.000Update
132006-01-01 01:01:03.000Delete
212006-01-01 01:01:01.000Insert
222006-01-01 01:01:02.000Update

TIA, CFR

View 5 Replies View Related

&<Long Text&> Entry

Mar 12, 2008

Hi all,

Newbie here, just wanted to get that out of the way first
and foremost.

Im trying to set up a DB in SQL 2000 that allows me to enter
lots of text into a column.

I read one site where it said to use the NTText datatype with a length
of 16. I did that, but everytime I enter alot of text into that column
I get <Long Text> and I dont know how to output that or even
read it.

Do any of you guys know how to either:

1. get the text out of the <long text> or
2. a better way to store that much data.

Thank you in advance!!!

REZ

View 8 Replies View Related

Can Insert Same Exit Value For Entry

Nov 24, 2011

i have data like...

userid startdate in_out
1 2011-11-20 9.30 1
1 2011-11-20 10.30 0
1 2011-11-20 12.30 0
1 2011-11-20 12.45 1
1 2011-11-20 6.30 0

See 1-Entry 0-exit for 2011-11-20 12.30 is exit but entry time of that exit is missing....

Can i insert same exit value for entry?

View 3 Replies View Related







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