• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 287
  • Last Modified:

String Manipulation in SQL Server

In reference to the code below, I am trying to find the GroupDescription 'Test: New Members 07/09/2009'.  The reason the @strDate variable was introduced was to allow for different dates to be entered.

When I run the query below however it returns no results yet when I run for the literal Group Description of  'Test: New Members 07/09/2009' it returns one row.

Can you help me correct this.
declare @studyID int
declare @studyGroupID int
declare @strDate varchar
/** Set studyID **/
set @studyID = 7
set @strDate = '07/09/2009' 
select @studyGroupID = StudyGroupID
from StudyGroups (nolock)
where GroupDescription = 'Test: New Members ' + @strDate
and StudyID = @studyID

Open in new window

  • 2
1 Solution
Guy Hengel [angelIII / a3]Billing EngineerCommented:
>declare @strDate varchar
must be
declare @strDate varchar(20)
Guy Hengel [angelIII / a3]Billing EngineerCommented:
declare @strDate varchar
is the same as
declare @strDate varchar(1)
onaled777Author Commented:
Ahh Thank you!  I understand completely and it works.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now