Click here to Skip to main content
15,895,799 members
Home / Discussions / Database
   

Database

 
GeneralRe: Union on a join Pin
jkirkerx6-May-15 11:40
professionaljkirkerx6-May-15 11:40 
GeneralRe: Union on a join Pin
jkirkerx7-May-15 12:24
professionaljkirkerx7-May-15 12:24 
Questionpostgresql VACUUM Pin
V.5-May-15 23:55
professionalV.5-May-15 23:55 
JokeRe: postgresql VACUUM Pin
Tim Carmichael6-May-15 4:52
Tim Carmichael6-May-15 4:52 
GeneralRe: postgresql VACUUM Pin
Mycroft Holmes6-May-15 14:06
professionalMycroft Holmes6-May-15 14:06 
GeneralRe: postgresql VACUUM Pin
Tim Carmichael6-May-15 14:49
Tim Carmichael6-May-15 14:49 
GeneralRe: postgresql VACUUM Pin
V.6-May-15 20:41
professionalV.6-May-15 20:41 
GeneralRe: postgresql VACUUM Pin
Mycroft Holmes6-May-15 22:04
professionalMycroft Holmes6-May-15 22:04 
GeneralRe: postgresql VACUUM Pin
V.6-May-15 22:06
professionalV.6-May-15 22:06 
GeneralRe: postgresql VACUUM Pin
Mycroft Holmes6-May-15 22:16
professionalMycroft Holmes6-May-15 22:16 
GeneralRe: postgresql VACUUM Pin
Tim Carmichael7-May-15 0:01
Tim Carmichael7-May-15 0:01 
AnswerRe: postgresql VACUUM Pin
Tim Carmichael7-May-15 2:15
Tim Carmichael7-May-15 2:15 
GeneralRe: postgresql VACUUM Pin
V.7-May-15 3:41
professionalV.7-May-15 3:41 
QuestionSequence number in DB2 Pin
sudevsu5-May-15 9:57
sudevsu5-May-15 9:57 
QuestionTest sol Pin
Stephen Holdorf30-Apr-15 11:24
Stephen Holdorf30-Apr-15 11:24 
GeneralRe: Help with a SQL query Pin
PIEBALDconsult30-Apr-15 19:33
mvePIEBALDconsult30-Apr-15 19:33 
GeneralRe: Help with a SQL query Pin
Stephen Holdorf1-May-15 2:54
Stephen Holdorf1-May-15 2:54 
GeneralRe: Help with a SQL query Pin
Stephen Holdorf20-May-15 3:27
Stephen Holdorf20-May-15 3:27 
GeneralRe: Help with a SQL query Pin
Stephen Holdorf20-May-15 3:39
Stephen Holdorf20-May-15 3:39 
AnswerRe: Help with a SQL query with all inappropriate information removed Pin
Richard Deeming1-May-15 3:39
mveRichard Deeming1-May-15 3:39 
QuestionRe: Test sol Pin
Eddy Vluggen4-May-15 8:20
professionalEddy Vluggen4-May-15 8:20 
QuestionDynamically Add Column Name Pin
MadDashCoder29-Apr-15 3:44
MadDashCoder29-Apr-15 3:44 
AnswerRe: Dynamically Add Column Name Pin
Sascha Lefèvre29-Apr-15 5:11
professionalSascha Lefèvre29-Apr-15 5:11 
GeneralRe: Dynamically Add Column Name Pin
MadDashCoder29-Apr-15 13:43
MadDashCoder29-Apr-15 13:43 
Hi, thank you all for responding. I decided to use a stored proc instead of a function and used Dynamic SQL to write my query.
Create Porocedure GetName
(
  @column nvarchar(50)
  @columnData nvarchar(50)
)
As
Begin 
   Declare @MyQuery nvarchar(300)

  set @column=   IF (@column IS NOT null AND @column ='TableA.SomeColumn') 
    Begin 
    Set @MyQuery = N'Select'+ TableA.[@column] + 'from dbo.TableA
        (where TableA.Column1 LIKE' + @columnData + '+ ''%'' OR' + @columnData + 'IS null)' 
     END         
End
EXEC sp_executesql;

I get no errors but it does not work. Any help will be greatly appreciated, thanks.

modified 29-Apr-15 19:53pm.

GeneralRe: Dynamically Add Column Name Pin
Corporal Agarn30-Apr-15 1:48
professionalCorporal Agarn30-Apr-15 1:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.