|
Luc Pattyn wrote: Hmm, I'm not familiar with triggers; the way I understand it, it causes some action to occur in the database, however I need other clients to get a notification (not just the one client that is causing the trigger to fire).
A trigger, traditionally, executes a piece of SQL when data is inserted/updated/deleted from a table. You can check *which* fields change in the trigger. MSDN has an example on a CLR Trigger[^] that uses pipes to communicate with the outside world. I'm not sure whether you can launch a socket from there, but once you can catch the change, you can inform your clients - one way or the other.
My client would then typically use the INotifyPropertyChanged interface to propagate changes.
Bastard Programmer from Hell
|
|
|
|
|
OK, I'll investigate how that works and fits with what I have already. Thanks again.
|
|
|
|
|
My pleasure, and thanks
|
|
|
|
|
I have to create a job that when a task is due the employee should get reminder notification 14 days before the due date and second notification before 3 days before the due date. how can i do this in SQL Server 2005
|
|
|
|
|
Create a job that checks the data store where the job is, compare the system date with the job due date, get the email address from the employee table and send the email using SQL mail.
The information about jobs can be found using sysobjects and the related sys% tables. You will need to do some research as to where it can be found. Employee information is your problem.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
In table i have column that is type of varchar(n), and it's not primary/foreign key.
Now, what I need is SQL query (stored procedure) that will select all the records in that table like:
(pseudo)
select * from table1 where SUBSTRING(table1.column2,1,2)<@param1 and SUBSTRING(table1.column2,1,2)>@param2
Parameters are first two letters of any record that contains data for that column.
if param1 is aa and param2 is cc then output should be all the records with first two letters like:
aa,ab,ac,...,az,ba,..,bz,ca,cb,cc
Any suggestions would be appreciated!
|
|
|
|
|
First off, I think you have your signs backward.
Other than that, have you tried it?
|
|
|
|
|
Already solved and you're right, in solution that is similar to pseudo code I posted, the signs were backward... but it was just a hint for possible solution that someone could offer. Thanks for your comment anyway, cheers
|
|
|
|
|
select * from table1 where SUBSTRING(table1.column2,1,2)
like '%@param1%'
or SUBSTRING(table1.column2,1,2)>'%@param2%'
use dynamic query
|
|
|
|
|
Hi folks,
I have a database in MS SQL Server which is accessed by an application I wrote. In other words, I have control over both the DB and the software. Things have grown so much now that I'm getting worried I might not have set up all the correct indexes in the DB to really optimise the queries.
I should probably sit down and go through all of my code to see what queries are being run against the DB and what indexes would optimise those queries but there is such a multitude of queries and it would be very difficult to determine which of these are run frequently and which of them only spradically.
Is there a tool that can monitor all the queries that are being run against the DB over a period of time and then analyze the shortcomings in the DB design? Somehow I recall having heard of such a tool but I've never used anyhting of the sort and don't really know where to start looking.
|
|
|
|
|
From the SQL Server Management Studio, under the Tools menu, you will find "SQL Server Profiler".
Use this tool to see exactly what SQL statements are being run, then take those statements and run them in the SQL Server Manager, and under the Query menu click on the "Include Actual Execution Plan".
After running the query it will show you whether or not an index is used, which tables (or indexes) are being scanned, etc.
Cool stuff.
Good luck.
|
|
|
|
|
Thanks a bunch, that looks like exactly the thing I was looking for. The reason I couldn't find it was because, on my machine, I have a SQL express version of the Management Studio from which the Profiler seems to be missing. When I work directly on the machine that runs SQL Server, it is there.
Now I need to figure out how to set up a trace and how to make it meaningful. But thanks, I've got something to work from now.
|
|
|
|
|
|
Hi everybody. I have a problem. I am trying to make a little social network. Users can add other users to own people list. So what should i do ? Should i create a new table for every user? ( for example 2000 table for 2000 users ) or should i create an array for every user ? After i can save the array to the database. or any other way ? whick way is the best ? İf array is the best , how can i do it ? first user have 2 friends , second user have 19 friend. array size is different.
So what should i do ?
|
|
|
|
|
This is a classic case of a Many to Many relationship and what you need to do is create a linking table. You have the original Users table with each user having a unique id UserID. Then you have another table call it Friends with only 2 fields UserID and FriendID. Each time a user adds a friend, you just add a row to the linking table, using the UserID of the Friend as the FriendID in the friends table, and if they remove the friend, you just drop the row.
Hope this makes sense.
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
this could work ! Thank you !
|
|
|
|
|
Glad to help
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
chuckcan08 wrote: this could will work
FTFY
|
|
|
|
|
Hello Experts,
I have 1 Lacs Records in Excel or XML. And i want to insert those records in Live Database in single Event.
So pls help me for this issue.
If you can think then I Can.
|
|
|
|
|
My advice would be to convert the excel/xml file to a csv file and then you can use LOAD DATA INFILE[^] syntax to upload the data. This will be much quicker than using a transaction and Insert statements, especially if you are creating indexes. See Speed of Insert Statements[^] to get an idea of what is involved.
Hope this helps
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
You know "Lacs" is not an English word... Always remember to say 100K or 100,000.
|
|
|
|
|
SilimSayo wrote: You know "Lacs" is not an English word
It is indeed an English word (although the spelling is not correct).
You meant it is not American, right?
|
|
|
|
|
|
Hi All,
Iam new to database. Here iam using sql server 2000. i want to sum the counts from a table. I need this to calculate the employees who have come late in a week/month.
Example: I have table such as
Table1:tbl_attandence(it contains the employee id and the intimings and outtime)
Fields:empcode,intime,outime
Eg: EMP001,11/1/2011 09:30:45 AM,11/30/2011 06:30:15 PM
I am attaching my code such that it return the count but iam unable to sum the values because it is showing the result as shown below
DECLARE @actualTime DATETIME
DECLARE @lateTime DATETIME
SELECT @actualTime = '9:41'
Select @lateTime ='10:00'
select count(convert(varchar,intime,105)) as dates,CONVERT(VARCHAR(5),intime,108) AS Hours from tbl_attendance
where empcode='EMP001';
and intime between '2011-11-01' and '2011-11-30'
and CONVERT(VARCHAR(5),intime,108) >=@actualTime and CONVERT(VARCHAR(5),intime,108) <= @lateTime
group by CONVERT(VARCHAR(5),intime,108)
OytPut:
days intime
1 09:41
1 09:44
1 09:46
2 09:53
1 09:54
Now i need to sum all the days and get the sum as 7
Please suggest that how can i do this task any help will be appreciated
|
|
|
|
|
Elizabeth Rani wrote: Now i need to sum all the days and get the sum as 7
Seems to add up to 6!
You can used compute after you query in the proc
compute sum(Days)
or put the existing query into another outer query
Select sum(days) from (put your query here)
Never underestimate the power of human stupidity
RAH
|
|
|
|