Re: help with stored procedure which returns an OUTPUT value
- From: Erland Sommarskog <esquel@xxxxxxxxxxxxx>
- Date: Sun, 2 Mar 2008 14:03:06 +0000 (UTC)
Vic (vikrantp@xxxxxxxxx) writes:
Also the print @sql isn't showing values of @db. So I tried to modify
the select statement by modifying the the single quotes (') in the
line then I see the error as @db not declared or something.
You have:
N' FROM @db.INFORMATION_SCHEMA.COLUMNS '+
I don't think this can ever be legal T-SQL. In any case it can never mean
what you intended. You cannot specify the database name through a
variable, but you have to inline it:
N' FROM ' + quotename(@db) + '.INFORMATION_SCHEMA.COLUMNS '+
Also Exec sp_executesql @sql, @params, 'TestData', 'accounting', '11'
is that how I call sp_executesql?
The first parameter is the SQL statement. The second is the parameter
list. The remaining are the parameters as specified in your parameter
list.
N' COLUMN_NAME LIKE @fieldnumber-% '
This is not going to end happily. - is a numeric operator, but % will not
convert to an integer. You need:
N' COLUMN_NAME LIKE @fieldnumber + ''-%'' '
--
Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
.
- Follow-Ups:
- References:
- help with stored procedure which returns an OUTPUT value
- From: Vic
- Re: help with stored procedure which returns an OUTPUT value
- From: Erland Sommarskog
- Re: help with stored procedure which returns an OUTPUT value
- From: Vic
- help with stored procedure which returns an OUTPUT value
- Prev by Date: Re: History/audit without history tables
- Next by Date: Re: Getting started with SQL Server Express Edition - total newbie
- Previous by thread: Re: help with stored procedure which returns an OUTPUT value
- Next by thread: Re: help with stored procedure which returns an OUTPUT value
- Index(es):
Relevant Pages
|