SQL Server :: How To Remove Records From A Table After Certain Days
Oct 25, 2010
I have records that were inserted into a sql server 2005 table using a stored procedure. I now need to remove or delete these records. The only problem is that the table does not contain a relevant column to define in my where clause when using delete command.
Is there any way I can identify these records for deletion.
I have two tables for storing language translations - tblEN and tblES. They have the same structure which is nvcEnglish and nvcLocal - both nVarChar fields.
In nvcLocal of the Spanish table, I enter the Spanish translations of words and phrases used within my app. Problem is, when I add a bunch of new records to the English table I also have to go in and repeat the data entry into the Spanish table. I am wondering if there is a way to import the newly added records into the Spanish table using Transact SQL?The plain language query would be something like:
If the data in tblEN.nvcEnglish does not exist in tblES.nvcEnglish then insert a new row into tblES with the values from tblEN
I want to retrieve all the records where the datetime is greater than or equal to 30 days ago. What is the correct formatting for this line: WHERE Property.dateadded >= NOW -30 days .. Dateadded field is in datetime format.
SELECT TOP (1) Property.Name, Property.Price, Department.DepartmentTitle, Images.ImageId, Property.DateAdded FROM Property LEFT OUTER JOIN Department ON Property.DepartmentId = Department.DepartmentId LEFT OUTER JOIN Images ON Property.PropertyId = Images.PropertyId WHERE Property.dateadded >= NOW -30 days
i have xyz.mdf file on live server every day i want to upload records on it for that i m downloading that file , make a changes on it and upload it . which is very time consuming and not a good practice is there any tool or any simple code i can write to do this for life time.
for sql i know there is a tool sqlpublishwizard which generate a query from selected table and that we can run directly on live server query analyzer and we can get the new records.
i have a table which records visits to a page, what i want to do is get a count of the last 24 hours and group the visits by the hour.
This is my table structure;
ID, ChannelNewsID, AddDate
This is what i did so far however it gives me both past and future records where as i want 24 hours previously starting from when the query was run. Here is what my query looks like;
I have a piece of sql code that selects the top 10% of a table. See below a sample of the database table
And this is my code
[Code]....
So what this code does is add up all the points in the points table, (also works out what percentage of the points each user has) and then displays the top 10%, which in this case will give me "John" and "Dave"
So what I need the sql to do is check if any other records in that table have the same number of points ast the last selected record, and to select it to.
I have created table into database dynamicaly,while inserting records into that dynamic table i faced problem.
The name "STD000001" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted. this error occured.
I created dynamic table by ,
declare @STUDENT_Table varchar(50) set @STUDENT_Table = [dbo].[GetStudentTable](@SchoolID) exec (@cmd) [code]....
this stored procedure.....
Should i give any permission while creating dynamic table.
I have a simple sql that selects records from some tables and insert them in one other table.This is what we need to do on a daily basis and we need to create a sql job for this.
CDC or Change data capture is a new feature in SQL Server 2008, which is an ability to record changes to table data into another table without writing triggers or some other mechanism, Change data capture records the changes like insert, update, and delete to a table in SQL server.I have sql 2005 and I have created triggers and tables CDC to capture the data. everything functions good and the data is being updated in the _CDC tables. all i need to do now is to generate the updated data as a report (excel/html)- what should I do ......?i need to show only the updated columns when user selects the date periods ( Range between dates ) and the person name - i need to display any updated info about that person during that period. So this updated columns about this person should be displayed in excel formatted column wise.
I have a datagrid control which is bound to a table which containing more than 1000 records. And i want to show only 25 records once a time. I have used paging in datagrid. But each time the next page index is set, query is fired again. This takes lots of time. So what is the easiest way to bound data in this case to improve performance.
I have an Access 2010 DB that I have a table of RAW data in. In my scenero when table 'a' has been populated all the rows with the updatedate of Now() get moved to another table... the SQL is like this...
[Code]....
As you can see it is a very simple query but it does NOT return any rows. There are actually 404 rows with todays date in teh Append_Date column.
I would like to make a function to return a information based on the current date and a process.So my parameters was just NOW() and the Process. For example to process AAA and the date '2011-03-27', I would get the stat 'normal' cause day 27 is between 4-28. (Doesn't matter the month)return case when ((@day >= @INI_DAY OR @day <= @END_DAY)) then @STAT else '' end;OR @day between @INI_DAY AND @END_DAY not works
ID Process Stats DayStart DayFinal 15 AAA Critic 1 3
The website is over half way done and the functionality for the blog is (except for adding posts) is already implemented and working correctlyI have a SQLExpress 2008 backendBlog posts are rendered on the page with full HTML markup within a label control.
All of the above is done and working. Though I am essentially new to creating websites with ASP.NET, CSS and SQL, I am sure that I could simply carry on and make a login page with some controls that would allow me to add records (blog posts) directly to the database on the host server. However, I am fearful of doing this because I know that malicious code can be passed in this way. Also, because of my lack of knowledge, the only way that I know of to pass the code from a control to the database is to disable validation for the page the control is on. Without a doubt I do not want to do that.
So what are my options for getting blog posts into the database? Is it safest for me to fully create the post in html and update a copy of the database that resides on my local machine? If I do it this way, how can I merge the records from the database on the local machine with the records on the remote server?
I have two tables and I want to display the second one based on the primary key:
the first table is tbl1 (id,fName,lName), and the second one is scnds(id,course,tbl1id).
I am practice using MVC 2.0, so I bulilt the the class repository
[Code]....
Then created the Studentcontroller
[Code]....
The problem is if I used Details method it will show only the first record, but I want to display every course that specific a student has. I don't know if the problem in repository or in the controller.
i have Intime and Outtime of each employee for all the days of 1st,2,3,4 week.There will be a off for 1 day or 2 days for each employees.Based on this i need to calculate consisitency days off assignmanet i.e no of matching days off among employees in percentage.If there are 100 emplyees out of 100 employees 50 people may get week off on the same day(for example sunday).I want result in percentage.result like this
Consistency Days of assignment Across 4 weeks 3 weeks 2weeks 0 2% 0% 0% 1 98% 100% 100% 2 0% 0% 0%
Here 0,1,2 are macthing days off.Across 98% of employees getting 1 days matching in off i.e 98% of employee might off in sunday.For this we need calculate matching days off for all the days from sunday to saturday across 4,3 2 weeks Here 98% of employees getting off in same day.0 indicates 0 days,1 is 1days and 2 is 2 days(for example 50 percentage of people will get off in saturday and sunday)