Solved

tsql parameter question

Posted on 2011-09-29
3
232 Views
Last Modified: 2012-05-12
I have a stored proc that accepts a number of parameters including 3 datetime parameters.

I'm trying to run this inside the query analyzer. When I pass in the datetime as a string I get a conversion error.  What is the correct way to do this? It is sql server 2005.

exec DrFirst.usp_insPrescriptions 
'BB-17450275',
'11291',
'MSNTN',
'kstepniakowski',
'Wal-Mart Pharmacy 91',
'diltiazem HCl',
'diltiazem HCl',
'n',
'180 mg',
'1',
'twice a day',
'30',
'60',
'4',
'',
'',
'3/29/2011 12:51:12 PM',
'3/29/2011 12:51:12 PM',
'sent,signed',
'fax',
'9/28/2011 3:45:21 PM',
0,
'y',
'',
'mewart'

Open in new window

0
Comment
Question by:rutledgj
3 Comments
 
LVL 33

Accepted Solution

by:
knightEknight earned 125 total points
ID: 36815093
If you can control the format of the string, I suggest this:

'2011-09-28 15:45:21'
0
 
LVL 92

Assisted Solution

by:Patrick Matthews
Patrick Matthews earned 125 total points
ID: 36815113
That should be OK, although I would recommend an ISO-style format.  For example, instead of:

'9/28/2011 3:45:21 PM'

I would use:

'2011-09-28 15:45:21'

That said, are you positive that you entered your parameters in the correct order?
0
 

Author Closing Comment

by:rutledgj
ID: 36815128
my goof. I was missing a param.
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
I have a large data set and a SSIS package. How can I load this file in multi threading?
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question