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 |
durgamavu
Starting Member
4 Posts |
Posted - 2011-03-22 : 12:26:43
|
hi ..the scenario is like :a stored procedure takes input parameter and returns a single result..and now i want to store this result into temp: table,and one more thing is dont want to insert row into temp table if it is redundant..,when am trying to create a temp table using #temp..its not allowing to do so..dnt knw the reason..pls help as am newbie to sql server dev: thnks |
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2011-03-22 : 13:01:33
|
Please post the structure of the table you're trying to insert into (CREATE TABLE statement). |
 |
|
X002548
Not Just a Number
15586 Posts |
|
durgamavu
Starting Member
4 Posts |
Posted - 2011-03-23 : 01:42:28
|
quote: Originally posted by robvolk Please post the structure of the table you're trying to insert into (CREATE TABLE statement).
set ANSI_NULLS ONset QUOTED_IDENTIFIER ONgoALTER PROCEDURE [dbo].[GetProductInfo] @prodid int AS SELECT ProductName FROM Products WHERE (ProductID = @prodid)insert into #temp(prodname) exec [dbo].[GetProductInfo]THIS IS THE TABLE AM TRYING TO CREATE..THE SP IS RETURNING THE RESULT BUE NOT IN A #TEMP TABLE,#temp table is not getting created |
 |
|
X002548
Not Just a Number
15586 Posts |
|
durgamavu
Starting Member
4 Posts |
Posted - 2011-03-23 : 01:48:03
|
quote: Originally posted by X002548 Are you doingEXEC <sprocname> INTO #newTemp???Won't workYou need to create the table first, then doINSERT INTO #temp (Col1, Col2, ColEtc)EXEC <sprocname>And does is redundant mean? If the sproc is returning dup rows, fix the sprocOr clone it and change itBrett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxWant to help yourself?http://msdn.microsoft.com/en-us/library/ms130214.aspxhttp://weblogs.sqlteam.com/brettk/http://brettkaiser.blogspot.com/
hi..had done the same way..pls look at the table structure...i want to fix the sp itself to stop returning redundant values..that is it can check in the temp table and allow only those values that are not there.. |
 |
|
durgamavu
Starting Member
4 Posts |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-03-23 : 04:16:02
|
can you show us the code that create the temp table and also how you execute the Stored Procedure KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|
|