Wednesday, March 28, 2012
Running a proc. on a certain date help?
DECLARE @.query varchar(8000)
--Looking at current date,
SELECT @.returnDay = DatePart(day,GetDate())
If @.returnDay = 3
SELECT @.query = 'bcp "SELECT a.HospitalName,a.HospitalCode,c.ProductName,b.Unit sDiscarded,b.DateEntered,b.DateCompleted,b.Compile dBy FROM Ivana_test.dbo.Units b INNER JOIN Ivana_test.dbo.Hospitals a ON (a.HospitalID = b.HospitalID)INNER JOIN Ivana_test.dbo.Products c ON (b.ProductID = c.ProductID)INNER JOIN Ivana_test.dbo.FateOfProducts d ON (d.FateID = b.FateID)ORDER BY a.HospitalID" queryout c:\test.txt -c -Sserver -Usa -Ptest
EXEC master.dbo.xp_cmdshell @.query
EXEC master.dbo.xp_sendmail @.recipients='test@.hotmail.com',
@.copy_recipients = 'test@.hotmail.com',
@.message='Submitting Results for the previous month.',
@.subject='BloodBank results for the previous month',@.attachments = '\\cen\c$\test.txt'
SELECT @.@.ERROR As ErrorNumber
I am trying to get this procedure to execute every month on the 4th of the month but if I run it today, or tomorrow it or any day it still runs,therefore the not looking at the date.
Is this correct,can this be done in this way,how can I get it to run when it recognizes the date number in the current dateUse SQL Agent (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/architec/8_ar_cs_6x0l.asp) to schedule it ?
-PatP|||DECLARE @.returnDay int
DECLARE @.query varchar(8000)
--Looking at current date,
SELECT @.returnDay = day(GetDate())
If @.returnDay = 3
begin
SELECT @.query = 'bcp "SELECT a.HospitalName,a.HospitalCode,c.ProductName,b.Unit sDiscarded,b.DateEntered,b.DateCompleted,b.Compile dBy FROM Ivana_test.dbo.Units b INNER JOIN Ivana_test.dbo.Hospitals a ON (a.HospitalID = b.HospitalID)INNER JOIN Ivana_test.dbo.Products c ON (b.ProductID = c.ProductID)INNER JOIN Ivana_test.dbo.FateOfProducts d ON (d.FateID = b.FateID)ORDER BY a.HospitalID" queryout c:\test.txt -c -Sserver -Usa -Ptest
EXEC master.dbo.xp_cmdshell @.query
EXEC master.dbo.xp_sendmail @.recipients='test@.hotmail.com',
@.copy_recipients = 'test@.hotmail.com',
@.message='Submitting Results for the previous month.',
@.subject='BloodBank results for the previous month',@.attachments = '\\cen\c$\test.txt'
SELECT @.@.ERROR As ErrorNumber
endsql
Monday, March 26, 2012
Running a LIKE statement when searching for a date field...
I am trying to run a like statement that has a datetime column and for some reason it does not return any values. I looked in the SQL help files and in states in there that when trying to select using a datetime that the preferred way of doing it is using a like statment. Does anybody know a better way of doing this? Here is my example: (I have dates in this column ie 2006-02-13 11:30:54.220)
SELECT * FROM workorderhistory WHERE wheninstalled LIKE '%2006-02%'
Where did you find that preferred way to compare dates is LIKE. You might want to use many date functions to compare dates available in 2k and 2k5.
OR if you incist on using LIKE convert "wheninstalled" to format that you specify in LIKE.
|||datetime is stored in database in an internal format. It is not in YYYY-MM-DD or whatsoever format.>> I have dates in this column ie 2006-02-13 11:30:54.220
This just how Query Analyser represent the date or format the date and time when it return the records.
>> SELECT * FROM workorderhistory WHERE wheninstalled LIKE '%2006-02%'
To retireve records for month of Feb 2006,
SELECT * FROM workorderhistory WHERE wheninstalled >= '2006-02-01' and wheninstalled < '2006-03-01'
|||
Here is the text from the sql help file.
It is recommended that LIKE be used when you search for datetime values, because datetime entries can contain a variety of dateparts. For example, if you insert the value 19981231 9:20 into a column named arrival_time, the clause WHERE arrival_time = 9:20 cannot find an exact match for the 9:20 string because SQL Server converts it to Jan 1, 1900 9:20AM. A match is found, however, by the clause WHERE arrival_time LIKE '%9:20%'.
Thanks for your help.
|||Thanks for the help... I don't konw why I did not think of doing it that way... Slipped my mind I guess.|||try this may be helpful for you
SELECT * FROM
WHERE (CAST(FLOOR(CAST([date] AS FLOAT)) AS DATETIME) = '3/14/2006')
How can I use a like statement in there. I tried doing
select * from workorderhistory where (CAST(FLOOR(CAST([date] AS FLOAT)) AS DATETIME) like '03/%') and this did not work. Basically I want to see all the workorders that were installed in the month of march.
Running a LIKE statement when searching for a date field...
I am trying to run a like statement that has a datetime column and for some reason it does not return any values. I looked in the SQL help files and in states in there that when trying to select using a datetime that the preferred way of doing it is using a like statment. Does anybody know a better way of doing this? Here is my example: (I have dates in this column ie 2006-02-13 11:30:54.220)
SELECT * FROM workorderhistory WHERE wheninstalled LIKE '%2006-02%'
Where did you find that preferred way to compare dates is LIKE. You might want to use many date functions to compare dates available in 2k and 2k5.
OR if you incist on using LIKE convert "wheninstalled" to format that you specify in LIKE.
|||datetime is stored in database in an internal format. It is not in YYYY-MM-DD or whatsoever format.>> I have dates in this column ie 2006-02-13 11:30:54.220
This just how Query Analyser represent the date or format the date and time when it return the records.
>> SELECT * FROM workorderhistory WHERE wheninstalled LIKE '%2006-02%'
To retireve records for month of Feb 2006,
SELECT * FROM workorderhistory WHERE wheninstalled >= '2006-02-01' and wheninstalled < '2006-03-01'
|||
Here is the text from the sql help file.
It is recommended that LIKE be used when you search for datetime values, because datetime entries can contain a variety of dateparts. For example, if you insert the value 19981231 9:20 into a column named arrival_time, the clause WHERE arrival_time = 9:20 cannot find an exact match for the 9:20 string because SQL Server converts it to Jan 1, 1900 9:20AM. A match is found, however, by the clause WHERE arrival_time LIKE '%9:20%'.
Thanks for your help.
|||Thanks for the help... I don't konw why I did not think of doing it that way... Slipped my mind I guess.|||try this may be helpful for you
SELECT * FROM
WHERE (CAST(FLOOR(CAST([date] AS FLOAT)) AS DATETIME) = '3/14/2006')
How can I use a like statement in there. I tried doing
select * from workorderhistory where (CAST(FLOOR(CAST([date] AS FLOAT)) AS DATETIME) like '03/%') and this did not work. Basically I want to see all the workorders that were installed in the month of march.
Friday, March 23, 2012
Running 64 Bit instance and 32 bit instance on Same Server
version of SQL 2005. My production server is a 64 bit version so I am still
maintaing the old server with the 32 bit for this ONE connectivity
requirement. The ODBC / OLEDB connector is used for a LINKED server to a
PROGRESS database.
Can I install the 32 BIT version of SQL on the same (64bit version of)
Windows Server 2003, and should I expect that the OEM ODBC driver would
function in the 32 bit instance as it does on the 32 bit Server?
--
Thanks~
JimDear Jim,
Thank you for posting here.
From your description, I understand that:
Your current ODBC connector is based on SQL Server 2005 32 bit; however
production server is a 64 bit version and you would like to know whether we
can install SQL Server 32bit on the 64 bit Windows Server 2003 and run both
64 bit and 32 bit SQL instances on it.
If I have misunderstood about your concern, feel free to let me know.
Windows Server 2003 64 bit Edition fully supports SQL Server 2005 32 bit
Editions. You can refer to the section "Operating System Requirements
(32-Bit)" of this article "Hardware and Software Requirements for
Installing SQL Server 2005":
http://msdn2.microsoft.com/en-us/library/ms143506.aspx
So, we are able to install the 32bit instance on the same 64 bit server. In
addition, we need to use "odbcad32.exe" on the 64bit system to configure
DSN for 32 bit driver. In most cases, the OEM ODBC connector should work in
this scenario. We can also contact the manufacturer of this ODBC connector
to confirm this.
If anything is unclear in my post, please don't hesitate to let me know.
Have a nice day!
Best regards,
Adams Qu
MCSE, MCDBA, MCTS
Microsoft Online Support
Microsoft Global Technical Support Center
Get Secure! - www.microsoft.com/security
=====================================================When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=====================================================This posting is provided "AS IS" with no warranties, and confers no rights.
| Thread-Topic: Running 64 Bit instance and 32 bit instance on Same Server
| thread-index: Acgb8YBLwppW8NlwQ/C3lA9P6QDrsQ==| X-WBNR-Posting-Host: 207.46.19.168
| From: =?Utf-8?B?QmlnSmltQ2FzaA==?= <Bigjimcash@.noemail.noemail>
| Subject: Running 64 Bit instance and 32 bit instance on Same Server
| Date: Wed, 31 Oct 2007 12:09:03 -0700
| Lines: 12
| Message-ID: <EDE96934-8B17-4CDA-90D4-64D64211C8CF@.microsoft.com>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.2992
| Newsgroups: microsoft.public.sqlserver.server
| Path: TK2MSFTNGHUB02.phx.gbl
| Xref: TK2MSFTNGHUB02.phx.gbl microsoft.public.sqlserver.server:29189
| NNTP-Posting-Host: tk2msftibfm01.phx.gbl 10.40.244.149
| X-Tomcat-NG: microsoft.public.sqlserver.server
|
| We are using an OEM ODBC connector that, to date, only works with the 32
bit
| version of SQL 2005. My production server is a 64 bit version so I am
still
| maintaing the old server with the 32 bit for this ONE connectivity
| requirement. The ODBC / OLEDB connector is used for a LINKED server to a
| PROGRESS database.
|
| Can I install the 32 BIT version of SQL on the same (64bit version of)
| Windows Server 2003, and should I expect that the OEM ODBC driver would
| function in the 32 bit instance as it does on the 32 bit Server?
| --
| Thanks~
| Jim
||||Dear Jim,
We wanted to see if the information provided was helpful. Please keep us
posted on your progress and let us know if you have any additional
questions or concerns.
We are looking forward to your response.
Have a nice day!
Best regards,
Adams Qu, MCSE, MCDBA, MCTS
Microsoft Online Support
Microsoft Global Technical Support Center
Get Secure! - www.microsoft.com/security
=====================================================When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=====================================================This posting is provided "AS IS" with no warranties, and confers no rights.
| X-Tomcat-ID: 54548849
| References: <EDE96934-8B17-4CDA-90D4-64D64211C8CF@.microsoft.com>
| MIME-Version: 1.0
| Content-Type: text/plain
| Content-Transfer-Encoding: 7bit
| From: v-adamqu@.online.microsoft.com (Adams Qu [MSFT])
| Organization: Microsoft
| Date: Thu, 01 Nov 2007 06:25:20 GMT
| Subject: RE: Running 64 Bit instance and 32 bit instance on Same Server
| X-Tomcat-NG: microsoft.public.sqlserver.server
| Message-ID: <7#wKAAFHIHA.4508@.TK2MSFTNGHUB02.phx.gbl>
| Newsgroups: microsoft.public.sqlserver.server
| Lines: 82
| Path: TK2MSFTNGHUB02.phx.gbl
| Xref: TK2MSFTNGHUB02.phx.gbl microsoft.public.sqlserver.server:29229
| NNTP-Posting-Host: tomcatimport2.phx.gbl 10.201.218.182
|
| Dear Jim,
|
| Thank you for posting here.
|
| From your description, I understand that:
|
| Your current ODBC connector is based on SQL Server 2005 32 bit; however
| production server is a 64 bit version and you would like to know whether
we
| can install SQL Server 32bit on the 64 bit Windows Server 2003 and run
both
| 64 bit and 32 bit SQL instances on it.
|
| If I have misunderstood about your concern, feel free to let me know.
|
| Windows Server 2003 64 bit Edition fully supports SQL Server 2005 32 bit
| Editions. You can refer to the section "Operating System Requirements
| (32-Bit)" of this article "Hardware and Software Requirements for
| Installing SQL Server 2005":
| http://msdn2.microsoft.com/en-us/library/ms143506.aspx
|
| So, we are able to install the 32bit instance on the same 64 bit server.
In
| addition, we need to use "odbcad32.exe" on the 64bit system to configure
| DSN for 32 bit driver. In most cases, the OEM ODBC connector should work
in
| this scenario. We can also contact the manufacturer of this ODBC
connector
| to confirm this.
|
| If anything is unclear in my post, please don't hesitate to let me know.
|
| Have a nice day!
|
| Best regards,
|
| Adams Qu
| MCSE, MCDBA, MCTS
| Microsoft Online Support
|
| Microsoft Global Technical Support Center
|
| Get Secure! - www.microsoft.com/security
| =====================================================| When responding to posts, please "Reply to Group" via your newsreader so
| that others may learn and benefit from your issue.
| =====================================================| This posting is provided "AS IS" with no warranties, and confers no
rights.
|
|
| --
| | Thread-Topic: Running 64 Bit instance and 32 bit instance on Same Server
| | thread-index: Acgb8YBLwppW8NlwQ/C3lA9P6QDrsQ==| | X-WBNR-Posting-Host: 207.46.19.168
| | From: =?Utf-8?B?QmlnSmltQ2FzaA==?= <Bigjimcash@.noemail.noemail>
| | Subject: Running 64 Bit instance and 32 bit instance on Same Server
| | Date: Wed, 31 Oct 2007 12:09:03 -0700
| | Lines: 12
| | Message-ID: <EDE96934-8B17-4CDA-90D4-64D64211C8CF@.microsoft.com>
| | MIME-Version: 1.0
| | Content-Type: text/plain;
| | charset="Utf-8"
| | Content-Transfer-Encoding: 7bit
| | X-Newsreader: Microsoft CDO for Windows 2000
| | Content-Class: urn:content-classes:message
| | Importance: normal
| | Priority: normal
| | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.2992
| | Newsgroups: microsoft.public.sqlserver.server
| | Path: TK2MSFTNGHUB02.phx.gbl
| | Xref: TK2MSFTNGHUB02.phx.gbl microsoft.public.sqlserver.server:29189
| | NNTP-Posting-Host: tk2msftibfm01.phx.gbl 10.40.244.149
| | X-Tomcat-NG: microsoft.public.sqlserver.server
| |
| | We are using an OEM ODBC connector that, to date, only works with the
32
| bit
| | version of SQL 2005. My production server is a 64 bit version so I am
| still
| | maintaing the old server with the 32 bit for this ONE connectivity
| | requirement. The ODBC / OLEDB connector is used for a LINKED server to
a
| | PROGRESS database.
| |
| | Can I install the 32 BIT version of SQL on the same (64bit version of)
| | Windows Server 2003, and should I expect that the OEM ODBC driver would
| | function in the 32 bit instance as it does on the 32 bit Server?
| | --
| | Thanks~
| | Jim
| |
|
|
Runniing Values in Charts
a running value and it will keep incrementing as the weeks progress.
If i use the same value for the chart it does not allow RunningValue for
scope Nothing. How do i do the equalant in a chart to xhow the cumulative by
week rather than just the week figures. ex:
Actual Cumulative
Week1 1000 1000
Week2 1500 2500
Week3 1000 3500
First column is
Sum(cdec( Fields!CURRENTANNUALPREMIUM.Value ))
second is
RunningValue(cdec( Fields!CURRENTANNUALPREMIUM.Value ), SUM, Nothing)
this works fine on table but not in chart. Please help me do cumulative charts
regards
GaneshSorry, RunningValue() in charts is not supported on RS 2000. It is supported
on RS 2005 though.
-- Robert
This posting is provided "AS IS" with no warranties, and confers no rights.
"Ganesh" <Ganesh@.discussions.microsoft.com> wrote in message
news:25E16A7D-A53D-4DFE-BD5E-4036A3C56EBD@.microsoft.com...
>I have a table which show the sales year to date by week. The sales amount
>is
> a running value and it will keep incrementing as the weeks progress.
> If i use the same value for the chart it does not allow RunningValue for
> scope Nothing. How do i do the equalant in a chart to xhow the cumulative
> by
> week rather than just the week figures. ex:
> Actual Cumulative
> Week1 1000 1000
> Week2 1500 2500
> Week3 1000 3500
> First column is
> Sum(cdec( Fields!CURRENTANNUALPREMIUM.Value ))
> second is
> RunningValue(cdec( Fields!CURRENTANNUALPREMIUM.Value ), SUM, Nothing)
> this works fine on table but not in chart. Please help me do cumulative
> charts
> regards
> Ganesh
Tuesday, March 20, 2012
Run report after parameter selected
My report has a Date parameter. Can the report be run automatically after the date is changed without clicking on View Report button?
Thanks
I don't think it can. The toolbar is generated by the reportserver and you can't hook into any events and there is no Autorun option to my knowledge.
The only hack I can think of is displaying the report in a custom page, view the source to find out the ids/names that RS assigns to your parameters and the name of the js function called when the "View Report" button is pressed. You then write some javascript that hooks into the onChage event of the dropdown and simulate the pressing of the button by calling the relevant function manually.
Like I said that is a real hack and is not likely to be very flexible but you could experiment. Eaither way you can't modify the Report Manager to do this you would have to write a custom page.
Monday, March 12, 2012
Run Job From TSQL
I need some help on this problem.
I create a job on SQL Agent, the job had schedule as selected date and time,
but I want to have a optional choise to user to allow them start the job at
the web page, so I try to create a store procedure to start the job and
return the outcome for the job (Fail or success). And I use
msdb.dbo.sp_start_job to start the job, now I face the problem how can I kno
w
the job are finished and after the job completed, I need to check the result
of the job. Can give me some idea, what should I do for this.
TQhi
probably you can have a log table. The jon logs the data into the table. and
you can read it from the web page of u can have ur sp return a value.
did this answer your question.
best Regards,
Chandra
http://chanduas.blogspot.com/
http://groups.msn.com/SQLResource/
---
"Judy" wrote:
> Dear All,
> I need some help on this problem.
> I create a job on SQL Agent, the job had schedule as selected date and tim
e,
> but I want to have a optional choise to user to allow them start the job a
t
> the web page, so I try to create a store procedure to start the job and
> return the outcome for the job (Fail or success). And I use
> msdb.dbo.sp_start_job to start the job, now I face the problem how can I k
now
> the job are finished and after the job completed, I need to check the resu
lt
> of the job. Can give me some idea, what should I do for this.
> TQ
>|||sp_hlep_job will give you the status and such but you will have to poll for
it periodically.
Andrew J. Kelly SQL MVP
"Judy" <Judy@.discussions.microsoft.com> wrote in message
news:97716C52-85C6-41F0-8BE8-EFB61EF3E0FD@.microsoft.com...
> Dear All,
> I need some help on this problem.
> I create a job on SQL Agent, the job had schedule as selected date and
> time,
> but I want to have a optional choise to user to allow them start the job
> at
> the web page, so I try to create a store procedure to start the job and
> return the outcome for the job (Fail or success). And I use
> msdb.dbo.sp_start_job to start the job, now I face the problem how can I
> know
> the job are finished and after the job completed, I need to check the
> result
> of the job. Can give me some idea, what should I do for this.
> TQ
>|||...or check out this article about how to use xp_sqlagent_enum_jobs to be a
ble to deal with the results since the results from sp_help_job cannot be in
serted into a table.
http://www.databasejournal.com/arti...10888_3491201_2
/Magnus