|
If joinDate is a DateTime type, then this should work:
joinDate >= CONVERT(DATETIME, '01.01.2009', 104)
This is fully documented in the SQL Server documentation, which is all available on line.
|
|
|
|
|
oh really thanks David
its great
Syed Shahid Hussain
|
|
|
|
|
Parse the strings to DateTime and use a parameterized query.
|
|
|
|
|
thanks
Syed Shahid Hussain
|
|
|
|
|
Hi,
I am using SQl 2005 for setting up a job which has 2 steps:-
Step 1: Executes a SP which sends out result to a file
Type : T-SQL
Command :
DECLARE @cmd varchar(2000),
SET @cmd = 'osql -E -S CONDOR -s";" -w2000 -d Arion -Q"EXEC dbo.ENRSP_Applicants" -o D:\Applicants.txt'
EXEC master..xp_cmdshell @cmd
Step 2: Mailing the txt file to the user
Type : Operating System(CmdExec)
Command :
"D:\MSSQL\JOBS\EmailFile.cmd" D:\Applicants.txt aa@yahoo.com ss@yahoo.com "Applicants Report"
This works fine but the user want some modification to the current Job
* the email subject to include the date also
* Wants the result set to be dumped into a CSV file and to attach the file to the mail
* Can you also tell me how to include a message to the mail plz?
I know its easy to get this all done using a SSIS but Can these be done using an SQL Job , if so can you plz help me with it?
Thanks in advance.
Warm regards,
Payal
modified on Thursday, September 24, 2009 11:10 PM
|
|
|
|
|
I have a SQL 2005 database and a SQL 2008 database. I want a simple SQL statement that will create/copy a table and its contents from 2005 into 2008 that I can use in a C# program. I know I can export using Mgmt Studio but I want to do in a a program. I am able to perform a SELECT INTO [MyDatabase2].[dbo].[mytable] SELECT * FROM [Mydatabase1].[dbo].[mytable] when they exist in different databases in the same machine and only in the same Database Instance but how do I across multiple instances or multiple machines.
Can anyone help ?
Thanks
|
|
|
|
|
Use this to connect to other server
EXEC sp_addlinkedsrvlogin 'server', 'false', 'userLocal', 'userRemote', 'remotePassword'
Code should look like this:
SELECT INTO [server].[MyDatabase2].[dbo].[mytable] FROM [Mydatabase1].[dbo].[mytable]
modified on Friday, September 25, 2009 2:06 AM
|
|
|
|
|
Blikkies,
Thanks for the info. Just a couple follow up questions.
So on the 2005 SQLExpress Server I have an instance of SQLEXPRESS and on 2008 SQL I have an DB instance of MY2008DB I would do the following if I am running on the 2008 system.
EXEC sp_addlinkedsrvlogin '\\MY2005Server\SQLEXPRESS', 'false', 'sa', 'sa', 'sa'
SELECT INTO [MyDatabase2].[dbo].[mytable] FROM [\\MY2005Server\SQLEXPRESS].[Mydatabase1].[dbo].[mytable]
and if I was running this on the 2005 server it would be the opposite ?
EXEC sp_addlinkedsrvlogin '\\MY2008Server\MY2008DB', 'false', 'sa', 'sa', 'sa'
SELECT INTO [\\MY2008Server\MY2008DB].[MyDatabase2].[dbo].[mytable] FROM [Mydatabase1].[dbo].[mytable]
Or how does that work with the DB Instance name ?
thanks
|
|
|
|
|
Hi everyone,
I have a table with 4 columns = "Name", "Age", "Place","Salary".
I want to display only "Name" and "Age" column with entries in Datagridview in my Form.
Cany anyone please tell me how to do this?
|
|
|
|
|
I'll assume you're using VB.NET or something similar...
If you don't want to show certain columns, simply don't show them. This may entail turning off auto-generate columns in your grid and adding in your own custom column definitions (lots of examples of grids can be found on Google.)
The other alternative is to make your datasource come from a query or view rather than grabbing the whole table.
-Dave
|
|
|
|
|
simple just do it
gv.Cloumns["YourColumnsName4hide"].Visible = False
that's it
Syed Shahid Hussain
|
|
|
|
|
I can't seem to find any way to backup my database on another server every hour or so.
Is there a way to do that? I'm using sql server 2005 express edition.
|
|
|
|
|
Why dont you use Windows Service to create backups. Generally Backup doesnt take network paths. so it is better to do this in your own server in a specific folder and a service will move the file from the place to where you want.
|
|
|
|
|
You can even do what abishek said, with a simple batch file, and a scheduled task.
My advice is free, and you may get what you paid for.
|
|
|
|
|
Hi Experts,
We have created an application in ASP.Net 2.0 and with MySQL 5.0.67 as Backend. The application was running great from months, but recently we have discovered that there is a performance degrades in the database. Actually database was designed by one of my colleague how didn’t have much of database background so database design is not a professional one. I would also like to mention that this is my first Project on MySQL. I have worked on SQL Server till now. When I started analyzing the database I found indexing was missing in the tables. Introduction of Indexes has improved the performance somewhat. Can any one please tell me what else can I do to improve the performance.
Please help me its urgent
Thanks and Regards,
Paramhans Dubey
|
|
|
|
|
Paramhans Dubey wrote: didn’t have much of database background so database design is not a professional one
So the design may be wrong to start with
Paramhans Dubey wrote: indexing was missing in the tables
Another sign that he didn't know ehat he was doing
Paramhans Dubey wrote: Please help me its urgent
Do what you should have done in the first place, employ someone who knows what they are doing. Without the schema, useage, etc its impossible to say what should be done anyway.
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
Hi
Thanks for your reply and suggestion. We are in process to recruitin someone who knows the job, but meanwhile we just cant sit and wait for him to join and do the job. Anyways I was going through one article where I came to know about Table Engines and their usage. I also came to know there Using MyISAM table engine can improve the read perfomance of the tables but the author also wrote that Your tables will get corrupted eventually but there was no explaination about how and why it happens?
I fyou know the reason then kindly tell me
Thanks and Regards,
Paramhans Dubey.
|
|
|
|
|
OK, so your DB started performing poorly after it ran for awhile....that's a pretty broad problem, but here's a few things you might try:
1) I fully agree with Bob's post - if you want it to work correctly, get someone who knows what they're doing to set things up properly. (Though I understand that doesn't fix your problem today.)
2) Check for any tables that have grown excessively large. It's possible that you have some large logging / history tables and such that can easily be archived and deleted from the working tables.
3) If there's any way to narrow your problem down to a few areas (perhaps the top 2 or 3 stored procedures you're having trouble with?) you can look at modifying indexes specifically to help with those queries - just be sure you don't replace one problem with another.
4) You could always throw more hardware at it for a temporary fix...
If you have any more specifics about what the problem is, perhaps we could better help.
-Dave
|
|
|
|
|
Here's the short question - how can I make this work?
create function callme()
returns TABLE AS
RETURN(exec MyExistingSP)
And the longer question on why I'd want it to...
* I've got several stored procs that return table result sets that are fairly large (or larger than I care to scroll through)
* Often, I'm doing ad-hoc queries where I only want to see one or two rows returned by the stored proc.
* If I need to whip up a function/stored proc to allow this, it would be handy if it would take the stored proc name as a parameter
* Would also be nice to take a subset of the column list in a select, or add an order by
* I'm most interested in SQL Server 2000+
* Performance is not an issue (within some reason...), as this is only for typed in ad-hoc queries
select column1, column2
from callme('MySP')
where id > 500
order by LastModified --> would be nice to see the subset...
I can do this easily with a multiline function for each stored proc, but it's not worth that much work. I keep hoping there's just a twist of syntax I'm missing, but I'm afraid that's not the case...
Any thoughts?
Thanks,
Dave
|
|
|
|
|
And one other gotcha....OPENROWSET() isn't enabled on some servers I have to work with...
-Dave
|
|
|
|
|
Dave2909 wrote: create function callme()
returns TABLE AS
RETURN(exec MyExistingSP)
You can't do this -
1. You can't call a proc from a function
2. You can't pipe the output from a proc into a table
Regarding only getting the first few rows, try
SET ROWCOUNT 10
exec sproc
SET ROWCOUNT 0
This will just return the 1st 10 rows.
As for the rest of it, the only way to do it would be some pretty complex dynamic sql.
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
Thanks, Bob...just wish there was a different answer.
The more I think about this though, it just seems that there really should be some way to do a sub-query against a stored proc's result set from SQL Server management studio without having to define specific tables, or do anything funky like parsing the SP to auto-create a result table. Perhaps I just need to add this into a feature request for MS.
Just in case...anyone else have a suggestion on how to narrow down the results of a stored proc from within Management studio? Something like being able to run a query against the results window sure would be handy.
Thanks,
Dave
|
|
|
|
|
I got the SQL Azure Service up and running. It is running of the hosted server
MyCloud Service
While working on this app, I found some interesting things. Here is a short summary
1. select * from sys.objects IS YOUR NEW OBJECT BROWSER
2. truncate table tablename will not work in SQL Azure - yes,drop and delete does work.
3. select @@servername will not work but select @@version does work
4. DO NOT TRY exec sp_help and exec sp_who – it will not work
5.Insert WILL NOT WORK if you forget to add a primary key on your table - For example
create table test
(
my_id int,
my_name varchar(10)
)
insert into test values (1,'abhi')
and you will get an error –“ Heaps can not be replicated tables. Please create a clustered index for the table.” . Just add a PK on my_id and things will work as expected
6. Migrating data from your local DB to the cloud is not easy - check out http://www.stephenforte.net
7. Copy connection string from your https://sql.azure.com/ServerInfo.aspx page - this is the easiest and fastest way to connect your app with SQL Azure
abhi
Zimbatech Solutions
|
|
|
|
|
How we can handle mails using trigger if exchange server is down. i Am sending mail on insert of any record in table through trigger. But if exchange server is down how we can handle mails.
|
|
|
|
|
We solved this problem, by sending emails through an application.
The application will try to send the email as usual, but in case the exchange server is down, or the email can not be sent for some other reason, all relevant data (addresses, message body, etc.) is stored into a database table instead.
Another application then checks the table periodically, and will attempt to send any message there. If sending is successful the app will flag the message as sent.
My advice is free, and you may get what you paid for.
|
|
|
|