Results 1 to 12 of 12
  1. #1
    Join Date
    Jun 2007
    Posts
    2

    Question Unanswered: dynamic column name (using where)

    Hello All,

    I'm trying to us a parameter as column name like:

    Select * From SM_Clients
    where @Selection like @SelectionChar+'%'

    This dos not work.

    does someone have a solution

    tks stroek

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    I wanted a read but that website is blocked
    Your request was denied because of its content categorization: "Personal Web Sites;Society and Lifestyles"
    George
    Home | Blog

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    yikes, george, yikes

    then again, you do have a tendency to mess about when you should be working, and if others in your company are the same, then no wonder they've put controls on you...

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Quote Originally Posted by r937
    then again, you do have a tendency to mess about when you should be working
    How very dare you!
    George
    Home | Blog

  6. #6
    Join Date
    Jun 2007
    Posts
    2
    Sorry but I didn't find any simple solution for my problem.
    Is there no one that can give me a simple solution???

    Gr stroek

  7. #7
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Code:
    DECLARE @s varchar(150)
    
    SET @s = 'Select * From SM_Clients where '
    SET @s = @s + @Selection
    SET @s = @s + ' like '''
    SET @s = @s + @SelectionChar
    SET @s = @s + '%'''
    
    EXEC (@s)
    ???
    George
    Home | Blog

  8. #8
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    Yeah, my work wouldn't consider time spent here to be "messing about"
    Inspiration Through Fermentation

  9. #9
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Mine either - an invaluable learning resource.
    You only get out what you put in
    George
    Home | Blog

  10. #10
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    i would've said skiving, but the rest of you lot would've thought i'd gone barmy
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  11. #11
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    I'm ahead of schedule on my projects and I consider this a constructive use of my time
    I think I've learnt more from these forums than I have from all the courses I have been on combined.
    Furthermore; learning by doing is also a much more effective way of learning imo.
    George
    Home | Blog

  12. #12
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    Unfortunately, I was being sarcastic. Spending a few hours of my work day giving support to others outside of the company (as I've done here in the past) would be severely frowned upon.
    Inspiration Through Fermentation

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •