|
Remove the AppointmentDate column, then create a second table that stores just the appointments and an identifier. Then use a Join statement.
"A client can have more than 1 record" is about the worst thing a database can say.
|
|
|
|
|
Johnny
I STRONGLY advise you to get a book on database design, find a beginners book and at least get the principles. You are committing one of the most basic errors in data design and if you do not get the basics you are going to create a nightmare for yourself and the poor sod who has to fix it.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Is it posible to write a trigger for a SQL db that fires on a date change?
i need to log the communications between an app and a palm scaner, but this would become one huge table within months. the idea is to only keep the latest 30 days of records in that table. so the trigger has to fire every day, check the date on the entries and delete it if its over 30 days old.
Thanx
Harvey Saayman - Junior C# and SQL Programmer
Think big and kick ass
|
|
|
|
|
you shuld look into using a windows service that would run on the server that has that database. that Service should run at say 12am each night and delete the records as necessary
hope it helps
Rocky
Success is a ladder which you can't climb with your hands in your pockets.
|
|
|
|
|
yeah we thaught of that, doing it programmaticly. but it would be sweet if a SQL trigger could handel that for us.
Thanx man
Think big and kick ass
|
|
|
|
|
Use an SQL job to call a stored proc?
|
|
|
|
|
We are trying to create a series of XML scripts from a Mysql database query. We are having two issues that we are not smart enough to figure out & could use some help;
1) We need to save each row of the query result as a separate xml file i.e. running the query may generate 100 results - each row being a full XML string which needs to be saved as a separate file. Is there a method to accomplish that goal?
2) Embedded in the XML script are DOS file paths with back slash separation. When we save the query result, we end up with double back slashes because Mysql uses the back slash as the esc char. Is it possible to get a single back slash w/o needing to externally edit the file?
Thanks for any suggestions!
|
|
|
|
|
Hi all..
i want to know how to take a backup for database in sql server.
thanks in advance..
siri
|
|
|
|
|
|
Hi
friends
I want to select two date from sys.
1st date is 1-April-2007
where Day 1st= is fixed
Month April is also fixed
But Year 2007 is the current year-1
and the 2nd date is 31-Dec-2007
where day 31st/30th/28th/29th is the last day of the previous month.means current month -1
and Year 2007=Current year-1 for the month of January and for the other months its fixed that is 2008 menas
the current year.
well i am using SQL SERVER 2005.pLZ help me out.
|
|
|
|
|
I think this will do it - it looks a bit horrendous and I'm sure there must be an easier way
declare @start datetime, @end datetime, @month varchar(10)<br />
<br />
set @month = 'feb'<br />
<br />
select @start = convert(datetime, '01-Apr-' + convert(varchar,datepart(year,dateadd(year,-1,getdate()))))<br />
select @start<br />
<br />
select @end = convert(datetime,dateadd(day,-1,dateadd(year,1,convert(datetime, '01-' + @month + convert(varchar,datepart(year,dateadd(year,-1,getdate())))))))<br />
select @end
Bob
Ashfield Consultants Ltd
|
|
|
|
|
If we delete or update a row in a table; the no of changed row shows as n rows affect.
Here is the example.
Ex: update TableName set Column1='N' where Column2=2
Output: 4 rows affected
In this i need to get the value 4. How to fetch that value.
Can anyone help me out
Regards,
LEE
|
|
|
|
|
In SQL Server you can get this value by using the global variable @@rowcount . The variable contains data about the number of rows affected by a sql statement and is updated each time you run a statement.
|
|
|
|
|
Hi i have a doubt,.
I have a view with two colums from table1, two columns from table2,
if i changed the data in view then updation occurs in both tables are not?
Another doubt..
If i combine two tables data in to one view...
how much space it takes.. suppose table1 takes 2kb, table2 takes 4kb
then view takes 6b or less ?
G. Satish
|
|
|
|
|
Satish - Developer wrote: if i changed the data in view then updation occurs in both tables are not?
Nope. To do that, you need to have an 'instead of' trigger on your view.
Satish - Developer wrote: If i combine two tables data in to one view...
how much space it takes
Theoretically, a view does not occupy storage space, except for the view definition stored in one of the system tables. When you query your view, it'll run the select query present in it's definition and return the result set.
SG
Cause is effect concealed. Effect is cause revealed.
modified on Thursday, January 31, 2008 7:44:10 AM
|
|
|
|
|
hi everybody
i am using sql 2000 server and facing syntax error.
plz correct and reply.
query is below but that is script of sql 2005 and i am using this on sql 2000
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ProductCategory]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ProductCategory](
[ProductCategoryID] [int] IDENTITY(1,1) NOT NULL,
[ProductCategoryName] [text] NOT NULL,
CONSTRAINT [PK_ProductCategory] PRIMARY KEY CLUSTERED
(
[ProductCategoryID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
GO
rajeev kumar sharma
vri software pvt. ltd.
new delhi India
modified on Thursday, January 31, 2008 2:06:42 AM
|
|
|
|
|
RajeevKumarSharma wrote: i am using sql 2000 server and facing syntax error.
What is the error? Did you check what the error message means before posting?
If you can't be bothered to do a little investigation yourself, I can't be bothered to help you
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
i tryed to solve that but i am unable to solve that
problem is
Server: Msg 170, Level 15, State 1, Line 9
Line 9: Incorrect syntax near '('.
Rajeev Kr. Sharma
VRI Software Pvt.Ltd.
New Delhi India
HumOnline.com
Stay Connected
|
|
|
|
|
Hi Friends,
I was running following command in SQL Server 2005.But,it was not worked. The command is,
"ALTER DATABASE [mydatabase name]
SET AUTO_SHRINK ON WITH NO_WAIT;"
Is this correct , i was using in sql server? Please suggest me. The following syntax using for auto shrink database log.
ALTER DATABASE database
SET optionspec [ ,...n ] [ WITH termination ] [;]
optionspec:
AUTO_SHRINK {ON | OFF}
Termination:
ROLLBACK AFTER integer [SECONDS]
ROLLBACK IMMEDIATE
NO_WAIT
My problem is, i have shrink my database transaction log every time by manually. So, i was using above auto shrink command.
Thanks in advance,
Rameshkumar Thirumalaisamy
modified on Thursday, January 31, 2008 7:31:20 AM
|
|
|
|
|
Does anyone know hot to import data from a spreadsheet into sql server table.
Many thanks
|
|
|
|
|
solarthur01 wrote: Does anyone know hot to import data from a spreadsheet into sql server table.
Yes.
Did you try searching for a solution yourself before you posted? A quick search on Google will give you plenty of information.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
|
Hello
Does anyone know how to get child rows of a row as a string?
I mean, lets say that i have 3 tables:
Students, Courses, and Student_Courses to track the courses that each student is taking
Each student can take many courses at the same time
What i want to retrive is:
Column 1 Column2
Alex 'Course1, Course2, Course3, Course6'
Alexei 'Course3, Course6'
Alexa 'Course2, Course3, Course6'
I dont want to use cursors and i would prefer to do this in SQL server
Im only wondering if SQL has a intruction to acomplish this or if anyone knows an easy way to do this
Thanks for your time
Alexei Rodriguez
|
|
|
|
|
AlexeiXX3 wrote: Does anyone know how to get child rows of a row as a string?
Check out this article[^].
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Alexei
Try this:
<br />
create table student (StudentID int, Name varchar(50))<br />
create table student_course (StudentID int, CourseID int)<br />
create table course (CourseID int, Name varchar(50))<br />
<br />
insert into student select 1,'Fred'<br />
insert into student select 2,'Joe'<br />
insert into student select 3,'Mary'<br />
<br />
insert into course select 1,'Maths'<br />
insert into course select 2,'Cooking'<br />
insert into course select 3,'Languages'<br />
<br />
insert into student_course select 1,1<br />
insert into student_course select 1,3<br />
insert into student_course select 2,1<br />
insert into student_course select 3,1<br />
insert into student_course select 3,2<br />
insert into student_course select 3,3<br />
<br />
go<br />
<br />
<br />
CREATE FUNCTION dbo.udf_GetStudentCourses(@StudentID int)<br />
RETURNS VARCHAR(1000) AS<br />
<br />
BEGIN<br />
DECLARE @CourseList varchar(1000)<br />
<br />
SELECT @CourseList = COALESCE(@CourseList + ', ', '') + c.Name<br />
FROM Student_Course s, Course c<br />
WHERE s.StudentID = @StudentID<br />
and c.CourseID = s.CourseID<br />
<br />
RETURN @CourseList<br />
END<br />
go<br />
<br />
<br />
select Name,dbo.udf_GetStudentCourses(StudentID)<br />
from Student
Results:
Fred Maths, Languages
Joe Maths
Mary Maths, Cooking, Languages
Bob
Ashfield Consultants Ltd
|
|
|
|