Need To Determine If Records Are Already In Database

Feb 21, 2001

Problem: I can add 4 items to a SQL 7.0 database but I need to redirect the user if all 4 items exist in the same Record elsewhere in the Database.

Clearly I need some kind of statement like "if category1 = var1 AND category2 = var 2 AND..." but don't know where to put it.

Code:

strSQL = "SELECT * FROM tblUserQuarter"

Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open strSQL, objConn,adOpenStatic , adLockOptimistic

'Insert choices from report.asp into tblUserQuarter
objRS.AddNew
objRS("cboFY") = Request.Form("cboFY")
objRS("Quarter") = Request.Form("Quarter")
objRS("ID") = Request.Form("ID")
objRS("Report") = Request.Form("Report")
objRS.Update

objRS.Close
Set objRS = Nothing
objConn.Close
set objConn = Nothing

View 1 Replies


ADVERTISEMENT

How To Determine The Unique IDs Of Duplicated Records

Feb 21, 2006

> This is a common problem with some solution[color=blue]>>[/color]/************************************************** *********************************** Problem:* Determine the Duplicated Records in a table using single SELECT.** We shall be using Northwind database, add some duplicate records.** Here we want to know if 2 columns (CompanyName,* PHone) are duplicated in a table.*** ShipperID CompanyName Phone* ----------- ------------------------- ------------------* 1 Speedy Express (503) 555-9831* 2 United Package (503) 555-3199* 3 Federal Shipping (503) 555-9931* 4 Federal Shipping (503) 555-9931* 5 Speedy Express (503) 555-9831* 6 Federal Shipping (503) 555-9931***************************************************** **/================================================== SOLUTION 1: Gives me the IDs that are duplicated.================================================== SELECTShipperID, CompanyName, PhoneFROMSHIPPERSWHEREEXISTS (SELECTNULLFROMSHIPPERS bWHEREb.CompanyName = SHIPPERS.CompanyNameAND b.Phone = SHIPPERS.PhoneGROUP BYb.CompanyName, b.PhoneHAVINGSHIPPERS.ShipperID < MAX( b.ShipperID ))/* ********************* Output results********************/ShipperID CompanyName Phone----------- ----------------------------------------------------------------1 Speedy Express (503) 555-98313 Federal Shipping (503) 555-99314 Federal Shipping (503) 555-9931(3 row(s) affected)================================================== ===========SOLUTION 2: Gives me the data which are duplicate butnot the IDs================================================== ===========SELECTCompanyName, PhoneFROMSHIPPERSGROUP BYCompanyName, PhoneHAVINGCOUNT(*) > 1/* ********************* Output results********************/CompanyName Phone---------------------------------------- ------------------------Speedy Express (503) 555-9831Federal Shipping (503) 555-9931(2 row(s) affected)

View 1 Replies View Related

How To Determine Last LSN For Database

Feb 13, 2008



What is the most reliable way to determine the last LSN of a database? I've looked in sys.database_files to no avail. I've also looked in msdb.dbo.backupset which is accurate but only based on backups already performed not the current state of the database.

-joe

View 5 Replies View Related

How To Determine Size Of Database

Feb 25, 2015

I ran a query to see how big my database on my SQL Server is and do not understand the metrics. I want to see how much of my 10GB database is left.

database_namedatabase_sizeunallocated space
ANTHEMQ 6521.06 MB243.55 MB

reserveddata index_sizeunused
1332304 KB1328168 KB1800 KB 2336 KB

View 3 Replies View Related

How Can I Determine The Size Of A Database?

Mar 8, 2007

Simple question...

When I use the full version of SQL Management Studio, I can run a report to view the size. How can I do this with SQL Mgmnt Express?

View 1 Replies View Related

Determine Date Database Was Last Used ?

Jun 15, 2006

Hi There

I am trying to establish the date a database was last used.

At first i checked out sp_helpfile and sysfiles to see if there was a date last modified, i also tried using xp_cmdshell to check the date on the actual .mdf or .ldf on the o/s but if the file has not grown the date will be the create date.

I need to establish the date a database was last used, either the last time someone logged into it or the last time any sort of command was run against the database, i cannot use sysprocesses as there are no connections to the database, so i need to determine the last time there actually were any processes run against this database.

And i need to use tsql, checking audit logs etc is not viable, can anyone help ?

Thanx

View 6 Replies View Related

Determine Last Access Of A Database Or Table

Dec 18, 2007

Does anybody know of a way to determine the last date/time a table has been accessed (query/update)? I've done enough research to know that this isn't easy. However, perhaps somebody has figured out a way through some of the stats that SQL Server keeps to determine the last access of a table. I have recently been put on a team that had no DBA and has a number of databases out there. They would like to determine which databases are inactive and get rid of them. I am a developer and haven't had much SQL Server Administration experience. Any info will help greatly! Thanks!   

View 2 Replies View Related

SQL 2012 :: Determine Size Of Database

Sep 17, 2015

I am working on Sql Server 2012. and I have multiple databases there. Out of those, i want to move one of my databases to other SQL server 2012, For that i was trying to get approximate size of my database on current server. As i don't have the admin rights, so i can't get that. Can i get the approximate size by right clicking on database and by using the size property Under Database category to get the size idea?

View 4 Replies View Related

Determine When A New Record Is Added To A Database

Dec 31, 2007

I have a SQL database that gets populated by another program. Is there a way to determine when a new record is added to that database?

Thanks

View 4 Replies View Related

How To Determine Sp Caller Current Database?

Aug 23, 2007

When executing a stored procedure that is defined in another database, as:

USE db1;

EXEC db2.dbo.sproc;

Is there a way in the stored procedure "sproc" to determine that the caller made the call from db1?

View 1 Replies View Related

SQL Server 2014 :: Possible To Determine Dataflow Within A Database?

May 14, 2015

Is it possible to determine the data flow within a database? e.g. I start by adding/inserting a record in MainTable1, then through a trigger SubTable1, SubTable2 have records inserted into, SubTable3 has a record updated into, then a StoredProcedure1 is run which updates first SubTable4, then a StoredProcedure2 is run which adds a record in SubTable5. So by simply adding a record in MainTable1, I affect 5 other tables.

Imagine a more complex process than this one now (which I'm currently facing and I want to win time and precision; I will still investigate it myself (if I will find an answer first - I will post it here)) Is there a way I could "extract" this flow by using T-SQL?

View 7 Replies View Related

How Do I Determine The Backup Date Of A Restored Database..?

Feb 1, 2007

Hi All,I have to a few backups restored from a set of backup files. Thebackup files have been removed from the drive because of some storageconstrains...For some data comparison reasons, I need to figure out the actual dateof these backup files that is used to restore these databases. Isthere any system table I can query to figure the actual backup timesof these databases...Any help will be much appreciated.. Thanks in advance.- Aravin

View 1 Replies View Related

Cannot Determine How To Set Owner To Install Database Design

Jun 14, 2007

My compatibility settings are fine. Anyone know how to to this?

View 4 Replies View Related

DB Engine :: Determine Database Access History?

Jul 31, 2015

I was asked to determine the last time 2 databases were accessed.

Are the .trc files an accurate way to determine the database access history?

View 5 Replies View Related

SQL Security :: How To Determine What Certificate Is Used To Encrypt A Database In 2014

May 28, 2015

I use a number of certificates on my database server.  I'm trying to verify the correct certificate is being used on the correct database.

View 3 Replies View Related

Way To Determine Which Logins Have Write Permissions To Database On Sever

Nov 15, 2007

Hi there,

Does anyone know a way (a query perhaps?) to determine which logins have write permissions to a specific database on SQL Server 2005? Ive thought about joining sys.syslogins & sys.sysusers but looking at the columns, not sure which one would render me that info.

Any help is appreciated. Many thanks!

View 1 Replies View Related

Waht Is Tempdb Database Used For? And How Can We Determine What Files Can Be Deleted From It?

Jun 25, 2007

Hi, all experts here,



Thank you very much for your kind attention.



Just found that my tempdb is always full whenever I run a query against a large database. Could please any experts here give me any advices on what is tempdb database used for and how to determine what files can be deleted from it?



I am looking forward to hearing from you and thanks a lot in advance.



With best regards,



Yours sincerely,



View 3 Replies View Related

Transact SQL :: Determine When Database Was Backed Up Without Using MSDB Tables?

Apr 22, 2015

I was wondering if there was another method to determine when a database was last backed up without using the backup history tables in msdb? whether using DBCC DBINFO, DBCC PAGE on a specific database page...etc.

Also, when restoring a database, is there a trace flag you can use to force restore details to be written to the error log?

View 4 Replies View Related

SQL Server 2012 :: Determine Read / Write Frequency On Database Table

Oct 6, 2015

How do I determine the read/write frequency on a database table? I am trying to do this on a 2012 and 2008 R2 servers.

View 2 Replies View Related

Copy Records From One Database To Another Database With Difference Of Records.

Apr 6, 2008

Hi,
I already submitted this type of question before and i receive reply. But unfortunately i found out errors when performing on my system.

My problem regarding to this one:

Suppose i have two databases with same tables with different records and I would like to copy the records from one database to another data and vice-versa. So that both the tables contains same number of records inside the tables.

Example:

Database1 (EmployeeTable) contains 6 records.
Database2 (EmployeeTable) contains 10 records.

It should copy only those records which is not present in each other database. No duplicate records.

Before i was recommend to use Primary key, if it is not present use index.

Hope this time i could solve my problem.

Thanks.

Kashif Chotu



View 1 Replies View Related

How To: Determine If Current Windows User Has Login Access, Database Access And If They Are A Member Of A Specific DB Role.

Mar 25, 2008


I need to determine the following about the current authenticated Windows domain user who is trying to access a SQL Server via a trusted connection.

1 Has the current user been granted login access to the trusted SQL Server?

2 Has the current user been granted access to a specific database?

3 Is the current user a member of a specific database role such as (DB_ROLE_ADMINISTRATORS)?

Thanks,
Sean

View 6 Replies View Related

SQL 2012 :: Query To Make Single Records From Multiple Records Based On Different Fields Of Different Records?

Mar 20, 2014

writing the query for the following, I need to collapse the continuity. If the termdate for an ID is one day less than the effdate of the next id (for the same ID) i need to collapse the records. See below example .....how should i write the query which will give me the desired output. i.e., get min(effdate) and max(termdate) if termdate is one day less than the effdate of next record.

ID effdate termdate
556868 1999-01-01 1999-06-30
556868 1999-07-01 1999-10-31
556869 2002-10-01 2004-01-31
556872 1999-02-01 2000-08-31
556872 2000-11-01 2004-01-31
556872 2004-02-01 2004-02-29

output should be ......

ID effdate termdate
556868 1999-01-01 1999-10-31
556869 2002-10-01 2004-01-31
556872 1999-02-01 2000-08-31
556872 2000-11-01 2004-02-29

View 0 Replies View Related

How Do We Determine Which User Database Tables Are Mostly Retrieved By User Or Modified By User?

May 22, 2008



Hi,
Please give the T-SQL script for this ? Thanks

Shanth


View 4 Replies View Related

Delete All Records From A Database

Aug 30, 2007

Is there a way to delete all records in a SQL Server 2005 database? A function or a script?

View 8 Replies View Related

Duplicate Records On Database

Sep 3, 2007

hi all,
How do i avoid duplicate records on my database? i have 4 textboxes that collect user information and this information is saved in the database. when a user fills the textboxes and clicks the submit button, i want to check through the database if the exact records exist in the database before the data is saved. if the user is registered on the database, he wont be allowed to login. how can i acheive this?
i thought of using the comparevalidator but i'm not sure how to proceed.
thanks

View 2 Replies View Related

Records Don't Get Deleted From The Database!

Sep 17, 2007

I am using this code to delete records from a table in the database that has two fields (both are primary keys) I am not getting any error, but nothing gets deleted. Thanks for the help.
Code:protected void btnRemove_Click(object sender, EventArgs e)
{
 
Remove();Response.Redirect("RegisteredCompanies.aspx");
 
}protected void Remove()
{
//update database with filename
//Save Changes
connection.Open();using (SqlTransaction trans = connection.BeginTransaction())
{
try
{ SqlHelper.ExecuteNonQuery(trans, CommandType.StoredProcedure, "spRemoveCompany", new SqlParameter("@Userid", getGdUserID(Profile.UserName)),new SqlParameter("@BusinessID", getBusinessID());
}catch (Exception err)
{
// throw exception
trans.Rollback();
 lblStatus.Text = "An error has occurred in the delete process. Please try again.";
}
}
 Here is the stored procedure:ALTER PROCEDURE [dbo].[spRemoveCompany]
 
 
@Userid uniqueidentifier OUTPUT,
@BusinessID uniqueidentifier OUTPUT
 
 
 
ASDELETE FROM Associations2 WHERE Userid = @Userid AND BusinessID = @BusinessID
 
RETURN

View 4 Replies View Related

How To Backup Records Of A Database?

Dec 17, 2005

Hello.
I need to design a database structure that will keep ALL table records and not delete anything. Every record will have associated users, but I need to keep perminant track of what every user did to any record.
Can you suggest a reading or backup method? Should I keep older versions of a record within the same table or move them to another? Or backup to log files? Any suggestions?
Thank you in advance
- Jasem

View 2 Replies View Related

Duplicate Records In The Database

Sep 13, 2006

i have duplicate records, but they have unique ids.

the duplicates resulted as a result of using a view to enter the data using BCP to load data from text file that had many dulicate records as part of consolidting the data i would like to get rid of the duplicate

is there some way of checking if the Name, Address, Telephone and Image are the same as on a record with another then remove them.

the table has the following colunms:

ID, Name, Address, Telephone, Image

1, adam, 45 tree gate road, 00000 000000, adam.jpg
2, uno, 44 garstang road, 00001 000001, uno.jpg
3, adam, 45 tree gate road, 00000 000000, adam.jpg
4, brian, belgarth house, 00022 000022, adam.jpg
5, karen, 3 chester close, 00002 000002, adam.jpg
6, uno, 44 garstang road, 00001 000001, uno.jpg
7, adam, 45 tree gate road, 00000 000000, adam.jpg


from the sample data you can see that there are multiple records is there a way of clensing the data using a sql command?

is there any issues such as performance on clensing it etc?

are there any strategies that should be implemented at the data tier so as to prevent duplication of data?

View 20 Replies View Related

Use Db-lib To Update Database Records

Jul 20, 2005

How to use db-lib to update/insert database records without using SQLlanguage. I want to change the value of the data individually withoutplugging in the new values in the SQL language then execute it. Theperfect situation for me is loop through the retrieved records thenedit the values individually until EOF.Thanks,Carlo

View 1 Replies View Related

Inserting New Records In A SQL CE Database

Jul 10, 2007

hello everyone



I have a question about new record insertion. I have a SQL Database that I have cofigured as a publisher for a mobile database. I want to be able using the PDA to insert new Customers and synchronize the CE database with the SQL DB. But I encounter a problem with the column field rowguid that SQL inserts as a unique indentifier during the publication. It cannot accept null values and I can't insert a value using the keyboard since the value is generated by SQL.

So my impression is that you cannot use PDA to insert new records, only to update old ones. Is that true or I miss something??



If someone knows the answer please let me know.



Thank you in advanced.

View 8 Replies View Related

Counting All Records In A Database

Jun 9, 2007

Is there an easy way to count all records in a database?

View 3 Replies View Related

Binding A Database Records To A Dropdownlist

Nov 24, 2006

Hey I just wanted to know if anyone could tell me how to bind values from a database to a dropdownlist?

View 2 Replies View Related

How Can I Return The 5 Records From A Database Table Using Ado.net

Apr 24, 2007

I have an incident reporting management application. People are supposed to report incidents by this application and every time some one reports an incident, they also select thier employee#(reqiured field). so how can write an sql statement that returns only the Top 5 incident reporters i.e going by employee number. Iam thinking of applying a COUNT function on the incident_id and grouping by Employee# but then how do i make sure that only the top 5 incident reporters are returned.

View 1 Replies View Related







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