473,379 Members | 1,520 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

string vs varchar

I dont know why my procedure doesnt work:

SET @fDate = CONVERT(DATE,CAST(@year AS VARCHAR(25)) +'/'+ @month + '/01',111)
SET @lDate = CONVERT(DATE,CAST(@year AS VARCHAR(25)) +'/' + @month + '/' + CAST(dbo.DaysInMonth(@fDate) AS VARCHAR(25)),111)

INSERT @TempTable --@TempTable is created inside procedure
SELECT Supplier, SUM(Total) AS Quantity, Monthly
FROM
(
SELECT Supplier, Quantity AS Total, DATEPART(mm,CONVERT(DateTime,i.Date,103)) AS Monthly
FROM Imports AS i
WHERE (i.Product like N'%'+@productName+'%')
AND (i.Industry like N'%'+@industry+'%')
AND CONVERT(DateTime, i.Date, 103) >= @fDate
AND CONVERT(DateTime, i.Date, 103) <= @lDate
) AS tmp
GROUP BY Supplier, Monthly

If i run it directly from Studio Management, it works fine. However, if i call the procedure from Visual Studio 2010,the procedure returns nothing. The weird thing is that if i replace:
CONVERT(DATE,CAST(@year AS VARCHAR(25)) +'/'+ @month + '/01',111) by CONVERT(DATE, '2011/' + @month +'/01', 111) then procedure returns correct result. @year is of type INT. When i step debug procedure, and check for @year value, its value is correctly passed. So i come to conclude:
CAST(@year AS VARCHAR(25) != '2011' if @year = 2011. is it weird?
Jan 10 '12 #1
0 1248

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Piet | last post by:
Hello, I have a very strange problem with regular expressions. The problem consists of analyzing the properties of columns of a MySQL database. When I request the column type, I get back a string...
3
by: Alex Ayzin | last post by:
Hi, I have a column in my WinGrid, that's being populated with numeric data, but it's of String datatype(business rule requires to have these numbers as varchars in DB). On top of that, I need...
0
by: ST | last post by:
Hello, I will be posting 2 errors that I just can't seem to figure out (I'll put them in different posts). I have looked all over the internet, and I still can't figure these out! This webapp was...
2
by: HumanJHawkins | last post by:
The following query works perfectly (returning all words on a list called "Dolch" that do not contain a form of "doing"): SELECT 'Dolch' AS , dbo.Dolch.vchWord FROM dbo.Dolch LEFT OUTER JOIN...
2
by: roopeman | last post by:
i need your help, my code as below : //----------------------------------------------------------------------- //Wrote by Michael April 30 2005...
16
by: Mark A. Sam | last post by:
Hello, I am having a problem with imputting into a string variable: Dim strSQL As String = "INSERT INTO tblContactForm1 (txtName, txtCompany, txtPhone, txtEmail, txtComment, chkGrower,...
15
by: angellian | last post by:
Sorry to raise a stupid question but I tried many methods which did work. how can I conserve the initial zero when I try to convert STR(06) into string in SQL statment? It always gives me 6...
4
by: Brian Parker | last post by:
I've been banging my head on this for hours and it's something that should be very very easy. I have a Stored Procedure in a MS-SQL 2000 server that returns a Varchar(40) and I want to grab that...
0
by: weird0 | last post by:
Here is the code for executing stored procedure ExecuteSP() , and object that sets all its parameters in other functions and the stored procedure. I think it has something to do with db datatypes...
1
by: mshemalatha | last post by:
Hi, String(Varchar) ID generation in Sql Server 2005 & NET for example ABC01,ABC02... and another example IN01,DN02,AM03,PK04,CN05,
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.