Solved

tsql parameter question

Posted on 2011-09-29
3
223 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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Join & Write a Comment

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
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.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how the fundamental information of how to create a table.

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now