Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Find a schema on function
Message
 
To
02/06/2008 08:57:44
Issam Mansour
Jordan Business Machines
Amman, Jordan
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01320930
Message ID:
01320942
Views:
13
>after that to use the result to get a value form on select statment.
>
>SELECT @MPQ = SELECT MPQ FROM @RESULT + 'PARM'
DECLARE @RESULT VARCHAR(100);
SET @RESULT=''

DECLARE @mpq int;
SET @mpq=0

DECLARE @TableName VARCHAR(40);
SET @TableName = 'parm'

SELECT @RESULT  = OBJECT_SCHEMA_NAME ( OBJECT_ID(@TableName ))
DECLARE @sql nvarchar(4000)
SET @sql = 'SELECT @Test = Mpq FROM '+@RESULT + '.'+@TableName

sp_executesql @sql, N'@Test int OUTPUT', @Test =@mpq
SELECT @MPQ
not tested

I see you have no WHERE in your clause, that means you could have unpredictable results if you have more than one record in that table.
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform