How can I pass a table variable as a parameter to a stored procedure ?
eg.
create proc procname ( @.param table (col1 int ) )
as
select ....
I get the following error :
Server: Msg 156, Level 15, State 1, Procedure procname, Line 1
Incorrect syntax near the keyword 'table'.
Is there any alternate way to do this ?
Thanks.You cannot pass a table variable as an input to the SP. Not sure about your logic but if it is unavoidable, one way is to populate a temp table and read from the SP and then delete it as soon as you exit from the called SP. This is one option. Sure there could be some better ones.
- CB
Originally posted by Decastod
How can I pass a table variable as a parameter to a stored procedure ?
eg.
create proc procname ( @.param table (col1 int ) )
as
select ....
I get the following error :
Server: Msg 156, Level 15, State 1, Procedure procname, Line 1
Incorrect syntax near the keyword 'table'.
Is there any alternate way to do this ?
Thanks.|||Thanks for your help.
Tired it in another way as you mentioned and it worked.
Showing posts with label col1. Show all posts
Showing posts with label col1. Show all posts
Monday, March 12, 2012
Wednesday, March 7, 2012
Parameters as Column names
I have a simple query but I need the parameter to select the column name
of the WHERE clause.
SELECT col1, col2, col3, col4 FROM Table WHERE @.colname = 1
The query builder is changing this everytime I set a parameter as a column
name. Is there a way to do this?I figured out my problem. I made the query a dynamic query by making it:
="SELECT col1, col2, col3, col4 FROM Table WHERE " & Parameters!Colname.Value
& " = 1"
I was running into all sorts of errors, but I found out that the query needs
to be all on one line with no linebreaks.
> I have a simple query but I need the parameter to select the column
> name of the WHERE clause.
> SELECT col1, col2, col3, col4 FROM Table WHERE @.colname = 1
> The query builder is changing this everytime I set a parameter as a
> column name. Is there a way to do this?
>
of the WHERE clause.
SELECT col1, col2, col3, col4 FROM Table WHERE @.colname = 1
The query builder is changing this everytime I set a parameter as a column
name. Is there a way to do this?I figured out my problem. I made the query a dynamic query by making it:
="SELECT col1, col2, col3, col4 FROM Table WHERE " & Parameters!Colname.Value
& " = 1"
I was running into all sorts of errors, but I found out that the query needs
to be all on one line with no linebreaks.
> I have a simple query but I need the parameter to select the column
> name of the WHERE clause.
> SELECT col1, col2, col3, col4 FROM Table WHERE @.colname = 1
> The query builder is changing this everytime I set a parameter as a
> column name. Is there a way to do this?
>
Subscribe to:
Posts (Atom)