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 |
|
Mazdak
Yak Posting Veteran
63 Posts |
Posted - 2003-02-23 : 03:16:36
|
| Whats wrong with his stored procedure:CREATE PROCEDURE sp_GetItemName@Table nvarchar(50),@ItemID bigint,@ItemName nvarchar(100) outputASDeclare @sqlstring AS nvarchar(1000)Declare @columnname AS nvarchar(100)set @sqlstring = 'SELECT '+ @columnname+ '=COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME=['+@Table+ '] AND ORDINAL_POSITION=9'EXEC @sqlstringDECLARE @sqlstring1 AS nvarchar(1000)DECLARE @columnname1 AS nvarchar(100)set @sqlstring1='SELECT ' +@ItemNAme+'=[' + @columnname + '] FROM [' + @Table + '] WHERE ID='+@ItemIDEXEC @sqlstring1GOWhen it run I got run time error:Could not find stored procedure ''. Could not find stored procedure ''.!!!!!!!!!!!!!! |
|
|
macka
Posting Yak Master
162 Posts |
Posted - 2003-02-23 : 05:07:35
|
| Change the lines :EXEC @sqlstring and EXEC @sqlstring1 to :EXEC (@sqlstring) and EXEC (@sqlstring1)The brackets indicate that a dynamic string should be executed rather than a stored proc.macka.--There are only 10 types of people in the world - Those who understand binary, and those who don't. |
 |
|
|
|
|
|