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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2004-11-08 : 07:21:58
|
| yamadootha writes "What is wrong with the syntex?CREATE PROCEDURE [dbo].[sp_SearchRecords] ( @whereclause as varchar(500) )ASSET QUOTED_IDENTIFIER OFF --Declare @SQL VarChar(1000)Declare @OrderBy varchar(50)SET @OrderBy = ' order by Field1 DESC'--Declare @DollarSign varchar(2)--SET @DollarSign = '$'SELECT CONVERT(char(10),Date1,1) as Date1,CONVERT(char(10),Date2,1) as Date2,Field1,Field2,Field3,'$' + CONVERT(NCHAR(15),cast(Field4 as money),1) as Field4 FROM TableName WHERE + @whereclause + @OrderByGO" |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2004-11-08 : 07:39:49
|
quote: Originally posted by AskSQLTeam yamadootha writes "What is wrong with the syntex?CREATE PROCEDURE [dbo].[sp_SearchRecords] ( @whereclause as varchar(500) )ASSET QUOTED_IDENTIFIER OFF --Declare @SQL VarChar(1000)Declare @OrderBy varchar(50)SET @OrderBy = ' order by Field1 DESC'--Declare @DollarSign varchar(2)--SET @DollarSign = '$'SELECT CONVERT(char(10),Date1,1) as Date1,CONVERT(char(10),Date2,1) as Date2,Field1,Field2,Field3,'$' + CONVERT(NCHAR(15),cast(Field4 as money),1) as Field4 FROM TableName WHERE + @whereclause + @OrderByGO"
your query, use dynamic sql for this.--------------------keeping it simple... |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2004-11-08 : 07:40:59
|
| Think about itselect *from tblwhere + 'hello'does that make sense?declare @sql varchar(8000)select @sql = 'SELECT CONVERT(char(10),Date1,1) as Date1,CONVERT(char(10),Date2,1) as Date2,Field1,Field2,Field3,''$'' + CONVERT(NCHAR(15),cast(Field4 as money),1) as Field4FROM TableName WHERE ' + @whereclause + @OrderByexec (@sql)==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|
|
|