September 26, 2007 at 1:32 pm
DECLARE @Annee AS CHAR(4)
DECLARE @MOIS AS CHAR(2)
DECLARE @SQL AS NVARCHAR(2000)
DECLARE @ServerName AS NVARCHAR(200)
DECLARE @login AS NVARCHAR(200)
DECLARE @Password AS NVARCHAR(200)
DECLARE @STRVALUE AS NVARCHAR(25)
SET @Annee = '2007'
SET @MOIS = '6'
SET @ServerName = 'SERVERNAME'
SET @login = 'ANDRE'
SET @Password = '********'
SET @SQL = 'SELECT * FROM databasebase.dbo.tblDimTime WITH (NOLOCK) WHERE CalendarYear =' + @Annee + ' AND MonthNumberOfYear = ' + @MOIS
-- THIS ONE WORK FINE AND I CAN SEE THE VALUE Q2 2007 --
EXECUTE ('SELECT a.EnglishQuarterDescription FROM OPENROWSET(''SQLOLEDB'', ''' + @ServerName + '''; ''' + @login + '''; ''' + @Password + ''', ''' + @SQL + ''') AS a GROUP BY a.EnglishQuarterDescription ORDER BY a.EnglishQuarterDescription')
-- BUT WHAT I NEED IS ...:cool:
EXECUTE (@STRVALUE = 'SELECT a.EnglishQuarterDescription FROM OPENROWSET(''SQLOLEDB'', ''' + @ServerName + '''; ''' + @login + '''; ''' + @Password + ''', ''' + @SQL + ''') AS a GROUP BY a.EnglishQuarterDescription ORDER BY a.EnglishQuarterDescription')
-- TO RETURN THE VALUE ---
SELECT '@STRVALUE = ' + @STRVALUE
Any body can help me ...
I spent all my time on this problem today ...
Will be appreciate
(Sorry my english is ..so so .. ) Thanks
Andre
September 26, 2007 at 1:48 pm
Have a look at sp_executesql
* Noel
September 26, 2007 at 2:47 pm
Yes I tried
sp_executesql
But I don't know how I can use it
September 26, 2007 at 3:08 pm
Here is an example:
http://www.simple-talk.com/sql/learn-sql-server/pop-rivetts-sql-server-faq/
* Noel
September 27, 2007 at 8:34 am
Cool Stuff !
Thank you Noel
Very mutch ... now it's working fine
André
September 27, 2007 at 4:10 pm
Happy to Help 😀
* Noel
September 28, 2007 at 12:50 pm
Sorry but it's not working i'm confuse but ..
Still have a same problem and I don't know how I can fix it
Look what i did
DECLARE @out_value AS INT
DECLARE @rc AS INT
DECLARE @SPName nVARCHAR(128)
DECLARE @SPCall nVARCHAR(128)
SET @SPName = 'SELECT [Greycon].[dbo].fn_GetLateDay(''00079902'',1)'
SELECT @SPCall = 'exec ' + @SPName + ' @out_value output'
EXEC @rc = HOSSQL.Greycon.dbo.sp_executesql @SPCall, N'@out_value int output', @out_value output
SELECT @rc AS TEST
it return 170 and is should be are 2
and I got this message error
Msg 170, Level 15, State 1, Line 28
Line 1: Incorrect syntax near '@out_value'.
Msg 156, Level 15, State 1, Line 28
Incorrect syntax near the keyword 'SELECT'.
(1 row(s) affected)
Do you know where I did a mistake ???? Plze...
I was trying exactelly what you tell me before and I went to http://www.simple-talk.com/sql/learn-sql-server/pop-rivetts-sql-server-faq/
But it's not working ... :w00t:
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply