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 |
|
shakthiA
Starting Member
12 Posts |
Posted - 2008-04-07 : 17:27:07
|
| Hi I have tried like this. but I cant execute my SP it ended up with errors.IF (@FirstLetters IS NOT NULL)BEGIN SET @FirstLetter = 'SELECT SplitValue FROM dbo.FnSplitString('+@FirstLetters+','',''))' print @FirstLetterENDSELECT P.PUB_ID AS ''PubId'',P.PUB_TITLE AS ''PubTitle''FROM HDS_PUBLICATION P INNER JOIN HN_IM_JOIN IM ON IM.PUB_UNID = P.PUB_UNID, HDS_CUSTOM C, WD_PUBLIC_SHELF S, HDS_TOPIC TWHERE P.PUB_UNID = C.PUB_UNID AND C.CUSTOM3 = ''False'' AND P.PUB_ID = S.PUB_ID AND P.PUB_UNID = T.PUB_UNID AND S.Audience = ''Public'' ' + @FilterByLang + 'ANDP.PUB_TITLE LIKE '+ @FirstLetter +'''%''' +' EXEC SPAny one please clear meThanks,shakthiA |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-04-08 : 05:29:20
|
| What is the error you are getting?MadhivananFailing to plan is Planning to fail |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2008-04-08 : 05:41:38
|
| What does the spli function return? They normally return a table (note they are not used in v2005 usually as you have cte's).It looks like you are trying to use dynamic sql but not creating the string. Anyway your quotes are not bvery close to being correct.trySELECT P.PUB_ID AS ''PubId'',P.PUB_TITLE AS ''PubTitle''FROM HDS_PUBLICATION PINNER JOIN HN_IM_JOIN IMON IM.PUB_UNID = P.PUB_UNID, HDS_CUSTOM C,WD_PUBLIC_SHELF S,HDS_TOPIC TWHERE P.PUB_UNID = C.PUB_UNID AND C.CUSTOM3 = ''False'' AND P.PUB_ID = S.PUB_IDAND P.PUB_UNID = T.PUB_UNIDAND S.Audience = 'Public'--' + @FilterByLang + ' -- what is this?AND left(P.PUB_TITLE,1) in (SELECT SplitValue FROM dbo.FnSplitString(@FirstLetters,'','')==========================================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. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-04-08 : 10:59:31
|
| What's SP? Also where is variable to hold the SQL string? ALso why do you put '' for aliases? |
 |
|
|
|
|
|
|
|