Showing posts with label working. Show all posts
Showing posts with label working. Show all posts

Friday, March 30, 2012

peer to peer replication

Hi,

I set up a peer to peer replication on servers, but only one side seem to be working. I am getting Log Reader Agent job error.

Unable to start execution of step 2 (reason: Error authenticating proxy domain\user, system error: Logon failure: unknown user name or bad password.). The step failed.

I am using the same windows account on both servers, why is one side working and the other side not?

thanks

doublecheck the account and password that starts the job, sqlserver and sqlagent service, and doublecheck their permissions on the machine.

Wednesday, March 28, 2012

PDF Report not reflecting changes after update

I've working on a report at a client and I'm having an issue with a report
not reflecting multiple updated. The basic procedure that is followed is:
1. The client adds an event to the timeline.
2. The client runs the timeline report and the new event shows up.
3. The client adds a new event to the timeline.
4. The second, and any subsequent events do not show up.
I've checked the stored procedure that the report calls and it returns the
correct data every time (reflects the events as added). I've also checked
the execution properties in the report to be sure that the report isn't set
to be cached, and it's not. I'm using SQL Server 2000 & Reporting Services,
and I'm using Visual Studio 2003 SP1.
Any help would be really appreciated.It took me awhile to find the answer when I had the same problem.
Use;
rs:ClearSession=true in the url assuming you are using the url method.
directs the report server to remove a report from session. All report
instances associated with an authenticated user are removed from
session. (A report instance is defined as the same report run multiple
times with different report parameter values.)
Neil
John Swaringen wrote:
> I've working on a report at a client and I'm having an issue with a report
> not reflecting multiple updated. The basic procedure that is followed is:
> 1. The client adds an event to the timeline.
> 2. The client runs the timeline report and the new event shows up.
> 3. The client adds a new event to the timeline.
> 4. The second, and any subsequent events do not show up.
> I've checked the stored procedure that the report calls and it returns the
> correct data every time (reflects the events as added). I've also checked
> the execution properties in the report to be sure that the report isn't set
> to be cached, and it's not. I'm using SQL Server 2000 & Reporting Services,
> and I'm using Visual Studio 2003 SP1.
> Any help would be really appreciated.|||Neil,
That worked great. It took me a while to figure out that I had to add it
via the ReportViewer.SetParameter() function. But once I did that everything
is cooking!
Thanks for the help!
"neilgould@.gmail.com" wrote:
> It took me awhile to find the answer when I had the same problem.
> Use;
> rs:ClearSession=true in the url assuming you are using the url method.
> directs the report server to remove a report from session. All report
> instances associated with an authenticated user are removed from
> session. (A report instance is defined as the same report run multiple
> times with different report parameter values.)
> Neil
>
> John Swaringen wrote:
> > I've working on a report at a client and I'm having an issue with a report
> > not reflecting multiple updated. The basic procedure that is followed is:
> >
> > 1. The client adds an event to the timeline.
> > 2. The client runs the timeline report and the new event shows up.
> > 3. The client adds a new event to the timeline.
> > 4. The second, and any subsequent events do not show up.
> >
> > I've checked the stored procedure that the report calls and it returns the
> > correct data every time (reflects the events as added). I've also checked
> > the execution properties in the report to be sure that the report isn't set
> > to be cached, and it's not. I'm using SQL Server 2000 & Reporting Services,
> > and I'm using Visual Studio 2003 SP1.
> >
> > Any help would be really appreciated.
>

PDF rendering extension not working on SQL RS 2K sp2

I am in the process of migrating apps from SSRS 2K sp1 to SP2 and one of the
application renders to PDF and it is not working.
I thought pdf rendering was missed out from rsserver.config file and added
the line below
<Extension Name="PDF"
type="Microsoft.ReportingServices.Rendering.ImageRenderer.PdfReport,Microsoft.ReportingServices.ImageRendering"/>
...thinking it might help, but still not.
THis is the error msg we are getting whenever we run the report from the
application.
An attempt has been made to use a rendering extension that is not registered
for this report server. --> An attempt has been made to use a rendering
extension that is not registered for this report server. --> An attempt has
been made to use a rendering extension that is not registered for this report
server
When we run the report from reporting service it works...
Can some one help me or point me in how to fix ...
Env: Win2k3 - SQL 2k - SSRS Sp2.
Thanks
- SaravanaAnyone can you reply about this, as I am in a time crunch
regards
- Saravana
"SK" wrote:
> I am in the process of migrating apps from SSRS 2K sp1 to SP2 and one of the
> application renders to PDF and it is not working.
> I thought pdf rendering was missed out from rsserver.config file and added
> the line below
> <Extension Name="PDF"
> type="Microsoft.ReportingServices.Rendering.ImageRenderer.PdfReport,Microsoft.ReportingServices.ImageRendering"/>
> ...thinking it might help, but still not.
> THis is the error msg we are getting whenever we run the report from the
> application.
> An attempt has been made to use a rendering extension that is not registered
> for this report server. --> An attempt has been made to use a rendering
> extension that is not registered for this report server. --> An attempt has
> been made to use a rendering extension that is not registered for this report
> server
> When we run the report from reporting service it works...
> Can some one help me or point me in how to fix ...
> Env: Win2k3 - SQL 2k - SSRS Sp2.
> Thanks
> - Saravana

PDF Render performance with SP1

Hi,
We have been working with some lrge PDF reports (200-400 pages) and have been anxiously awaiting
SP1 because of performance problems we have been having.
Our initial tests show that the performance is better: Given about 3000 records from SQL Server,
we generated a 272 page report.
Pre SP1: 4 minutes 35 seconds
With SP: 2 minutes 5 second.
So it is just over twice as fast. I also noticed that it is consuming less memory (roughly down
from 700MB to 400MB)
We still would like to get the performance much better and I'm looking for help to understand the
process and what we can do. In the past, running this report in MS Access and using ActivePDF took
10-20 seconds to generate the same report. Why is there such a disparity?
The SQL Query is taking 1-2 seconds at most, then all of the time is spent in aspnet_wp - all CPU,
negligible disk I/O. How do you suggest we identify the time spent?
Are there any tricks to making the report more efficient so that the PDF render time is better? Do
you have some favorite performance counters to watch to better isolate this?
We are trying to convert to using RS exclusively for our reports, but this performance may prevent
us from doing so - any help would be appreciated!
Thanks to all,
JamiIn general, the rules around RDL are much more complex than that of Access.
So much of the time may be in processing, not rendering. What is the time
for XML? Also, what type of data regions are you using (list, table,
matrix?).
Nonetheless, we will continue to work on both performance and size for
future releases.
--
Brian Welcker
Group Program Manager
SQL Server Reporting Services
This posting is provided "AS IS" with no warranties, and confers no rights.
"Jami Bradley" <jbradley@.isa-og.com> wrote in message
news:vv3pd0hd8qupdap37f9e5rqn5c6pupi63k@.4ax.com...
> Hi,
> We have been working with some lrge PDF reports (200-400 pages) and have
> been anxiously awaiting
> SP1 because of performance problems we have been having.
> Our initial tests show that the performance is better: Given about 3000
> records from SQL Server,
> we generated a 272 page report.
> Pre SP1: 4 minutes 35 seconds
> With SP: 2 minutes 5 second.
> So it is just over twice as fast. I also noticed that it is consuming
> less memory (roughly down
> from 700MB to 400MB)
> We still would like to get the performance much better and I'm looking for
> help to understand the
> process and what we can do. In the past, running this report in MS Access
> and using ActivePDF took
> 10-20 seconds to generate the same report. Why is there such a disparity?
> The SQL Query is taking 1-2 seconds at most, then all of the time is spent
> in aspnet_wp - all CPU,
> negligible disk I/O. How do you suggest we identify the time spent?
> Are there any tricks to making the report more efficient so that the PDF
> render time is better? Do
> you have some favorite performance counters to watch to better isolate
> this?
> We are trying to convert to using RS exclusively for our reports, but this
> performance may prevent
> us from doing so - any help would be appreciated!
> Thanks to all,
> Jami
>|||We timed the XML output and it was just over 2 *seconds*. Our report is a list with sublists.
If you have any tips that may avoid performance issues with our reports, please let us know.
Thanks!
Jami
On Sat, 26 Jun 2004 00:25:50 -0700, "Brian Welcker [MSFT]" <bwelcker@.online.microsoft.com> wrote:
>In general, the rules around RDL are much more complex than that of Access.
>So much of the time may be in processing, not rendering. What is the time
>for XML? Also, what type of data regions are you using (list, table,
>matrix?).
>Nonetheless, we will continue to work on both performance and size for
>future releases.|||Well, XML is much easier than PDF. One thing that you should probably look
at is converting some of your report to tables instead of lists. Tables can
sometimes be faster to render.
--
Brian Welcker
Group Program Manager
SQL Server Reporting Services
This posting is provided "AS IS" with no warranties, and confers no rights.
"Jami Bradley" <jbradley@.isa-og.com> wrote in message
news:cfc0e0ld0j45b4tbl6ic32tvskcod2ff3t@.4ax.com...
> We timed the XML output and it was just over 2 *seconds*. Our report is a
> list with sublists.
> If you have any tips that may avoid performance issues with our reports,
> please let us know.
> Thanks!
> Jami
> On Sat, 26 Jun 2004 00:25:50 -0700, "Brian Welcker [MSFT]"
> <bwelcker@.online.microsoft.com> wrote:
>>In general, the rules around RDL are much more complex than that of
>>Access.
>>So much of the time may be in processing, not rendering. What is the time
>>for XML? Also, what type of data regions are you using (list, table,
>>matrix?).
>>Nonetheless, we will continue to work on both performance and size for
>>future releases.
>|||We have been doing some testing with one of our reports and found a few interesting things. Here
is the basic information on what we did and how it affected the PDF size and PDF render
performance. All of the reports we ran were dominated by PDF render (checked in the execution
log). We were unable to get adequate performance from this report, so we solved this with a
different product, but I hope the information is useful to others.
All of these tests were using Report Manager - the processing time is the time for 'View Report' to
preview in IE, the PDF render time is the time to export to PDF from Report Manager.
A. Baseline Report (original form, desired report format):
10-15 seconds processing, 5:27 in PDF render, 508 pages, 10.6MB
B. Removed grouping and sub-report:
11 seconds processing, 2:10 in PDF render, 508 pages, 10.2MB
C. B with all details line drawing removed, and no logo (now a plain text report):
9 seconds processing, 1:00 in PDF render, 402 pages, 2.6MB
D. C with no line drawing in page header, avoiding overlapping text:
11 seconds processing, 52 in PDF render, 402 pages, 2.01MB
E. D with two fields removed (fairly complex nested iif expressions):
8 seconds processing, 46 in PDF render, 402 pages, 1.92MB
Items C, D, E had slightly different queries which reduced the row count from about 4500 to about
4000. Too bad I saw this late! I retested E with the proper row count to get the following
results:
E2. Corrected where clause to get all the rows:
9 seconds processing, 1:15 in PDF render, 451 pages, 2.16MB
So the conclusions? Grouping is dominating the time to get this report rendered (our grouping
simply puts a header line between groups). Line drawing makes the PDF significantly larger - this
is not too surpising, but other products seem to do this much more efficiently.
Good luck,
Jami
On Mon, 28 Jun 2004 22:43:17 -0700, "Brian Welcker [MSFT]" <bwelcker@.online.microsoft.com> wrote:
>Well, XML is much easier than PDF. One thing that you should probably look
>at is converting some of your report to tables instead of lists. Tables can
>sometimes be faster to render.

Monday, March 26, 2012

PDF Error: Urgent

When I try to export it to PDF; I get an error "There was an error opening
this document.This file cannot be found."
The same report was working fine last month.
Export To Excel Works FineClear Temporary Internet Folder
"Sudha" wrote:
> When I try to export it to PDF; I get an error "There was an error opening
> this document.This file cannot be found."
> The same report was working fine last month.
> Export To Excel Works Fine
>

Friday, March 23, 2012

PB using UNION ALL with VB6 and SQL-server

I'm working on a softwear and I have to create some Update. This softwear used first MS Access as a database, and now I have to create the code which allows it to use MS SQL-server. This softwear is created in VB6.

I've got some error when I'm using the UNION ALL function. This error appears:
"incorrect syntax towards the key word ' union' "

Here is the code in VB6 :

" GOpenLocalDb (FOR_READ) ' open the database

SQLStmt = "select * from ol_table_temp"
SQLStmt = SQLStmt & " where [Subject_no] = " & dlr_subject & " "
ord$ = SQL_Order()
SQLStmt = SQLStmt & ord$

'dalafouzos: 24/09/2002 I added the lines below to include the DLR entries in the ol_old table
SQLStmt = SQLStmt & " union all select * from ol_table_old where [Subject_no] = " & dlr_subject & " "
ord$ = SQL_Order()
SQLStmt = SQLStmt & ord$

'GOpenLocalDb (FOR_READ) ' open the database
Set DLRset = New ADODB.Recordset
DLRset.CursorLocation = adUseClient
DLRset.Open SQLStmt, g_objConn, adOpenKeyset, adLockReadOnly, adCmdText "

when the error appears the value of SQLStmt is :

"select * from ol_table_temp where [Subject_no] = 1020 Order by [Date] DESC, [Time] DESC union all select * from ol_table_old where [Subject_no] = 1020 Order by [Date] DESC, [Time] DESC "

Thanks for your help...and both tables has the same DDL?|||I think so. Both of them are similar...but how can I see if they have the same DDL? because I'm not sure as I didn't have to create these tables.

But this syntaxe works well with MS Access...the problem appears only with MS SQL-server.sql

Wednesday, March 21, 2012

patindex with nvarchar

Hi Microsoft,

My Name is Harshal Choksi. i am working in microsoft technolgy in .NET and SQL Server 2000. we are storing some unicode data in database in table which has a nvarchar data types. i have written one function in SQL which contains some T-Transact function like SubString, Len & PatIndex. in which i m not getting any value with PatIndex, it shows me always column with 0 value.

Means my patindex is not working well if i have 'hindi text'.

GO
SELECT PATINDEX ('%??????%', keyword)

FROM tblKeywords where keywordID = 68
GO

where i tblKeyword is a tableName and keyword is a column name. "??????" is text what my parameter in function .keyword is column name which has a datatype NVARCHAR. i m getting result with in result wizard 0 each time, instead of "??????", if i write something "London",then it will show me right value.

so please help in this manner. i would be feel great if you would me help so. i have to implement some search functionality with hindi word..... i could use Contains keyword in SQL in wheere condion but i want to use patIndex only. so help me as soon as possible....

I will be waiting for your reply.

Thanks in advance.

You have to put N prefix on Nvarchar String values

See the sample here..

Code Snippet

SELECT PATINDEX ('%??????%', N'??????????????')

--Output : 0

SELECT PATINDEX (N'%??????%', N'??????????????')

--Output : 9

--InYour Query

SELECT

PATINDEX (N'%??????%', keyword)

FROM

tblKeywords where keywordID = 68

|||

Hi Manivannan, Thanks for your help.. yet still not getting output. i have written function is SQL as below,u might have some sort of idea about it. & this function i m using in my stored procedure... which also i am mentioning below this SQL function.

--SQL Function

SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO

--
-- GetKeywordsFromQuery(query)
-- SUMMARY Parses a full-text query for keywords that can be used in a keyword (rather
-- than full-text) search
-- PARAMS query Query containing one or more keywords
-- RETURNS A temporary TABLE containing the found keywords
--
ALTER FUNCTION GetKeywordsFromQuery
(
@.query nvarchar(255)
)
RETURNS @.words TABLE (Word nvarchar(255)COLLATE DATABASE_Default)
AS
BEGIN
-- Define processing flags
-- NOTE A processing flag is used to ensure that words are excluded from
-- NOTE the results if they are preceeded with a "NOT" or that a complete
-- NOTE phrase is added as a whole (rather than seperate words)
DECLARE @.isNotWord bit
SET @.isNotWord = 0
DECLARE @.isPhrase bit
SET @.isPhrase = 0
-- Define word variables
DECLARE @.word AS nvarchar(255)
DECLARE @.phrase AS nvarchar(255)
DECLARE @.substring AS nvarchar(255)
SET @.substring = @.query
-- Find the first space
DECLARE @.spacePosition AS bigint
SET @.spacePosition = PATINDEX(N'% %', @.query)
-- Iterate over the query until all words have been found
WHILE 0 <= @.spacePosition
BEGIN
-- Get the next word in the query
IF(0 != @.spacePosition)
SET @.word = SUBSTRING(@.substring, 1, (@.spacePosition -1))
ELSE
BEGIN
SET @.word = @.substring
SET @.spacePosition = -1
END
-- Check for a phrase
IF(N'"' = SUBSTRING(@.word, 1, 1))
BEGIN
-- Start the phrase
SET @.isPhrase = 1
SET @.phrase = SUBSTRING(@.word, 2, LEN(@.word) - 1)
END
ELSE IF(N'"' = SUBSTRING(@.word, LEN(@.word), 1))
BEGIN
-- Complete the phrase
SET @.isPhrase = 0
SET @.phrase = @.phrase + SPACE(1) + SUBSTRING(@.word, 1, LEN(@.word) - 1)
SET @.word = @.phrase
END

ELSE IF(1 = @.isPhrase)
-- Append the current word to the phrase
SET @.phrase = @.phrase + SPACE(1) + @.word
-- Add the word to temporary table
IF (UPPER('NEAR') != UPPER(@.word))
AND (UPPER('AND') != UPPER(@.word))
AND (UPPER('NOT') != UPPER(@.word))
AND (0 = @.isNotWord)
AND (0 = @.isPhrase)
BEGIN
-- This word can be used to search for keywords
INSERT @.words VALUES(@.word)
SET @.isNotWord = 0
END
-- Reset the "Not Word" exclusion flag
-- NOTE This is for cases where an AND or NEAR follows an AND NOT
ELSE IF (UPPER('NEAR') = UPPER(@.word))
OR (UPPER('AND') = UPPER(@.word))
SET @.isNotWord = 0
-- Indicate that the next word needs to be excluded
ELSE IF (UPPER('NOT') = UPPER(@.word))
SET @.isNotWord = 1
-- Move on to the next word or exit the WHILE
SET @.substring = SUBSTRING(@.substring, (@.spacePosition + 1), LEN(@.substring) - (@.spacePosition))
IF(-1 != @.spacePosition)
SET @.spacePosition = PATINDEX(N'% %', @.substring)
END
RETURN
END

GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

--

Here this is my sp:

SELECT DISTINCT c.ContentName, c.ContentLongSummary, c.MasterId, nc.NavigationId
FROM tblContents AS c
INNER JOIN tblKeywords AS k ON k.KeywordId = c.KeywordId
INNER JOIN GetKeywordsFromQuery(@.query) AS kq ON kq.Word = k.Keyword
WHERE c.SiteId = @.siteId
AND c.StatusID = 2
AND c.DeletedBy IS NULL

so i have to sort out this this thing as well,can you please look at thru my function as well stored procedure.

Thanks in Advance.

|||

so please give me solution as possible, here i have written my stored procedure as below which use above function:

I am using for all column nvarchar only in which i stored hindi text and English as well.

SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO


--
-- spSearch
-- SUMMARY Executes a search using the specified query
-- PARAMS @.siteId Identifier of the site from which the search request was generated
-- @.query Full-text query to be executed against the full-text engine
--
ALTER PROCEDURE spSearch
(
@.siteId INT,
@.textOnly BIT,
@.query NVARCHAR(4000)
)
AS
-- Select Alternatives
Declare @.partialQuery NVARCHAR(50)
Declare @.keyphrase NVARCHAR(50)
--Query can be provided like 'searchterm' or as "search term" depending in existance of space character
--must format the partial query if it contains a space like '"search term*"'
--the keyphrase is @.query without quotes
IF CHARINDEX('"',@.query) > 0
BEGIN
SET @.partialQuery = LEFT(@.query, LEN(@.query) - 1) + '*"'
SET @.keyphrase = LEFT(RIGHT(@.query, LEN(@.query) - 1), LEN(@.query) - 2)
END
ELSE
BEGIN
--must format the partial query like '"searchterm*"'
set @.partialQuery = ' "' + @.query + '*" '
set @.keyphrase = @.query
END

--Now we can search for alternatives as exact match of @.query on alternatives
--or partial match on keyword, but ignore exact match on keyword (i.e. only alternatives to @.query)
SELECT *
FROM tblKeywords
WHERE NOT Keyword = @.keyphrase
AND SiteId = @.siteId
AND (
CONTAINS(Keyword, @.partialQuery )
)


-- Select the pages that match the query
SELECT DISTINCT c.ContentName, c.ContentLongSummary, c.MasterId, nc.NavigationId
FROM tblContents AS c
INNER JOIN trelKeywords AS ck ON ck.MasterId = c.MasterId
INNER JOIN tblKeywords AS k ON k.KeywordId = ck.KeywordId
INNER JOIN trelNavigationContents AS nc ON nc.MasterId = c.MasterId
INNER JOIN GetKeywordsFromQuery(@.query) AS kq ON kq.Word = k.Keyword
INNER JOIN tblNavigation AS nav ON nc.NavigationId = nav.NavigationId
WHERE c.SiteId = @.siteId
AND c.StatusID = 2
AND c.DeletedBy IS NULL
AND ( (@.textOnly=0) or (nav.ExcludeFromTextSite=0 and @.textOnly=1) )
UNION -- the following selects list pages that match, with primarylist page as their navigationid
SELECT DISTINCT c.ContentName, c.ContentLongSummary, c.MasterId, nc.NavigationId
FROM tblContents AS c
INNER JOIN trelKeywords AS ck ON ck.MasterId = c.MasterId
INNER JOIN tblKeywords AS k ON k.KeywordId = ck.KeywordId
INNER JOIN tblContents AS c1 ON c.PrimaryListMasterId = c1.MasterId
INNER JOIN trelNavigationContents AS nc ON nc.MasterId = c1.MasterId
INNER JOIN GetKeywordsFromQuery(@.query) AS kq ON kq.Word = k.Keyword
INNER JOIN tblNavigation AS nav ON nc.NavigationId = nav.NavigationId
INNER JOIN tblListContents AS lst ON lst.ListItemMasterId = c.MasterId
WHERE c.SiteId = @.siteId
AND c.DeletedBy IS NULL
AND c.StatusID = 2
AND c1.statusid = 2
AND c1.DeletedBy IS NULL
AND ( (@.textOnly=0) or (nav.ExcludeFromTextSite=0 and @.textOnly=1) )
AND lst.ContentMasterId = c.PrimaryListMasterId

-- Select the downloads that match the query
SELECT DISTINCT r.ResourceId, r.ResourceName, r.ResourceLongSummary, r.FileSize
FROM tblResources AS r
INNER JOIN trelKeywordResources AS kr ON kr.ResourceId = r.ResourceId
INNER JOIN tblKeywords AS k ON k.KeywordId = kr.KeywordId
INNER JOIN GetKeywordsFromQuery(@.query) AS kq ON kq.Word = k.Keyword
INNER JOIN trelContentItemResources AS cir ON r.ResourceId = cir.ResourceId
WHERE r.ResourceTypeId = 2
AND r.SiteId = @.siteId
AND cir.StatusId = 2

SELECT CASE WHEN nc.MasterId IS NULL THEN cir.MasterId ELSE nc.MasterId END AS MasterId, CASE WHEN nc.MasterId IS NULL
THEN ln.NavigationId ELSE nc.NavigationId END AS NavigationId, c.ContentName, res.ResourceId, res.ResourceTextType, res.ResourceText,
c.ContentLongSummary
FROM tblResources res INNER JOIN
trelContentItemResources cir ON cir.ResourceId = res.ResourceId
LEFT OUTER JOIN trelNavigationContents nc ON nc.MasterId = cir.MasterId
LEFT OUTER JOIN tblContents c ON c.MasterId = cir.MasterId AND c.StatusId = cir.StatusId
LEFT OUTER JOIN trelNavigationContents ln ON c.PrimaryListMasterId = ln.MasterId
LEFT OUTER JOIN tblNavigation nav ON nc.NavigationId = nav.NavigationId
INNER JOIN tlkpResourceTypes rt ON rt.ResourceTypeId = res.ResourceTypeId
INNER JOIN tblListContents AS lst ON lst.ListItemMasterId = c.MasterId
WHERE (res.SiteId = @.siteId)
AND (res.ResourceTypeId = 1 OR res.ResourceTypeId = 6)
AND CONTAINS(res.ResourceText, @.query)
AND (c.ContentPublicationDate IS NOT NULL)
AND (c.DeletedBy IS NULL)
AND (c.StatusId = 2)
AND (nc.MasterId IS NOT NULL)
AND ( (@.textOnly=0) or (nav.ExcludeFromTextSite=0 and @.textOnly=1) )
OR
(res.SiteId = @.siteId)
AND (res.ResourceTypeId = 1 OR res.ResourceTypeId = 6)
AND CONTAINS(res.ResourceText, @.query)
AND (c.ContentPublicationDate IS NOT NULL)
AND (c.DeletedBy IS NULL)
AND (c.StatusId = 2)
AND (c.PrimaryListMasterId IS NOT NULL)
AND ( (@.textOnly=0) or (nav.ExcludeFromTextSite=0 and @.textOnly=1) )
ORDER BY rt.SearchResultOrder, c.ContentName

GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

|||

Your query is working fine on my mac..

I tried with following statement ...

Code Snippet

Select * From dbo.GetKeywordsFromQuery(N'"SQL Server" is "very good" AND "very Powerfull" ?????? ?????? AND ?????? ????????????????????????')

OUTPUT:

Word

-

SQL Server

is

very good

very Powerfull

??????

??????

??????

????????????????????????

What I am doubting here is @.QUERY parameter.

Pls check the datatype. And when you call the SP you should prefix the N.

Example:

Code Snippet

Exec dbo.YourSP @.query = N'"SQL Server" is "very good" AND "very Powerfull" ?????? ?????? AND ?????? ????????????????????????')

|||

yeah thanks for your help,but can you check my storedProcedure as well?

Please look at it & if you have any idea of it.

__

SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO


--
-- spSearch
-- SUMMARY Executes a search using the specified query
-- PARAMS @.siteId Identifier of the site from which the search request was generated
-- @.query Full-text query to be executed against the full-text engine
--
ALTER PROCEDURE spSearch
(
@.siteId INT,
@.textOnly BIT,
@.query NVARCHAR(4000)
)
AS
-- Select Alternatives
Declare @.partialQuery NVARCHAR(50)
Declare @.keyphrase NVARCHAR(50)
--Query can be provided like 'searchterm' or as "search term" depending in existance of space character
--must format the partial query if it contains a space like '"search term*"'
--the keyphrase is @.query without quotes
IF CHARINDEX(N'"',@.query) > 0
BEGIN
SET @.partialQuery = LEFT(@.query, LEN(@.query) - 1) + N'*"'
SET @.keyphrase = LEFT(RIGHT(@.query, LEN(@.query) - 1), LEN(@.query) - 2)
END
ELSE
BEGIN
--must format the partial query like '"searchterm*"'
set @.partialQuery = N' "' + @.query + N'*" '
set @.keyphrase = @.query
END

--Now we can search for alternatives as exact match of @.query on alternatives
--or partial match on keyword, but ignore exact match on keyword (i.e. only alternatives to @.query)
SELECT *
FROM tblKeywords
WHERE NOT Keyword = @.keyphrase
AND SiteId = @.siteId
AND (
CONTAINS(Keyword, @.partialQuery )
)


-- Select the pages that match the query
SELECT DISTINCT c.ContentName, c.ContentLongSummary, c.MasterId, nc.NavigationId
FROM tblContents AS c
INNER JOIN trelKeywords AS ck ON ck.MasterId = c.MasterId
INNER JOIN tblKeywords AS k ON k.KeywordId = ck.KeywordId
INNER JOIN trelNavigationContents AS nc ON nc.MasterId = c.MasterId
INNER JOIN GetKeywordsFromQuery (@.query) AS kq ON kq.Word = k.Keyword
INNER JOIN tblNavigation AS nav ON nc.NavigationId = nav.NavigationId
WHERE c.SiteId = @.siteId
AND c.StatusID = 2
AND c.DeletedBy IS NULL
AND ( (@.textOnly=0) or (nav.ExcludeFromTextSite=0 and @.textOnly=1) )
UNION -- the following selects list pages that match, with primarylist page as their navigationid
SELECT DISTINCT c.ContentName, c.ContentLongSummary, c.MasterId, nc.NavigationId
FROM tblContents AS c
INNER JOIN trelKeywords AS ck ON ck.MasterId = c.MasterId
INNER JOIN tblKeywords AS k ON k.KeywordId = ck.KeywordId
INNER JOIN tblContents AS c1 ON c.PrimaryListMasterId = c1.MasterId
INNER JOIN trelNavigationContents AS nc ON nc.MasterId = c1.MasterId
INNER JOIN GetKeywordsFromQuery (@.query) AS kq ON kq.Word = k.Keyword
INNER JOIN tblNavigation AS nav ON nc.NavigationId = nav.NavigationId
INNER JOIN tblListContents AS lst ON lst.ListItemMasterId = c.MasterId
WHERE c.SiteId = @.siteId
AND c.DeletedBy IS NULL
AND c.StatusID = 2
AND c1.statusid = 2
AND c1.DeletedBy IS NULL
AND ( (@.textOnly=0) or (nav.ExcludeFromTextSite=0 and @.textOnly=1) )
AND lst.ContentMasterId = c.PrimaryListMasterId

-- Select the downloads that match the query
SELECT DISTINCT r.ResourceId, r.ResourceName, r.ResourceLongSummary, r.FileSize
FROM tblResources AS r
INNER JOIN trelKeywordResources AS kr ON kr.ResourceId = r.ResourceId
INNER JOIN tblKeywords AS k ON k.KeywordId = kr.KeywordId
INNER JOIN GetKeywordsFromQuery (@.query) AS kq ON kq.Word = k.Keyword
INNER JOIN trelContentItemResources AS cir ON r.ResourceId = cir.ResourceId
WHERE r.ResourceTypeId = 2
AND r.SiteId = @.siteId
AND cir.StatusId = 2

SELECT CASE WHEN nc.MasterId IS NULL THEN cir.MasterId ELSE nc.MasterId END AS MasterId, CASE WHEN nc.MasterId IS NULL
THEN ln.NavigationId ELSE nc.NavigationId END AS NavigationId, c.ContentName, res.ResourceId, res.ResourceTextType, res.ResourceText,
c.ContentLongSummary
FROM tblResources res INNER JOIN
trelContentItemResources cir ON cir.ResourceId = res.ResourceId
LEFT OUTER JOIN trelNavigationContents nc ON nc.MasterId = cir.MasterId
LEFT OUTER JOIN tblContents c ON c.MasterId = cir.MasterId AND c.StatusId = cir.StatusId
LEFT OUTER JOIN trelNavigationContents ln ON c.PrimaryListMasterId = ln.MasterId
LEFT OUTER JOIN tblNavigation nav ON nc.NavigationId = nav.NavigationId
INNER JOIN tlkpResourceTypes rt ON rt.ResourceTypeId = res.ResourceTypeId
INNER JOIN tblListContents AS lst ON lst.ListItemMasterId = c.MasterId
WHERE (res.SiteId = @.siteId)
AND (res.ResourceTypeId = 1 OR res.ResourceTypeId = 6)
AND CONTAINS(res.ResourceText, @.query)
AND (c.ContentPublicationDate IS NOT NULL)
AND (c.DeletedBy IS NULL)
AND (c.StatusId = 2)
AND (nc.MasterId IS NOT NULL)
AND ( (@.textOnly=0) or (nav.ExcludeFromTextSite=0 and @.textOnly=1) )
OR
(res.SiteId = @.siteId)
AND (res.ResourceTypeId = 1 OR res.ResourceTypeId = 6)
AND CONTAINS(res.ResourceText, @.query)
AND (c.ContentPublicationDate IS NOT NULL)
AND (c.DeletedBy IS NULL)
AND (c.StatusId = 2)
AND (c.PrimaryListMasterId IS NOT NULL)
AND ( (@.textOnly=0) or (nav.ExcludeFromTextSite=0 and @.textOnly=1) )
ORDER BY rt.SearchResultOrder, c.ContentName

GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

you call the SP you should prefix the N

in this sp, i m using three times that function. even i m not getting how to call the sp with it should have prefix the N....please let me know. i am just waiting for your reply.even i have using NVARCHAR whereever i stored a hindi text...i hope you have already seen my function.please do the needful. i have tried lot since few days on this, still couldn't get the right solution.

|||

can u tell me how you are executing your sp ..

I need the Exec spSearch .... statement

|||

well i don't have written something like Exec spSearch statement, actually i m calling this function from my ASP.NET application that's all. passing a 3 parameters and wanted to get results accordingly. Waiting for your reply.

Thanks Again for your response.

|||

hey check your ASP.NET code, the param declaration. It should be NVARCHAR.

Test your SP from Query Analyser using EXEC statement.. So you can validate where the problem resides.

|||

well,even not my sp giving me results at all if i pass a parameters,i checked using Exec statement also,not getting result..in ASP.NET i have written someting:--

public virtual SafeSqlDataReader GetSearchResults(int siteId, bool textOnly, string input)

{

// Define the command

SqlCommand command = new SqlCommand();

command.CommandType = CommandType.StoredProcedure;

command.CommandText = StoredProcedures.spSearch.ToString();

// Set the parameters

command.Parameters.Add("@.siteId", siteId);

command.Parameters.Add("@.textOnly", textOnly);

command.Parameters.Add("@.query", input);

command.Connection = SqlHelperWrapper.OpenConnection(this.ConnectionString);

return new SafeSqlDataReader(command);

}

so not getting a problem where it might be? if i have declared varchar here also then problem still remain same for the Stored Procedure because not giving me result at all if i pass a parameter in stored procedure,so problem is with sp and then we solved a problem with our code.

waiting for your reply.

|||

Hi still i am waiting for your response. Let me know if any solution you have for this, i am not getting this thing, i have written in my .NET code varchar , but if i pass parameters for hindi, not getting a results at all. so stored procedure may have some problem.

Please give me any solution for this.

Waiting for your response soon.

|||

how is it work with Patindex if i have one column which have data type 'Image', i want to search some hindi text within that, i have written a function in SQL which contains some Patindex and some string function as well. i have written something like:- PATINDEX(N'% %', @.query), but i want to find a some value with the help of stored procesedure:

here is my query which is a part of my stored procedure:

_

SELECT DISTINCT r.ResourceId, r.ResourceName, r.ResourceLongSummary, r.FileSize
FROM tblResources AS r
INNER JOIN trelKeywordResources AS kr ON kr.ResourceId = r.ResourceId
INNER JOIN tblKeywords AS k ON k.KeywordId = kr.KeywordId
INNER JOIN GetKeywordsFromQuery(@.query) AS kq ON kq.Word = k.Keyword
INNER JOIN trelContentItemResources AS cir ON r.ResourceId = cir.ResourceId
WHERE r.ResourceTypeId = 2
AND r.SiteId = @.siteId
AND cir.StatusId = 2
AND k.SiteId = @.siteId

SELECT CASE WHEN nc.MasterId IS NULL THEN cir.MasterId ELSE nc.MasterId END AS MasterId, CASE WHEN nc.MasterId IS NULL
THEN ln.NavigationId ELSE nc.NavigationId END AS NavigationId, c.ContentName, res.ResourceId, res.ResourceTextType, res.ResourceText,
c.ContentLongSummary
FROM tblResources res INNER JOIN
trelContentItemResources cir ON cir.ResourceId = res.ResourceId
LEFT OUTER JOIN trelNavigationContents nc ON nc.MasterId = cir.MasterId
LEFT OUTER JOIN tblContents c ON c.MasterId = cir.MasterId AND c.StatusId = cir.StatusId
LEFT OUTER JOIN trelNavigationContents ln ON c.PrimaryListMasterId = ln.MasterId
LEFT OUTER JOIN tblNavigation nav ON nc.NavigationId = nav.NavigationId
INNER JOIN tlkpResourceTypes rt ON rt.ResourceTypeId = res.ResourceTypeId
INNER JOIN tblListContents AS lst ON lst.ListItemMasterId = c.MasterId
WHERE (res.SiteId = @.siteId)
AND (res.ResourceTypeId = 1 OR res.ResourceTypeId = 6)
AND CONTAINS(res.ResourceText, @.query)
AND (c.ContentPublicationDate IS NOT NULL)
AND (c.DeletedBy IS NULL)
AND (c.StatusId = 2)
AND (nc.MasterId IS NOT NULL)
AND ( (@.textOnly=0) or (nav.ExcludeFromTextSite=0 and @.textOnly=1) )
OR
(res.SiteId = @.siteId)
AND (res.ResourceTypeId = 1 OR res.ResourceTypeId = 6)
AND CONTAINS(res.ResourceText, @.query)
AND (c.ContentPublicationDate IS NOT NULL)
AND (c.DeletedBy IS NULL)
AND (c.StatusId = 2)
AND (c.PrimaryListMasterId IS NOT NULL)
AND ( (@.textOnly=0) or (nav.ExcludeFromTextSite=0 and @.textOnly=1) )
ORDER BY rt.SearchResultOrder, c.ContentName

__

where ResourceText is having a datatype 'Image', so could you tell me how to use that function as well.

i will be waiting for your response soon.

Thanking You.

|||

Are you using Image datatype for storing information .. .

You can't do any Text/String manipulation on Image datatype.

Can I know why you are using image datatype here.

|||

yeah we have taken its an image data type because we have an editor somethning like this in which we are writing but it may have some image as well. so we taken as image data type.

0x4C6F6E646F6E206973206120636974792E3C7370616E207374796C653D22464F4E542D53495A453A2031307074223E203C703EE0A4B5E0A4BEE0A4B2E0A58DE0A4AEE0A580E0A495E0A4BF3C2F703E3C2F7370616E3E

i am having some value like that in Resource Text. so we have an editor complety & we are storing some text as well as possible to stored images as well in editor. but if we find english keyword then it works fine, else it is not suported with hindi keyword. so tell me solution.

|||

HarshalChoksi wrote:

but if we find english keyword then it works fine, else it is not suported with hindi keyword. so tell me solution.

This is not bcs of the SQL server. There is a problem on your Resource Text.

The Unicode english codes & ASCII codes are same. So it will work fine. But your Building the Resource Text somehow failed to create a Unicode text.

You have to look the solution on that area.. Not in SQL Server

patindex with nvarchar

Hi Microsoft,

My Name is Harshal Choksi. i am working in microsoft technolgy in .NET and SQL Server 2000. we are storing some unicode data in database in table which has a nvarchar data types. i have written one function in SQL which contains some T-Transact function like SubString, Len & PatIndex. in which i m not getting any value with PatIndex, it shows me always column with 0 value.

Means my patindex is not working well if i have 'hindi text'.

GO
SELECT PATINDEX ('%??????%', keyword)

FROM tblKeywords where keywordID = 68
GO

where i tblKeyword is a tableName and keyword is a column name. "??????" is text what my parameter in function .keyword is column name which has a datatype NVARCHAR. i m getting result with in result wizard 0 each time, instead of "??????", if i write something "London",then it will show me right value.

so please help in this manner. i would be feel great if you would me help so. i have to implement some search functionality with hindi word..... i could use Contains keyword in SQL in wheere condion but i want to use patIndex only. so help me as soon as possible....

I will be waiting for your reply.

Thanks in advance.

You have to put N prefix on Nvarchar String values

See the sample here..

Code Snippet

SELECT PATINDEX ('%??????%', N'??????????????')

--Output : 0

SELECT PATINDEX (N'%??????%', N'??????????????')

--Output : 9

--InYour Query

SELECT

PATINDEX (N'%??????%', keyword)

FROM

tblKeywords where keywordID = 68

|||

Hi Manivannan, Thanks for your help.. yet still not getting output. i have written function is SQL as below,u might have some sort of idea about it. & this function i m using in my stored procedure... which also i am mentioning below this SQL function.

--SQL Function

SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO

--
-- GetKeywordsFromQuery(query)
-- SUMMARY Parses a full-text query for keywords that can be used in a keyword (rather
-- than full-text) search
-- PARAMS query Query containing one or more keywords
-- RETURNS A temporary TABLE containing the found keywords
--
ALTER FUNCTION GetKeywordsFromQuery
(
@.query nvarchar(255)
)
RETURNS @.words TABLE (Word nvarchar(255)COLLATE DATABASE_Default)
AS
BEGIN
-- Define processing flags
-- NOTE A processing flag is used to ensure that words are excluded from
-- NOTE the results if they are preceeded with a "NOT" or that a complete
-- NOTE phrase is added as a whole (rather than seperate words)
DECLARE @.isNotWord bit
SET @.isNotWord = 0
DECLARE @.isPhrase bit
SET @.isPhrase = 0
-- Define word variables
DECLARE @.word AS nvarchar(255)
DECLARE @.phrase AS nvarchar(255)
DECLARE @.substring AS nvarchar(255)
SET @.substring = @.query
-- Find the first space
DECLARE @.spacePosition AS bigint
SET @.spacePosition = PATINDEX(N'% %', @.query)
-- Iterate over the query until all words have been found
WHILE 0 <= @.spacePosition
BEGIN
-- Get the next word in the query
IF(0 != @.spacePosition)
SET @.word = SUBSTRING(@.substring, 1, (@.spacePosition -1))
ELSE
BEGIN
SET @.word = @.substring
SET @.spacePosition = -1
END
-- Check for a phrase
IF(N'"' = SUBSTRING(@.word, 1, 1))
BEGIN
-- Start the phrase
SET @.isPhrase = 1
SET @.phrase = SUBSTRING(@.word, 2, LEN(@.word) - 1)
END
ELSE IF(N'"' = SUBSTRING(@.word, LEN(@.word), 1))
BEGIN
-- Complete the phrase
SET @.isPhrase = 0
SET @.phrase = @.phrase + SPACE(1) + SUBSTRING(@.word, 1, LEN(@.word) - 1)
SET @.word = @.phrase
END

ELSE IF(1 = @.isPhrase)
-- Append the current word to the phrase
SET @.phrase = @.phrase + SPACE(1) + @.word
-- Add the word to temporary table
IF (UPPER('NEAR') != UPPER(@.word))
AND (UPPER('AND') != UPPER(@.word))
AND (UPPER('NOT') != UPPER(@.word))
AND (0 = @.isNotWord)
AND (0 = @.isPhrase)
BEGIN
-- This word can be used to search for keywords
INSERT @.words VALUES(@.word)
SET @.isNotWord = 0
END
-- Reset the "Not Word" exclusion flag
-- NOTE This is for cases where an AND or NEAR follows an AND NOT
ELSE IF (UPPER('NEAR') = UPPER(@.word))
OR (UPPER('AND') = UPPER(@.word))
SET @.isNotWord = 0
-- Indicate that the next word needs to be excluded
ELSE IF (UPPER('NOT') = UPPER(@.word))
SET @.isNotWord = 1
-- Move on to the next word or exit the WHILE
SET @.substring = SUBSTRING(@.substring, (@.spacePosition + 1), LEN(@.substring) - (@.spacePosition))
IF(-1 != @.spacePosition)
SET @.spacePosition = PATINDEX(N'% %', @.substring)
END
RETURN
END

GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

--

Here this is my sp:

SELECT DISTINCT c.ContentName, c.ContentLongSummary, c.MasterId, nc.NavigationId
FROM tblContents AS c
INNER JOIN tblKeywords AS k ON k.KeywordId = c.KeywordId
INNER JOIN GetKeywordsFromQuery(@.query) AS kq ON kq.Word = k.Keyword
WHERE c.SiteId = @.siteId
AND c.StatusID = 2
AND c.DeletedBy IS NULL

so i have to sort out this this thing as well,can you please look at thru my function as well stored procedure.

Thanks in Advance.

|||

so please give me solution as possible, here i have written my stored procedure as below which use above function:

I am using for all column nvarchar only in which i stored hindi text and English as well.

SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO


--
-- spSearch
-- SUMMARY Executes a search using the specified query
-- PARAMS @.siteId Identifier of the site from which the search request was generated
-- @.query Full-text query to be executed against the full-text engine
--
ALTER PROCEDURE spSearch
(
@.siteId INT,
@.textOnly BIT,
@.query NVARCHAR(4000)
)
AS
-- Select Alternatives
Declare @.partialQuery NVARCHAR(50)
Declare @.keyphrase NVARCHAR(50)
--Query can be provided like 'searchterm' or as "search term" depending in existance of space character
--must format the partial query if it contains a space like '"search term*"'
--the keyphrase is @.query without quotes
IF CHARINDEX('"',@.query) > 0
BEGIN
SET @.partialQuery = LEFT(@.query, LEN(@.query) - 1) + '*"'
SET @.keyphrase = LEFT(RIGHT(@.query, LEN(@.query) - 1), LEN(@.query) - 2)
END
ELSE
BEGIN
--must format the partial query like '"searchterm*"'
set @.partialQuery = ' "' + @.query + '*" '
set @.keyphrase = @.query
END

--Now we can search for alternatives as exact match of @.query on alternatives
--or partial match on keyword, but ignore exact match on keyword (i.e. only alternatives to @.query)
SELECT *
FROM tblKeywords
WHERE NOT Keyword = @.keyphrase
AND SiteId = @.siteId
AND (
CONTAINS(Keyword, @.partialQuery )
)


-- Select the pages that match the query
SELECT DISTINCT c.ContentName, c.ContentLongSummary, c.MasterId, nc.NavigationId
FROM tblContents AS c
INNER JOIN trelKeywords AS ck ON ck.MasterId = c.MasterId
INNER JOIN tblKeywords AS k ON k.KeywordId = ck.KeywordId
INNER JOIN trelNavigationContents AS nc ON nc.MasterId = c.MasterId
INNER JOIN GetKeywordsFromQuery(@.query) AS kq ON kq.Word = k.Keyword
INNER JOIN tblNavigation AS nav ON nc.NavigationId = nav.NavigationId
WHERE c.SiteId = @.siteId
AND c.StatusID = 2
AND c.DeletedBy IS NULL
AND ( (@.textOnly=0) or (nav.ExcludeFromTextSite=0 and @.textOnly=1) )
UNION -- the following selects list pages that match, with primarylist page as their navigationid
SELECT DISTINCT c.ContentName, c.ContentLongSummary, c.MasterId, nc.NavigationId
FROM tblContents AS c
INNER JOIN trelKeywords AS ck ON ck.MasterId = c.MasterId
INNER JOIN tblKeywords AS k ON k.KeywordId = ck.KeywordId
INNER JOIN tblContents AS c1 ON c.PrimaryListMasterId = c1.MasterId
INNER JOIN trelNavigationContents AS nc ON nc.MasterId = c1.MasterId
INNER JOIN GetKeywordsFromQuery(@.query) AS kq ON kq.Word = k.Keyword
INNER JOIN tblNavigation AS nav ON nc.NavigationId = nav.NavigationId
INNER JOIN tblListContents AS lst ON lst.ListItemMasterId = c.MasterId
WHERE c.SiteId = @.siteId
AND c.DeletedBy IS NULL
AND c.StatusID = 2
AND c1.statusid = 2
AND c1.DeletedBy IS NULL
AND ( (@.textOnly=0) or (nav.ExcludeFromTextSite=0 and @.textOnly=1) )
AND lst.ContentMasterId = c.PrimaryListMasterId

-- Select the downloads that match the query
SELECT DISTINCT r.ResourceId, r.ResourceName, r.ResourceLongSummary, r.FileSize
FROM tblResources AS r
INNER JOIN trelKeywordResources AS kr ON kr.ResourceId = r.ResourceId
INNER JOIN tblKeywords AS k ON k.KeywordId = kr.KeywordId
INNER JOIN GetKeywordsFromQuery(@.query) AS kq ON kq.Word = k.Keyword
INNER JOIN trelContentItemResources AS cir ON r.ResourceId = cir.ResourceId
WHERE r.ResourceTypeId = 2
AND r.SiteId = @.siteId
AND cir.StatusId = 2

SELECT CASE WHEN nc.MasterId IS NULL THEN cir.MasterId ELSE nc.MasterId END AS MasterId, CASE WHEN nc.MasterId IS NULL
THEN ln.NavigationId ELSE nc.NavigationId END AS NavigationId, c.ContentName, res.ResourceId, res.ResourceTextType, res.ResourceText,
c.ContentLongSummary
FROM tblResources res INNER JOIN
trelContentItemResources cir ON cir.ResourceId = res.ResourceId
LEFT OUTER JOIN trelNavigationContents nc ON nc.MasterId = cir.MasterId
LEFT OUTER JOIN tblContents c ON c.MasterId = cir.MasterId AND c.StatusId = cir.StatusId
LEFT OUTER JOIN trelNavigationContents ln ON c.PrimaryListMasterId = ln.MasterId
LEFT OUTER JOIN tblNavigation nav ON nc.NavigationId = nav.NavigationId
INNER JOIN tlkpResourceTypes rt ON rt.ResourceTypeId = res.ResourceTypeId
INNER JOIN tblListContents AS lst ON lst.ListItemMasterId = c.MasterId
WHERE (res.SiteId = @.siteId)
AND (res.ResourceTypeId = 1 OR res.ResourceTypeId = 6)
AND CONTAINS(res.ResourceText, @.query)
AND (c.ContentPublicationDate IS NOT NULL)
AND (c.DeletedBy IS NULL)
AND (c.StatusId = 2)
AND (nc.MasterId IS NOT NULL)
AND ( (@.textOnly=0) or (nav.ExcludeFromTextSite=0 and @.textOnly=1) )
OR
(res.SiteId = @.siteId)
AND (res.ResourceTypeId = 1 OR res.ResourceTypeId = 6)
AND CONTAINS(res.ResourceText, @.query)
AND (c.ContentPublicationDate IS NOT NULL)
AND (c.DeletedBy IS NULL)
AND (c.StatusId = 2)
AND (c.PrimaryListMasterId IS NOT NULL)
AND ( (@.textOnly=0) or (nav.ExcludeFromTextSite=0 and @.textOnly=1) )
ORDER BY rt.SearchResultOrder, c.ContentName

GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

|||

Your query is working fine on my mac..

I tried with following statement ...

Code Snippet

Select * From dbo.GetKeywordsFromQuery(N'"SQL Server" is "very good" AND "very Powerfull" ?????? ?????? AND ?????? ????????????????????????')

OUTPUT:

Word

-

SQL Server

is

very good

very Powerfull

??????

??????

??????

????????????????????????

What I am doubting here is @.QUERY parameter.

Pls check the datatype. And when you call the SP you should prefix the N.

Example:

Code Snippet

Exec dbo.YourSP @.query = N'"SQL Server" is "very good" AND "very Powerfull" ?????? ?????? AND ?????? ????????????????????????')

|||

yeah thanks for your help,but can you check my storedProcedure as well?

Please look at it & if you have any idea of it.

__

SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO


--
-- spSearch
-- SUMMARY Executes a search using the specified query
-- PARAMS @.siteId Identifier of the site from which the search request was generated
-- @.query Full-text query to be executed against the full-text engine
--
ALTER PROCEDURE spSearch
(
@.siteId INT,
@.textOnly BIT,
@.query NVARCHAR(4000)
)
AS
-- Select Alternatives
Declare @.partialQuery NVARCHAR(50)
Declare @.keyphrase NVARCHAR(50)
--Query can be provided like 'searchterm' or as "search term" depending in existance of space character
--must format the partial query if it contains a space like '"search term*"'
--the keyphrase is @.query without quotes
IF CHARINDEX(N'"',@.query) > 0
BEGIN
SET @.partialQuery = LEFT(@.query, LEN(@.query) - 1) + N'*"'
SET @.keyphrase = LEFT(RIGHT(@.query, LEN(@.query) - 1), LEN(@.query) - 2)
END
ELSE
BEGIN
--must format the partial query like '"searchterm*"'
set @.partialQuery = N' "' + @.query + N'*" '
set @.keyphrase = @.query
END

--Now we can search for alternatives as exact match of @.query on alternatives
--or partial match on keyword, but ignore exact match on keyword (i.e. only alternatives to @.query)
SELECT *
FROM tblKeywords
WHERE NOT Keyword = @.keyphrase
AND SiteId = @.siteId
AND (
CONTAINS(Keyword, @.partialQuery )
)


-- Select the pages that match the query
SELECT DISTINCT c.ContentName, c.ContentLongSummary, c.MasterId, nc.NavigationId
FROM tblContents AS c
INNER JOIN trelKeywords AS ck ON ck.MasterId = c.MasterId
INNER JOIN tblKeywords AS k ON k.KeywordId = ck.KeywordId
INNER JOIN trelNavigationContents AS nc ON nc.MasterId = c.MasterId
INNER JOIN GetKeywordsFromQuery (@.query) AS kq ON kq.Word = k.Keyword
INNER JOIN tblNavigation AS nav ON nc.NavigationId = nav.NavigationId
WHERE c.SiteId = @.siteId
AND c.StatusID = 2
AND c.DeletedBy IS NULL
AND ( (@.textOnly=0) or (nav.ExcludeFromTextSite=0 and @.textOnly=1) )
UNION -- the following selects list pages that match, with primarylist page as their navigationid
SELECT DISTINCT c.ContentName, c.ContentLongSummary, c.MasterId, nc.NavigationId
FROM tblContents AS c
INNER JOIN trelKeywords AS ck ON ck.MasterId = c.MasterId
INNER JOIN tblKeywords AS k ON k.KeywordId = ck.KeywordId
INNER JOIN tblContents AS c1 ON c.PrimaryListMasterId = c1.MasterId
INNER JOIN trelNavigationContents AS nc ON nc.MasterId = c1.MasterId
INNER JOIN GetKeywordsFromQuery (@.query) AS kq ON kq.Word = k.Keyword
INNER JOIN tblNavigation AS nav ON nc.NavigationId = nav.NavigationId
INNER JOIN tblListContents AS lst ON lst.ListItemMasterId = c.MasterId
WHERE c.SiteId = @.siteId
AND c.DeletedBy IS NULL
AND c.StatusID = 2
AND c1.statusid = 2
AND c1.DeletedBy IS NULL
AND ( (@.textOnly=0) or (nav.ExcludeFromTextSite=0 and @.textOnly=1) )
AND lst.ContentMasterId = c.PrimaryListMasterId

-- Select the downloads that match the query
SELECT DISTINCT r.ResourceId, r.ResourceName, r.ResourceLongSummary, r.FileSize
FROM tblResources AS r
INNER JOIN trelKeywordResources AS kr ON kr.ResourceId = r.ResourceId
INNER JOIN tblKeywords AS k ON k.KeywordId = kr.KeywordId
INNER JOIN GetKeywordsFromQuery (@.query) AS kq ON kq.Word = k.Keyword
INNER JOIN trelContentItemResources AS cir ON r.ResourceId = cir.ResourceId
WHERE r.ResourceTypeId = 2
AND r.SiteId = @.siteId
AND cir.StatusId = 2

SELECT CASE WHEN nc.MasterId IS NULL THEN cir.MasterId ELSE nc.MasterId END AS MasterId, CASE WHEN nc.MasterId IS NULL
THEN ln.NavigationId ELSE nc.NavigationId END AS NavigationId, c.ContentName, res.ResourceId, res.ResourceTextType, res.ResourceText,
c.ContentLongSummary
FROM tblResources res INNER JOIN
trelContentItemResources cir ON cir.ResourceId = res.ResourceId
LEFT OUTER JOIN trelNavigationContents nc ON nc.MasterId = cir.MasterId
LEFT OUTER JOIN tblContents c ON c.MasterId = cir.MasterId AND c.StatusId = cir.StatusId
LEFT OUTER JOIN trelNavigationContents ln ON c.PrimaryListMasterId = ln.MasterId
LEFT OUTER JOIN tblNavigation nav ON nc.NavigationId = nav.NavigationId
INNER JOIN tlkpResourceTypes rt ON rt.ResourceTypeId = res.ResourceTypeId
INNER JOIN tblListContents AS lst ON lst.ListItemMasterId = c.MasterId
WHERE (res.SiteId = @.siteId)
AND (res.ResourceTypeId = 1 OR res.ResourceTypeId = 6)
AND CONTAINS(res.ResourceText, @.query)
AND (c.ContentPublicationDate IS NOT NULL)
AND (c.DeletedBy IS NULL)
AND (c.StatusId = 2)
AND (nc.MasterId IS NOT NULL)
AND ( (@.textOnly=0) or (nav.ExcludeFromTextSite=0 and @.textOnly=1) )
OR
(res.SiteId = @.siteId)
AND (res.ResourceTypeId = 1 OR res.ResourceTypeId = 6)
AND CONTAINS(res.ResourceText, @.query)
AND (c.ContentPublicationDate IS NOT NULL)
AND (c.DeletedBy IS NULL)
AND (c.StatusId = 2)
AND (c.PrimaryListMasterId IS NOT NULL)
AND ( (@.textOnly=0) or (nav.ExcludeFromTextSite=0 and @.textOnly=1) )
ORDER BY rt.SearchResultOrder, c.ContentName

GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

you call the SP you should prefix the N

in this sp, i m using three times that function. even i m not getting how to call the sp with it should have prefix the N....please let me know. i am just waiting for your reply.even i have using NVARCHAR whereever i stored a hindi text...i hope you have already seen my function.please do the needful. i have tried lot since few days on this, still couldn't get the right solution.

|||

can u tell me how you are executing your sp ..

I need the Exec spSearch .... statement

|||

well i don't have written something like Exec spSearch statement, actually i m calling this function from my ASP.NET application that's all. passing a 3 parameters and wanted to get results accordingly. Waiting for your reply.

Thanks Again for your response.

|||

hey check your ASP.NET code, the param declaration. It should be NVARCHAR.

Test your SP from Query Analyser using EXEC statement.. So you can validate where the problem resides.

|||

well,even not my sp giving me results at all if i pass a parameters,i checked using Exec statement also,not getting result..in ASP.NET i have written someting:--

public virtual SafeSqlDataReader GetSearchResults(int siteId, bool textOnly, string input)

{

// Define the command

SqlCommand command = new SqlCommand();

command.CommandType = CommandType.StoredProcedure;

command.CommandText = StoredProcedures.spSearch.ToString();

// Set the parameters

command.Parameters.Add("@.siteId", siteId);

command.Parameters.Add("@.textOnly", textOnly);

command.Parameters.Add("@.query", input);

command.Connection = SqlHelperWrapper.OpenConnection(this.ConnectionString);

return new SafeSqlDataReader(command);

}

so not getting a problem where it might be? if i have declared varchar here also then problem still remain same for the Stored Procedure because not giving me result at all if i pass a parameter in stored procedure,so problem is with sp and then we solved a problem with our code.

waiting for your reply.

|||

Hi still i am waiting for your response. Let me know if any solution you have for this, i am not getting this thing, i have written in my .NET code varchar , but if i pass parameters for hindi, not getting a results at all. so stored procedure may have some problem.

Please give me any solution for this.

Waiting for your response soon.

|||

how is it work with Patindex if i have one column which have data type 'Image', i want to search some hindi text within that, i have written a function in SQL which contains some Patindex and some string function as well. i have written something like:- PATINDEX(N'% %', @.query), but i want to find a some value with the help of stored procesedure:

here is my query which is a part of my stored procedure:

_

SELECT DISTINCT r.ResourceId, r.ResourceName, r.ResourceLongSummary, r.FileSize
FROM tblResources AS r
INNER JOIN trelKeywordResources AS kr ON kr.ResourceId = r.ResourceId
INNER JOIN tblKeywords AS k ON k.KeywordId = kr.KeywordId
INNER JOIN GetKeywordsFromQuery(@.query) AS kq ON kq.Word = k.Keyword
INNER JOIN trelContentItemResources AS cir ON r.ResourceId = cir.ResourceId
WHERE r.ResourceTypeId = 2
AND r.SiteId = @.siteId
AND cir.StatusId = 2
AND k.SiteId = @.siteId

SELECT CASE WHEN nc.MasterId IS NULL THEN cir.MasterId ELSE nc.MasterId END AS MasterId, CASE WHEN nc.MasterId IS NULL
THEN ln.NavigationId ELSE nc.NavigationId END AS NavigationId, c.ContentName, res.ResourceId, res.ResourceTextType, res.ResourceText,
c.ContentLongSummary
FROM tblResources res INNER JOIN
trelContentItemResources cir ON cir.ResourceId = res.ResourceId
LEFT OUTER JOIN trelNavigationContents nc ON nc.MasterId = cir.MasterId
LEFT OUTER JOIN tblContents c ON c.MasterId = cir.MasterId AND c.StatusId = cir.StatusId
LEFT OUTER JOIN trelNavigationContents ln ON c.PrimaryListMasterId = ln.MasterId
LEFT OUTER JOIN tblNavigation nav ON nc.NavigationId = nav.NavigationId
INNER JOIN tlkpResourceTypes rt ON rt.ResourceTypeId = res.ResourceTypeId
INNER JOIN tblListContents AS lst ON lst.ListItemMasterId = c.MasterId
WHERE (res.SiteId = @.siteId)
AND (res.ResourceTypeId = 1 OR res.ResourceTypeId = 6)
AND CONTAINS(res.ResourceText, @.query)
AND (c.ContentPublicationDate IS NOT NULL)
AND (c.DeletedBy IS NULL)
AND (c.StatusId = 2)
AND (nc.MasterId IS NOT NULL)
AND ( (@.textOnly=0) or (nav.ExcludeFromTextSite=0 and @.textOnly=1) )
OR
(res.SiteId = @.siteId)
AND (res.ResourceTypeId = 1 OR res.ResourceTypeId = 6)
AND CONTAINS(res.ResourceText, @.query)
AND (c.ContentPublicationDate IS NOT NULL)
AND (c.DeletedBy IS NULL)
AND (c.StatusId = 2)
AND (c.PrimaryListMasterId IS NOT NULL)
AND ( (@.textOnly=0) or (nav.ExcludeFromTextSite=0 and @.textOnly=1) )
ORDER BY rt.SearchResultOrder, c.ContentName

__

where ResourceText is having a datatype 'Image', so could you tell me how to use that function as well.

i will be waiting for your response soon.

Thanking You.

|||

Are you using Image datatype for storing information .. .

You can't do any Text/String manipulation on Image datatype.

Can I know why you are using image datatype here.

|||

yeah we have taken its an image data type because we have an editor somethning like this in which we are writing but it may have some image as well. so we taken as image data type.

0x4C6F6E646F6E206973206120636974792E3C7370616E207374796C653D22464F4E542D53495A453A2031307074223E203C703EE0A4B5E0A4BEE0A4B2E0A58DE0A4AEE0A580E0A495E0A4BF3C2F703E3C2F7370616E3E

i am having some value like that in Resource Text. so we have an editor complety & we are storing some text as well as possible to stored images as well in editor. but if we find english keyword then it works fine, else it is not suported with hindi keyword. so tell me solution.

|||

HarshalChoksi wrote:

but if we find english keyword then it works fine, else it is not suported with hindi keyword. so tell me solution.

This is not bcs of the SQL server. There is a problem on your Resource Text.

The Unicode english codes & ASCII codes are same. So it will work fine. But your Building the Resource Text somehow failed to create a Unicode text.

You have to look the solution on that area.. Not in SQL Server

Tuesday, March 20, 2012

PATINDEX not working with "[" ?

For some reason I can't get PATINDEX to find instances of the opening
bracket "[" although it finds the closing bracket "]" without any trouble.
Running the following script results in "0" for brakbegin and the correct
number for brakend.
UPDATE FOIdata
Set
brakbegin = PatIndex('%[%',Title_txt),
brakend = PatIndex('%]%',Title_txt)
Table Structure:
Title_txt text = "Oncovin (Lilly Research) [Leukemia] 12/04/1984 Medical
Officers Review"
brakbegin int
brakend int
Any idea what I'm doing wrong?
Terrytry this
declare @.Var varchar(50)
select @.var ='abc[def]zzz'
select PatIndex('%[[]%',@.var)
http://sqlservercode.blogspot.com/|||I don't know why this is happening but you could use CHARINDEX instead.
Declare @.text varchar(50)
Set @.Text = 'Oncovin (Lilly Research) [Leukemia] 12/04/1984 Medical
Officers Review'
Select charindex('[', @.Text)
Select Charindex(']', @.text, (charindex('[', @.Text)))
HTH
Barry|||Escape it:
PatIndex('%[]]%',Title_txt)
ML
http://milambda.blogspot.com/|||Thanks for all your excellent, quick help!
I didn't know about escaping the open bracket. That did the trick!
Thanks again!
Terry

Pathing Error: Subreport(s) could not be shown

Hi Folks
I have a working report with 5 additional subreports on my PC. Also, works
fine on the development server.
The issue is with PRODUCTION.
Our networking folks are disabling 127.0.0.1 and localhost in PRODUCTION.
Can anyone tell me if suppling the 'path' in the main report .rdl for all of
the subreports will fix the issue. Tried several permuations and have not
been able to have a subreport shown.
robjust doublechecked:
1. CAN deploy from VB.NET into the 'Home' directory in PRODUCTION and the
report/subreports work just fine :)
2. However, our 'normal' mode of operations is to copy the .RDLs from
DEVELOPMENT and upload them.
3. Attempting to deploy to any of the subdirectories/folders throws up an
authentication dialog.
4. My TargetServerURL: http://myproductionserver.here.mycompany.com/Reports
This needs to be something like:
http://myproductionserver.here.mycompany.com/Reports/thisapplicationreportsdir/reportnumber123
thanks
rob
"RobKaratzas" wrote:
> Hi Folks
> I have a working report with 5 additional subreports on my PC. Also, works
> fine on the development server.
> The issue is with PRODUCTION.
> Our networking folks are disabling 127.0.0.1 and localhost in PRODUCTION.
> Can anyone tell me if suppling the 'path' in the main report .rdl for all of
> the subreports will fix the issue. Tried several permuations and have not
> been able to have a subreport shown.
> rob|||sorry...
Finally, when deployed by hand (uploaded from .RDLs into where the reports
need to be) the subreports INDIVIDUALLY work just fine (so I'm pretty sure
it's a simply pathing related issue in the MAIN report).
Now, just how to modify the main report with the specific paths needed for
each subreport.
rob
"RobKaratzas" wrote:
> just doublechecked:
> 1. CAN deploy from VB.NET into the 'Home' directory in PRODUCTION and the
> report/subreports work just fine :)
> 2. However, our 'normal' mode of operations is to copy the .RDLs from
> DEVELOPMENT and upload them.
> 3. Attempting to deploy to any of the subdirectories/folders throws up an
> authentication dialog.
> 4. My TargetServerURL: http://myproductionserver.here.mycompany.com/Reports
> This needs to be something like:
> http://myproductionserver.here.mycompany.com/Reports/thisapplicationreportsdir/reportnumber123
> thanks
> rob
> "RobKaratzas" wrote:
> > Hi Folks
> >
> > I have a working report with 5 additional subreports on my PC. Also, works
> > fine on the development server.
> >
> > The issue is with PRODUCTION.
> >
> > Our networking folks are disabling 127.0.0.1 and localhost in PRODUCTION.
> >
> > Can anyone tell me if suppling the 'path' in the main report .rdl for all of
> > the subreports will fix the issue. Tried several permuations and have not
> > been able to have a subreport shown.
> >
> > rob|||Used the 'move' option to move all the reports to the proper location in the
SSRS tree.
The reports run just fine, however, this isn't the optimal way we want to
have to deploy our reports (preference is to upload the .rdls by hand).
rob
"RobKaratzas" wrote:
> sorry...
> Finally, when deployed by hand (uploaded from .RDLs into where the reports
> need to be) the subreports INDIVIDUALLY work just fine (so I'm pretty sure
> it's a simply pathing related issue in the MAIN report).
> Now, just how to modify the main report with the specific paths needed for
> each subreport.
> rob
> "RobKaratzas" wrote:
> > just doublechecked:
> >
> > 1. CAN deploy from VB.NET into the 'Home' directory in PRODUCTION and the
> > report/subreports work just fine :)
> >
> > 2. However, our 'normal' mode of operations is to copy the .RDLs from
> > DEVELOPMENT and upload them.
> >
> > 3. Attempting to deploy to any of the subdirectories/folders throws up an
> > authentication dialog.
> >
> > 4. My TargetServerURL: http://myproductionserver.here.mycompany.com/Reports
> > This needs to be something like:
> > http://myproductionserver.here.mycompany.com/Reports/thisapplicationreportsdir/reportnumber123
> >
> > thanks
> > rob
> >
> > "RobKaratzas" wrote:
> >
> > > Hi Folks
> > >
> > > I have a working report with 5 additional subreports on my PC. Also, works
> > > fine on the development server.
> > >
> > > The issue is with PRODUCTION.
> > >
> > > Our networking folks are disabling 127.0.0.1 and localhost in PRODUCTION.
> > >
> > > Can anyone tell me if suppling the 'path' in the main report .rdl for all of
> > > the subreports will fix the issue. Tried several permuations and have not
> > > been able to have a subreport shown.
> > >
> > > rob|||Rob,
Can I ask why you're not developing and deploying all your rdl's at
once, inside a single report project? It seems logical to keep
associated reports in the same "container", especially when you have 6
reports to keep track of.|||hi toolman
this is just how this company operates...
operations folks don't have access to/use any IDEs to deploy
in this case, I ended deploying this for them into production (Home
directory) and then had to use the 'MOVE' to move all reports.
not an ideal situation, but since I was the person who initially setup the
system(s), I still have access to them still. but typically, this would have
caused issues in this environment.
thanks rob
"toolman" wrote:
> Rob,
> Can I ask why you're not developing and deploying all your rdl's at
> once, inside a single report project? It seems logical to keep
> associated reports in the same "container", especially when you have 6
> reports to keep track of.
>

Patching WMSDE db's

Howdy,
Working on sql sp4 patching, we have one db that is an MSDE hybrid..WMSDE,
which is what ships with WSUS. If installed as the default on a Windows 200
3
server what sql version is it at, and has anyone had any experience with
patching this with MSDE SP4?
thxExperiencing the same issue on a WSUS server. ISS Internet Scanner says it
needs SQL SP4, but SP4 will not install. Anyone know if there is a version
of SP4 specifically designed for WMSDE? or whether or not WMSDE can be patc
hed at all?
**************
quote:
Originally posted by bill_the_cat
Howdy,
Working on sql sp4 patching, we have one db that is an MSDE hybrid..WMSDE,
which is what ships with WSUS. If installed as the default on a Windows 200
3
server what sql version is it at, and has anyone had any experience with
patching this with MSDE SP4?
thx

Patching SQL server in the field?

I've been working with the DBAs to come up with a plan to Service pack and
patch our SQL servers in the field. I've search high and low and cannot find
any solid docs on if this is possible? supported or recommended? or how to d
o
it at all. I built a new test Software update package and it had only a hand
full of security updates for SQL. So i guess my questions are
1) Is this possible and are there documents to support it?
2) SQL service packs a built very differently then normal patches and
updates. Because of this is it not advisable to repackage them for SMS?
Thanks in Advance!!
DobolinaIt's possible with SQL Server 2000, but it uses some old installshield
technology so that you need to capture an answer file and use that (and be
pretty sure that your choises will work on each server where it will be
applied). I had some minor issues with this when I upgraded some 70-80
servers a couple of years ago.
With SQL 2005 Microsoft moved to Windows Installer, and it seems to be much
easier to upgrade. Last week I created an upgrade from SQL 2000 to SQL 2005
with SP2 that I'm able to run silently from the SMS client.
/Rune
"Bob Dobolina" <Bob Dobolina@.discussions.microsoft.com> wrote in message
news:215C80C3-06DF-4B40-A82A-37CF2877504D@.microsoft.com...
> I've been working with the DBAs to come up with a plan to Service pack and
> patch our SQL servers in the field. I've search high and low and cannot
> find
> any solid docs on if this is possible? supported or recommended? or how to
> do
> it at all. I built a new test Software update package and it had only a
> hand
> full of security updates for SQL. So i guess my questions are
> 1) Is this possible and are there documents to support it?
> 2) SQL service packs a built very differently then normal patches and
> updates. Because of this is it not advisable to repackage them for SMS?
> Thanks in Advance!!
> Dobolina|||Thanks Rune,
I too noticed the SP4 exe extracts into an old school directory structure.
Lucky we have a packaging wizard. I'll sick him on the task.
again, thanks!
"Rune Norberg" wrote:

> It's possible with SQL Server 2000, but it uses some old installshield
> technology so that you need to capture an answer file and use that (and be
> pretty sure that your choises will work on each server where it will be
> applied). I had some minor issues with this when I upgraded some 70-80
> servers a couple of years ago.
> With SQL 2005 Microsoft moved to Windows Installer, and it seems to be muc
h
> easier to upgrade. Last week I created an upgrade from SQL 2000 to SQL 200
5
> with SP2 that I'm able to run silently from the SMS client.
> /Rune
> "Bob Dobolina" <Bob Dobolina@.discussions.microsoft.com> wrote in message
> news:215C80C3-06DF-4B40-A82A-37CF2877504D@.microsoft.com...
>|||Hmmm, are you trying to do a repackage of this servicepack? I doubt that you
will get a good repacked solution as there are several *.sql scripts that is
run against to system databases to upgrade them.
/Rune
"Bob Dobolina" <BobDobolina@.discussions.microsoft.com> wrote in message
news:93931A57-7C13-4C22-88E2-9C7527D5EEC8@.microsoft.com...[vbcol=seagreen]
> Thanks Rune,
> I too noticed the SP4 exe extracts into an old school directory structure.
> Lucky we have a packaging wizard. I'll sick him on the task.
> again, thanks!
> "Rune Norberg" wrote:
>

Monday, March 12, 2012

password storage

Hi everybody

I am working on a school project where I am writing a software for course registration. I have different users Students, Faculty, and Administrator. They are allowed to log in using their ID and password. I was wondering how could i store password and userID securly. Should I store it in the individual table or separately?

Any suggestion is appreciated. Also, if somebody has worked on this kind of project, please let me know.

Thanks a lot[I am using SQL 2000.|||You need to use what is known as "one-way" encryption. The good news is that this is simpler than "two-way" encryption where it is must be possible to both encypt and decrypt a text string. In one-way encryption you apply a function to encrypt the string, and then store the encrypted result in your table. When someone submits their password to log in, you apply the same encryption function to their password and then compare it to the encrypted version stored with their personal record. If the two match, you let the dude in.

There are some built-in encryption functions within SQL Server which are simple to use. I think they are called dbencrypt and dbcompare, or something similiar. The disadvantage with these is that they are undocumented functions, and if you upgrade your database to a new version of sql server Microsoft does not guarantee that it will use the same encryption algorythm in future versions. The result (and this has happened in past upgrades...) is that the passwords your users submit no longer match the versions stored in your database. They must all be reset and new ones must be entered.

You can write your own one-way encryption algorythm, or I have one that you can use that is more secure than the one supplied with SQL Server. (The built-in function has been cracked and the solution is available on the internet.)

blindman

Wednesday, March 7, 2012

Password encryption and decryption

Hi there,
Currently I working on a project that requires users to enter a username and
password before they can use one of our internal administration system.
The system is built using VB6.0 and SQL server 200o on Windows 2000.
Can someone please suggest a way of encrypting and decrypting the password
so that the passwords can be stored in the databaseCall the Windows Crypto API in the VB6 application.
Lots of information on MSDN.
Pity you are not using .NET as there, it is 100's of times easier to
implement.
Regards
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"Padmini" <Padmini@.discussions.microsoft.com> wrote in message
news:3DB5CD8B-17E8-459E-9CD8-331952A8FD90@.microsoft.com...
> Hi there,
> Currently I working on a project that requires users to enter a username
> and
> password before they can use one of our internal administration system.
> The system is built using VB6.0 and SQL server 200o on Windows 2000.
> Can someone please suggest a way of encrypting and decrypting the password
> so that the passwords can be stored in the database|||Don't store the password in the database. Password recovery mechanisms are
inherently insecure. Instead store a secure hash, including salt. The MS
crypto API provides the tools you need.
David Portas
SQL Server MVP
--|||are there any code examples of doing this anywhere?
"David Portas" wrote:

> Don't store the password in the database. Password recovery mechanisms are
> inherently insecure. Instead store a secure hash, including salt. The MS
> crypto API provides the tools you need.
> --
> David Portas
> SQL Server MVP
> --

Monday, February 20, 2012

Passing second column of table as index

We are working on C++ in eVC++ 3.0 environment (CE 3.0) with SQL CE 2.0.

We are trying with IRowsetIndex:: Seek method to access the data from the database.

We are facing problem when we try to access data from the table having composite index other than the first column.

For example:
The table ITEM contains the following columns:
1. ItemCode
2. PcNo
3. SubPcNo
4. BrandNo
5. DescText

6. ProductionKind

7. ProductionState

8. ClearingState

9. ST

10. TS

I’ve two indexes for this table where the two indexes are

1. ItemKey1 on ITEM (ItemCode).

2. ItemKey2 on ITEM (PcNo, SubPcNo, BrandNo).

If I mention ItemKey1 as the index then the Seek method works perfectly.

But if I mention ItemKey2 as the index, then I’m getting the error as “DB_E_BADBINDINFO”.

When we visted the MSDN for this problem we noted that:

1. When you use the Seek method on multiple fields, the Seek fields must be in the same order as the fields in the underlying table. If they are not, the Seek method fails.

2. When passing key values to an index rowset, the consumer performs these actions only for the number of key columns specified in the cKeyValues argument in IRowsetIndex:: Seek.

So we had the composite index such that columns of a composite index are physically aligned next to each other as in the table.

When the first column of the index is the first column of the table as in index ItemKey1 we found that the seek method works perfectly.

If we pass the index ItemKey2, we are again getting the error “DB_E_BADBINDINFO”.

What else have we missed out while passing the keys in IRowsetIndex:: Seek?

Thanks in advance.

Regards,

Sasi.

I saw this error when tried to use the table accessor for seeking. When you use IRowsetIndex you must create a separate accessor for the index columns and use that accessor for the Seek method, not the table's own accessor.

|||

Thanks for your reply Joao Paulo Figueira.

I was not able to understand the solution you provided, could you kinldy explain in detail.

Thanks & Regards,

Sasi.

|||

You must create a second memory buffer where to store the values to seek. This is built the same way as the memory buffer for accessing table data, but it must have the index columns and in the same order. You should use code similar to the one for binding the table columns in order to create the index accessor.

The only situation when you can share the same accessor between the table and the index is when the first N columns of the index are the same as the first N columns of the table. In all other situations you must create a different accessor for entering the data to seek.

|||

Thanks a lot Sir.

Its working now.

Thanks & Regards,

Sasi.