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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 where clause

Author  Topic 

jemacc
Starting Member

42 Posts

Posted - 2004-10-03 : 02:18:59
I will like to add to the statement below the following criteria
select @sql =SELECT @SQL = @SQL + ' WHERE (EmployeeID) = @EmployeeID',

how can I do this?

USE Northwind
GO

DECLARE @SQL varchar(8000), @EmployeeID,@tblname sysname

SELECT @tbname = 'Employees'

SELECT @SQL = 'SELECT * FROM ' + @tblname
SELECT @SQL = @SQL + ' WHERE (EmployeeID) = 5'
EXEC(@SQL)
GO

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2004-10-03 : 11:02:34
do this:
SELECT @SQL = 'SELECT * FROM ' + @tblname
SELECT @SQL = @SQL + ' WHERE EmployeeID = ' + @EmployeeID


Go with the flow & have fun! Else fight the flow
Go to Top of Page

jemacc
Starting Member

42 Posts

Posted - 2004-10-03 : 12:27:14
Thank you so much for time,help and knowledge


"Our lives begin to end the day we become silent about things that matter."
- Dr. Martin Luther King, Jr.
"The mind does not take its complexion from the skin..."
- Frederick Douglass
There is always a way to do it better . . . find it!" Thomas A. Edison

Go to Top of Page
   

- Advertisement -