|
problme in stored procedure -- Lalit N Dubey --
Hello Group, I am new in stored procedure writing. I was trying to write the procedure to return the rows from a specific table where I wanted to pass the column name at run time. Is there is any tips do provide me here. Thanks in advance for cooperation's. Regards, Lalit Dubey Noida , India |
|
-- Lalit N Dubey --
Hello Group, I am new in stored procedure writing. I was trying to write the procedure to return the rows from a specific table where I wanted to pass the column name at run time. Is there is any tips do provide me here. Thanks in advance for cooperation's. Regards, Lalit Dubey Noida , India -----Original Message----- From: TechdotNetIndia Re: problme in stored procedure Use Dynamic Queries ----- Original Message ----- From: Lalit N Dubey To: TechdotNetIndia Sent: Friday, June 09, 2006 3:32 PM Subject: problme in stored procedure Hi, How to pass the table name at run time in stored procedure. Regards, Lalit -----Original Message----- From: TechdotNetIndia Application Hang when add a icon in winform Hi Group, I am facing a problem . When I am adding a new Icon.ico to windows from . When i close this form it freeze the application . Thanks and regards |
|
-- Ravi Kumar --
Hi, try this create procedure Dynamic(@TblName varchar(200),@ColumnName varchar(200)) as begin declare @qry varchar(4000) set @qry='select '+@ColumnName+' from '+@TblName exec(@qry) end Regards Ravi.P ----- Original Message ----- From: Lalit N Dubey To: TechdotNetIndia Sent: Wednesday, July 05, 2006 12:58 PM Subject: Re: problme in stored procedure Hello Group, I am new in stored procedure writing. I was trying to write the procedure to return the rows from a specific table where I wanted to pass the column name at run time. Is there is any tips do provide me here. Thanks in advance for cooperation’s… Regards, Lalit Dubey Noida , India -----Original Message----- From: TechdotNetIndia On Behalf Of Ravi Kumar Sent: Friday, June 09, 2006 3:40 PM To: TechdotNetIndia Subject: Re: problme in stored procedure Use Dynamic Queries ----- Original Message ----- From: Lalit N Dubey To: TechdotNetIndia Sent: Friday, June 09, 2006 3:32 PM Subject: problme in stored procedure Hi, How to pass the table name at run time in stored procedure. Regards, Lalit -----Original Message----- From: TechdotNetIndia On Behalf Of Rahul Gupta Sent: Thursday, June 08, 2006 4:41 PM To: TechdotNetIndia Subject: Application Hang when add a icon in winform Hi Group, I am facing a problem . When I am adding a new Icon.ico to windows from . When i close this form it freeze the application . Thanks and regards |
|
-- Lalit N Dubey --
Hello Ravi, Thanks for the response. Here I have got 2 points 1- I hope this stored procedure would be fine working in SQL Server. But as of now I ma using the My SQL 5.0 I tried to write it but its giving error , bcz exec(@qry) mothod is no that scope. Any idea about MYSQL stored procedure ? 2- Hpw can I call this procedure in C# where the table name is on runtime? I tried this code MySqlCommand cmd = new MySqlCommand("ProcedureNAme", new MySqlConnection(ConnectionString)); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new MySqlParameter("param1", "TableName")); cmd.Parameters.Add(new MySqlParameter("param2", "ColumnName")); is that valid for the table parameter to call as param1 ? its giving error here in my case. Plz help Lalit, -----Original Message----- From: TechdotNetIndia Re: problme in stored procedure Hi, try this create procedure Dynamic(@TblName varchar(200),@ColumnName varchar(200)) as begin declare @qry varchar(4000) set @qry='select '+@ColumnName+' from '+@TblName exec(@qry) end Regards Ravi.P ----- Original Message ----- From: Lalit N Dubey To: TechdotNetIndia Sent: Wednesday, July 05, 2006 12:58 PM Subject: Re: problme in stored procedure Hello Group, I am new in stored procedure writing. I was trying to write the procedure to return the rows from a specific table where I wanted to pass the column name at run time. Is there is any tips do provide me here. Thanks in advance for cooperation's. Regards, Lalit Dubey Noida , India -----Original Message----- From: TechdotNetIndia Re: problme in stored procedure Use Dynamic Queries ----- Original Message ----- From: Lalit N Dubey To: TechdotNetIndia Sent: Friday, June 09, 2006 3:32 PM Subject: problme in stored procedure Hi, How to pass the table name at run time in stored procedure. Regards, Lalit -----Original Message----- From: TechdotNetIndia Application Hang when add a icon in winform Hi Group, I am facing a problem . When I am adding a new Icon.ico to windows from . When i close this form it freeze the application . Thanks and regards |
|
-- muthu ramalingam --
Hello, 1. Try to use Sp_ExecuteSQL...... Create procedure DynamicTableNew(@TblName varchar(200),@ColumnName varchar(200)) as begin declare @qry NVarChar(4000) set @qry='select '+@ColumnName+' from '+@TblName Exec Sp_ExecuteSQL @qry end 2.Use the parameter's name as in SP cmd.Parameters.Add(new MySqlParameter("(@TblName", "TableName")); cmd.Parameters.Add(new MySqlParameter("@ColumnName", "ColumnName")); If any issues,please inform me..... Regards, M.Muthuramalingam Lalit N Dubey Hello Ravi, Thanks for the response. Here I have got 2 points 1- I hope this stored procedure would be fine working in SQL Server. But as of now I ma using the My SQL 5.0 I tried to write it but its giving error , bcz exec(@qry) mothod is no that scope. Any idea about MYSQL stored procedure ? 2- Hpw can I call this procedure in C# where the table name is on runtime? I tried this code MySqlCommand cmd = new MySqlCommand("ProcedureNAme", new MySqlConnection(ConnectionString)); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new MySqlParameter("param1", "TableName")); cmd.Parameters.Add(new MySqlParameter("param2", "ColumnName")); is that valid for the table parameter to call as param1 ? its giving error here in my case. Plz help Lalit, -----Original Message----- From: TechdotNetIndia Re: problme in stored procedure Hi, try this create procedure Dynamic(@TblName varchar(200),@ColumnName varchar(200)) as begin declare @qry varchar(4000) set @qry='select '+@ColumnName+' from '+@TblName exec(@qry) end Regards Ravi.P ----- Original Message ----- From: Lalit N Dubey To: TechdotNetIndia Sent: Wednesday, July 05, 2006 12:58 PM Subject: Re: problme in stored procedure Hello Group, I am new in stored procedure writing. I was trying to write the procedure to return the rows from a specific table where I wanted to pass the column name at run time. Is there is any tips do provide me here. Thanks in advance for cooperation’s… Regards, Lalit Dubey Noida , India -----Original Message----- From: TechdotNetIndia Re: problme in stored procedure Use Dynamic Queries ----- Original Message ----- From: Lalit N Dubey To: TechdotNetIndia Sent: Friday, June 09, 2006 3:32 PM Subject: problme in stored procedure Hi, How to pass the table name at run time in stored procedure. Regards, Lalit -----Original Message----- From: TechdotNetIndia Application Hang when add a icon in winform Hi Group, I am facing a problem . When I am adding a new Icon.ico to windows from . When i close this form it freeze the application . Thanks and regards --------------------------------- How low will we go? Check out Yahoo! Messenger’s low PC-to-Phone call rates. |
|
-- sudharshan teddu --
Hi, In order to send table name dynamically to a stored procedure. Try the solution given below, if at all it is SQL SERVER 2000. CREATE PROCEDURE DYNAMICTABLE ( @TABLENAME VARCHAR(20) ) AS BEGIN EXEC('SELECT * FROM ' + @TABLENAME) END If you u want to test this procedure, try it out in the SQl Query Analyzer. By typing the procedure name DYNAMICTABLE 'tablename' 'tablename' might be dynamic table like emp,dept etc... Cheers, Sudharshan... On 7/5/06, Lalit N Dubey Hello Group, I am new in stored procedure writing. I was trying to write the procedure to return the rows from a specific table where I wanted to pass the column name at run time. Is there is any tips do provide me here. Thanks in advance for cooperation's… Regards, Lalit Dubey Noida , India -----Original Message----- *From:* TechdotNetIndia [mailto: TechdotNetIndia] *On Behalf Of *Ravi Kumar *Sent:* Friday, June 09, 2006 3:40 PM *To:* TechdotNetIndia *Subject:* Re: problme in stored procedure Use Dynamic Queries ----- Original Message ----- *From:* Lalit N Dubey *To:* TechdotNetIndia *Sent:* Friday, June 09, 2006 3:32 PM *Subject:* problme in stored procedure Hi, How to pass the table name at run time in stored procedure. Regards, Lalit -----Original Message----- *From:* TechdotNetIndia [mailto: TechdotNetIndia] *On Behalf Of *Rahul Gupta *Sent:* Thursday, June 08, 2006 4:41 PM *To:* TechdotNetIndia *Subject:* Application Hang when add a icon in winform Hi Group, I am facing a problem . When I am adding a new Icon.ico to windows from . When i close this form it freeze the application . Thanks and regards > |
|
-- sreejith77 --
Lalit for this u have to use followin thing set @tab = 'tablename' set @qry = 'Select * from ' + @tab exec sp_executesql @qry hope this will work for u Sreejith TechdotNetIndia wrote: Hello Group, I am new in stored procedure writing. I was trying to write the procedure to return the rows from a specific table where I wanted to pass the column name at run time. Is there is any tips do provide me here. Thanks in advance for cooperation!7;s… Regards, Lalit Dubey Noida , India -----Original Message----- From: TechdotNetIndia Re: problme in stored procedure Use Dynamic Queries ----- Original Message ----- From: Lalit N Dubey To: TechdotNetIndia Sent: Friday, June 09, 2006 3:32 PM Subject: problme in stored procedure Hi, How to pass the table name at run time in stored procedure. Regards, Lalit -----Original Message----- From: TechdotNetIndia Application Hang when add a icon in winform Hi Group, I am facing a problem . When I am adding a new Icon.ico to windows from . When i close this form it freeze the application . Thanks and regards |
|
-- Lalit N Dubey --
Hello Ravi, Thanks for the response. I have got the solution for this problem. Now its working. Lalit, -----Original Message----- From: TechdotNetIndia Re: problme in stored procedure Hello, 1. Try to use Sp_ExecuteSQL...... Create procedure DynamicTableNew(@TblName varchar(200),@ColumnName varchar(200)) as begin declare @qry NVarChar(4000) set @qry='select '+@ColumnName+' from '+@TblName Exec Sp_ExecuteSQL @qry end 2.Use the parameter's name as in SP cmd.Parameters.Add(new MySqlParameter("(@TblName", "TableName")); cmd.Parameters.Add(new MySqlParameter("@ColumnName", "ColumnName")); If any issues,please inform me..... Regards, M.Muthuramalingam Lalit N Dubey Hello Ravi, Thanks for the response. Here I have got 2 points 1- I hope this stored procedure would be fine working in SQL Server. But as of now I ma using the My SQL 5.0 I tried to write it but its giving error , bcz exec(@qry) mothod is no that scope. Any idea about MYSQL stored procedure ? 2- Hpw can I call this procedure in C# where the table name is on runtime? I tried this code MySqlCommand cmd = new MySqlCommand("ProcedureNAme", new MySqlConnection(ConnectionString)); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new MySqlParameter("param1", "TableName")); cmd.Parameters.Add(new MySqlParameter("param2", "ColumnName")); is that valid for the table parameter to call as param1 ? its giving error here in my case. Plz help Lalit, -----Original Message----- From: TechdotNetIndia Re: problme in stored procedure Hi, try this create procedure Dynamic(@TblName varchar(200),@ColumnName varchar(200)) as begin declare @qry varchar(4000) set @qry='select '+@ColumnName+' from '+@TblName exec(@qry) end Regards Ravi.P ----- Original Message ----- From: Lalit N Dubey To: TechdotNetIndia Sent: Wednesday, July 05, 2006 12:58 PM Subject: Re: problme in stored procedure Hello Group, I am new in stored procedure writing. I was trying to write the procedure to return the rows from a specific table where I wanted to pass the column name at run time. Is there is any tips do provide me here. Thanks in advance for cooperation's. Regards, Lalit Dubey Noida , India -----Original Message----- From: TechdotNetIndia Re: problme in stored procedure Use Dynamic Queries ----- Original Message ----- From: Lalit N Dubey To: TechdotNetIndia Sent: Friday, June 09, 2006 3:32 PM Subject: problme in stored procedure Hi, How to pass the table name at run time in stored procedure. Regards, Lalit -----Original Message----- From: TechdotNetIndia Application Hang when add a icon in winform Hi Group, I am facing a problem . When I am adding a new Icon.ico to windows from . When i close this form it freeze the application . Thanks and regards |