Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

tsql parameter question

Posted on 2011-09-29
3
Medium Priority
?
244 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 33

Accepted Solution

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

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

Assisted Solution

by:Patrick Matthews
Patrick Matthews earned 500 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

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

597 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