Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2001-10-29 : 09:13:19
|
Pushpa writes "Hello,I have one query in SQL, can u help me in solving it?PROBLEM:--------I want to generate dynamic query for data retreival, but I don't know how to execute it. Do you have any idea? I have written a small query, to give u the general idea of my dynamic query.CODE:-----SELECT @SQL= ' SELECT @@sCompanyName=Co.company_name, @@nComp_Id=Co.company_id, FROM company_l Co WHERE Co.login_name =@@sLogin AND Co.Password=@@sPwd 'IF (@@OrderBy=<>'') BEGIN @SQL= @SQL + @OrderBy ENDEXEC(@SQL) --- This line is giving error, becoz i m trying to store the value in variable.In the above query, these are my INPUT parameters - @@OrderBy, @@sLogin, @@sPwd.@@OrderBy = ' ORDER BY Co.company_id 'Pls. tell me how i can execute this query and retreive values in variables.I also tried sp_executesql, but failed in retreiving values in my variables.Pushpa" |
|
|
|
|