|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Query with user-define function John Belland numbers. When I query [Index]=AA there is an error: Invalid column name 'AA' Any more suggestion? Thank you Helen Show quote "John Bell" wrote: > Hi > > Maybe > > CREATE TABLE foo ( [index] int not null identity(1,1), a int, b int, c > varchar(10) ) > INSERT INTO Foo ( a, b, c ) SELECT 5,9,'a+@q+3*b' > > DECLARE @sql VARCHAR(255) > SELECT @sql = 'DECLARE @q int SET @q=7 SELECT a,b,' + c+ ' FROM dbo.foo > where [Index]=1' > FROM dbo.foo where [Index]=1 > EXEC(@sql) > > John [Index] = 'AA'.
Perayu Show quote "Helen" <He***@discussions.microsoft.com> wrote in message news:A76F8AD0-7065-4968-ADA5-9E957DD7949D@microsoft.com... > Yes!! It works. But just a point. In the [Index] column I have both > strings > and numbers. When I query [Index]=AA there is an error: Invalid column > name > 'AA' > Any more suggestion? > > Thank you > Helen > > "John Bell" wrote: > >> Hi >> >> Maybe >> >> CREATE TABLE foo ( [index] int not null identity(1,1), a int, b int, c >> varchar(10) ) >> INSERT INTO Foo ( a, b, c ) SELECT 5,9,'a+@q+3*b' >> >> DECLARE @sql VARCHAR(255) >> SELECT @sql = 'DECLARE @q int SET @q=7 SELECT a,b,' + c+ ' FROM dbo.foo >> where [Index]=1' >> FROM dbo.foo where [Index]=1 >> EXEC(@sql) >> >> John > |
|||||||||||||||||||||||