Solved

tsql parameter question

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sql select record as one long string 21 24
Update a text value in another table 10 40
ms sql + get number in list out of total 7 29
SQL Count issue 24 16
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
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.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

773 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