MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 9th, 2008, 10:39 AM
swimlikehell swimlikehell is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2008
Posts: 35 swimlikehell User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 51 sec
Reputation Power: 1
Problem with a stored procedure

I am using a stored procedure and executing it from a string, to make it easy to modify. I am passing is a select as varchar(max) as well as a date as datetime, when I rune my execute(sp); I get an error "Conversion failed when converting datetime from character string.". if anyone has any suggestions they will be much appreciated, thanks.

Reply With Quote
  #2  
Old July 9th, 2008, 10:47 AM
MrFujin's Avatar
MrFujin MrFujin is online now
Lord of the Dance
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Oct 2003
Posts: 1,228 MrFujin User rank is Major (30000 - 40000 Reputation Level)MrFujin User rank is Major (30000 - 40000 Reputation Level)MrFujin User rank is Major (30000 - 40000 Reputation Level)MrFujin User rank is Major (30000 - 40000 Reputation Level)MrFujin User rank is Major (30000 - 40000 Reputation Level)MrFujin User rank is Major (30000 - 40000 Reputation Level)MrFujin User rank is Major (30000 - 40000 Reputation Level)MrFujin User rank is Major (30000 - 40000 Reputation Level)MrFujin User rank is Major (30000 - 40000 Reputation Level)MrFujin User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 5 Days 22 h 45 m 10 sec
Reputation Power: 335
can you post your stored procedure? please also post how and where you call it?

this will make it easier to help you.

Reply With Quote
  #3  
Old July 10th, 2008, 09:01 AM
swimlikehell swimlikehell is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2008
Posts: 35 swimlikehell User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 51 sec
Reputation Power: 1
I figured out what I needed to do:

Code:
'query . . . WHERE (date = ''' + cast(@today as nvarchar(50)) + ''') . . . query continued'.


thanks for your help.

Reply With Quote
  #4  
Old July 10th, 2008, 09:36 AM
NimirRamon NimirRamon is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2008
Posts: 21 NimirRamon User rank is Sergeant (500 - 2000 Reputation Level)NimirRamon User rank is Sergeant (500 - 2000 Reputation Level)NimirRamon User rank is Sergeant (500 - 2000 Reputation Level)NimirRamon User rank is Sergeant (500 - 2000 Reputation Level)NimirRamon User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 15 h 59 m 47 sec
Reputation Power: 0
Check what your default DateFormat is

My Server defaults to American style mm/dd/yyyy, but I typically write the UK dd/mm/yyyy so when using strings as dates I often get the conversion error.

I have to put SET DATEFORMAT DMY somewhere before the command using the date (ie at the start of the stored procedures).

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Problem with a stored procedure


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway