Click here to Skip to main content
15,908,264 members
Home / Discussions / Database
   

Database

 
GeneralRe: SQL problem Pin
kozu6-Jun-07 5:04
kozu6-Jun-07 5:04 
QuestionExporting ERD from Visio 2007 Enterprise Architect to SQL Server 2005 Pin
salman_syed_015-Jun-07 6:10
salman_syed_015-Jun-07 6:10 
QuestionSQL Case problem Pin
si_695-Jun-07 4:19
si_695-Jun-07 4:19 
AnswerRe: SQL Case problem Pin
si_695-Jun-07 4:36
si_695-Jun-07 4:36 
GeneralRe: SQL Case problem Pin
Krish - KP5-Jun-07 17:34
Krish - KP5-Jun-07 17:34 
AnswerRe: SQL Case problem Pin
Ilya Verbitskiy5-Jun-07 4:42
Ilya Verbitskiy5-Jun-07 4:42 
QuestionReporting Services Multilingual ? Pin
ArunkumarSundaravelu5-Jun-07 3:08
ArunkumarSundaravelu5-Jun-07 3:08 
QuestionError in executing stored procedure:not a valid identifier Pin
Kusumasrinivas5-Jun-07 0:24
Kusumasrinivas5-Jun-07 0:24 
Hey



I have written the following the stored procedure and executed it.But i am getting the following error. I don't know the reason for this.



set ANSI_NULLS ON

set QUOTED_IDENTIFIER ON

go



Create PROCEDURE [dbo].[GSU_Site_ReterieveActiveSitesOnSearch]

@whereClause nvarchar(2000)


AS

BEGIN

-- SET NOCOUNT ON added to prevent extra result sets from

-- interfering with SELECT statements.







declare @sqlstr as varchar(max)

set @sqlstr='SELECT Site.siteid as siteid,'

set @sqlstr=@sqlstr+ 'Site.Sitename as sitename, '

set @sqlstr= @sqlstr+ 'Customer.customerid,'

set @sqlstr= @sqlstr+ 'Customer.customername as CustomerName,'

set @sqlstr= @sqlstr+ 'Site.City as City,'

set @sqlstr= @sqlstr+ 'site.Address as Address,'

set @sqlstr =@sqlstr+ 'Site.state , '

set @sqlstr= @sqlstr+ 'Country.countryid as countryid,'

set @sqlstr= @sqlstr+ 'Country.countryname as country,Businessunit.businessunitid ,businessunit.businessunitname as BUName,'

set @sqlstr= @sqlstr+ 'SystemType.SystemTypeID,SystemType.SystemTypeName FROM Site INNER JOIN Country '

set @sqlstr= @sqlstr+ 'ON Country.countryid = Site.countryid INNER JOIN Customer ON Customer.customerid=Site.customerid '

set @sqlstr= @sqlstr+ 'INNER JOIN Businessunit ON Businessunit.businessunitID=Site.BusinessUnitID INNER JOIN SystemType ON '

set @sqlstr= @sqlstr+ 'SystemType.SystemTypeID=Site.SystemTypeID INNER JOIN GSUStatus ON Site.GSUStatusID=GSUStatus.GSUStatusID '

set @sqlstr= @sqlstr+@whereClause


--

--set @sqlstr=@sqlstr+' WHERE GSUStatus.GSUStatusID=' +@GSUStatusID

--if @BusinessUnitID <> 0

--set @sqlstr=@sqlstr+'and site.BusinessUnitID ='+@BusinessUnitID

--if @CountryID <> 0

--set @sqlstr=@sqlstr+'and site.countryid='+@CountryID

--if @CustomerID <> 0

--set @sqlstr=@sqlstr+'and site.customerid='+@CustomerID

--if @SystemTypeID <> 0

--set @sqlstr=@sqlstr+'and site.SystemTypeID='+@SystemTypeID

--if @SiteName <> ''

--set @sqlstr=@sqlstr+'and site.Sitename like ' + @SiteName

--if @Address <> ''

--set @sqlstr=@sqlstr+'site.Address like '+ @Address

--if @City <> ''

--set @sqlstr=@sqlstr+'site.City like '+ @City

--if @State <> ''

--set @sqlstr=@sqlstr+'and site.state like '+ @State

print @sqlstr



exec @sqlstr






END





I executed the procedure by pasing parameters



Exec [GSU_Site_ReterieveActiveSitesOnSearch]

" where GSUStatus.GSUStatusID=1 and site.Sitename like 'lakshmisite' "





and getting the following error



- exc {"The name 'SELECT Site.siteid as siteid,Site.Sitename as sitename, Customer.customerid,Customer.customername as CustomerName,Site.City as City,site.Address as Address,Site.state , Country.countryid as countryid,Country.countryname as country,Businessunit.businessunitid ,businessunit.businessunitname as BUName,SystemType.SystemTypeID,SystemType.SystemTypeName FROM Site INNER JOIN Country ON Country.countryid = Site.countryid INNER JOIN Customer ON Customer.customerid=Site.customerid INNER JOIN Businessunit ON Businessunit.businessunitID=Site.BusinessUnitID INNER JOIN SystemType ON SystemType.SystemTypeID=Site.SystemTypeID INNER JOIN GSUStatus ON S' is not a valid identifier."} System.Exception {System.Data.SqlClient.SqlException}





Please let me know the problem in this.





Thanks

Kusuma
AnswerRe: Error in executing stored procedure:not a valid identifier Pin
andyharman5-Jun-07 0:59
professionalandyharman5-Jun-07 0:59 
AnswerRe: Error in executing stored procedure:not a valid identifier Pin
P_pk9-Jun-07 0:15
P_pk9-Jun-07 0:15 
Questionsqlserverdoubt Pin
saravanan054-Jun-07 23:40
saravanan054-Jun-07 23:40 
AnswerRe: sqlserverdoubt Pin
Krish - KP5-Jun-07 17:25
Krish - KP5-Jun-07 17:25 
Questionindex order Pin
Shajeel4-Jun-07 21:24
Shajeel4-Jun-07 21:24 
AnswerRe: index order Pin
Pete O'Hanlon4-Jun-07 22:25
mvePete O'Hanlon4-Jun-07 22:25 
GeneralRe: index order Pin
Shajeel4-Jun-07 22:48
Shajeel4-Jun-07 22:48 
GeneralRe: index order Pin
andyharman4-Jun-07 23:05
professionalandyharman4-Jun-07 23:05 
Question0about update statement Pin
Nilesh Mitra4-Jun-07 20:12
Nilesh Mitra4-Jun-07 20:12 
AnswerRe: 0about update statement Pin
WoutL4-Jun-07 20:55
WoutL4-Jun-07 20:55 
QuestionHow to disable and monitor user connection Pin
Bob Vila4-Jun-07 14:09
Bob Vila4-Jun-07 14:09 
AnswerRe: How to disable and monitor user connection Pin
leckey4-Jun-07 17:40
leckey4-Jun-07 17:40 
QuestionAdd only form in access - disable combobox drop Pin
Dan Neely4-Jun-07 9:43
Dan Neely4-Jun-07 9:43 
QuestionCharacter Encoding in .DBF Pin
tg20044-Jun-07 9:11
tg20044-Jun-07 9:11 
QuestionMSDE Problems Pin
Brendan Vogt4-Jun-07 6:49
Brendan Vogt4-Jun-07 6:49 
AnswerRe: MSDE Problems Pin
Paul Conrad4-Jun-07 7:06
professionalPaul Conrad4-Jun-07 7:06 
Questionchecking the datatype of a column in a table Pin
steve_rm4-Jun-07 6:00
steve_rm4-Jun-07 6:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.