Showing posts with label ive. Show all posts
Showing posts with label ive. Show all posts

Wednesday, March 7, 2012

Chalenge returning the first available number in a sequence

Hi all,

Ive been trying to figure this out and has proven to be quite difficult for me. Lets say i do a select on all client numbers from a clients table i would want the first available number returned.

Given the client table below my query would return 4 because its the lowest number availeble.

Thanks.

client table

clnum

1

2

3

6

7

Writing a single sql query for this task is challenging. Though I suggest that you could write a stored procedure that loops through a cursor pointing to clnum and check which number isn't present in the column:

psuedo code

open a cusor on clnum

loop i =1 to max int

loop thru the cursor and check if i is present ; if not then return i

end of loop

close the cursor

For help on using loops and cursors,seehttp://www.databasejournal.com/features/mssql/article.php/3111031

Hope this helps.

QI.

|||

Create a temp table or table variable, insert your clientid's and query from it. Something like this:

Declare @.ttable( Idint identity, clientidint)insert into @.tselect 1unionallselect 2unionallselect 3unionallselect 6unionallselect 7select top 1 IDfrom @.tWhere Idnot in (Select clientidfrom @.t)order by id
|||

This would not work if we already had 4 and 5 in the column as well. For example:

Declare @.ttable( Idintidentity, clientidint)

insertinto @.t

select 1unionall

select 2unionall

select 3unionall

select 4unionall

select 5unionall

select 6unionall

select 7

selecttop 1 ID

from @.tWhere Idnotin(Select clientidfrom @.t)

orderby id

The above code wouldn't return anything. Even though it should return 8, which is the lowest available number. Also, you want to be able to select from a column which may have an unknown number of rows so I don't think you can keep on doing unions like this.

QI.

|||

(1) If the ID returned is NULL, you can always query back with MAX(Clientid) and increment by 1. If you write a function to do this, it should be very simple.

(2) There is no need to manually write the INSERTs. That was just for a sample.

INSERT INTO @.T

SELECT Clientid

FROM Clients

would insert all the clients into the table.

Friday, February 24, 2012

Centralised Database

Hi All,
I've been tasked at looking into a solution for a global data project for my
company.
The company uses some software that requires a local database, the local
databases are going to be located in Australia, US, & UK, the local databases
will have exact copies of each others schema. They would like the UK &
Australia databases to update the US database (effectively making the US
database centralized).
Conceptually whats the best way of doing this? My thoughts would be to have
the 3 local databases and create an additional database to centralize the
three using DTS or replication... ...there would be no overlapping data in
any of the three databases (except identity based keys), however data would
be updated. The only caviate I have to adhere to is the centralized database
must be no more than 30 minutes out of date (preferably no more than 15
minutes).
I've had a good year and half experience of being a DBA, but have never
really had to touch on replication and distributed data, so any thoughts or
views you have would be greatly appreciated.
Kind regards
Ben
I think your case is the simplest one, no data overlapping, you can use any
way to update data.
I would like use webservice, it is easy to control and no problem on any
firewall.
"BenUK" <BenUK@.discussions.microsoft.com> wrote in message
news:60AC4511-63FA-4709-A5BD-84A091750BD6@.microsoft.com...
> Hi All,
> I've been tasked at looking into a solution for a global data project for
my
> company.
> The company uses some software that requires a local database, the local
> databases are going to be located in Australia, US, & UK, the local
databases
> will have exact copies of each others schema. They would like the UK &
> Australia databases to update the US database (effectively making the US
> database centralized).
> Conceptually whats the best way of doing this? My thoughts would be to
have
> the 3 local databases and create an additional database to centralize the
> three using DTS or replication... ...there would be no overlapping data in
> any of the three databases (except identity based keys), however data
would
> be updated. The only caviate I have to adhere to is the centralized
database
> must be no more than 30 minutes out of date (preferably no more than 15
> minutes).
> I've had a good year and half experience of being a DBA, but have never
> really had to touch on replication and distributed data, so any thoughts
or
> views you have would be greatly appreciated.
> Kind regards
> Ben

Cell Drillthrough in Reporting Services 2005

Hi,

I’ve build a report in reporting services 2005, based on a MOLAP cube (Analysis Services 2005). In the cube I’ve enabled drillthrough.

I know that we can define drillthrough in the report by clicking on one of the members of the dimension hierarchy, but that’s not what I want. I want to be able to drillthrough on a cell. Is there any way how to do that in Reporting Services 2005?

Thanks,

AbdelSSAS actions are not carried to SSRS reports. One workaround is to create a drillthrough report which gets the context from the master report and executes the DRILLTHROUGH MDX query.|||

Hi Abdel ,

You have written U know how to define a drillthrough in the report by clicking on one of the members of the dimension hierarchy . can you please tell me how we will do that ?

I am trying to make a drillthrough report ,can you please give me a step by step process for enabling drill through in the reports .

I want to jump to a child report & pass the parameters of the parent report to the child report , I am able to get the parameters value in the child report ,but not able to use those values in the dataset query of the child report .

can you please tell me if this is possible or not ? & if yes how ?

Thanks

Rashmi

|||Please note the the original question was asking about a drillthrough action in the cube. If you just want the user to drilll through to another report, you can use the SSRS navigation feature. To do so, right-click on the textbox which will be use for drillthrough and choose Properties. Then go to the Navigation tab and use the Jump to Report feature. Note that that if the second report will retrieve data from the cube as well, you need to pass the parameters in the required format, e.g.; [Date].[Date].&[20070523]

Cell Drillthrough in Reporting Services 2005

Hi,

I’ve build a report in reporting services 2005, based on a MOLAP cube (Analysis Services 2005). In the cube I’ve enabled drillthrough.

I know that we can define drillthrough in the report by clicking on one of the members of the dimension hierarchy, but that’s not what I want. I want to be able to drillthrough on a cell. Is there any way how to do that in Reporting Services 2005?

Thanks,

AbdelSSAS actions are not carried to SSRS reports. One workaround is to create a drillthrough report which gets the context from the master report and executes the DRILLTHROUGH MDX query.|||

Hi Abdel ,

You have written U know how to define a drillthrough in the report by clicking on one of the members of the dimension hierarchy . can you please tell me how we will do that ?

I am trying to make a drillthrough report ,can you please give me a step by step process for enabling drill through in the reports .

I want to jump to a child report & pass the parameters of the parent report to the child report , I am able to get the parameters value in the child report ,but not able to use those values in the dataset query of the child report .

can you please tell me if this is possible or not ? & if yes how ?

Thanks

Rashmi

|||Please note the the original question was asking about a drillthrough action in the cube. If you just want the user to drilll through to another report, you can use the SSRS navigation feature. To do so, right-click on the textbox which will be use for drillthrough and choose Properties. Then go to the Navigation tab and use the Jump to Report feature. Note that that if the second report will retrieve data from the cube as well, you need to pass the parameters in the required format, e.g.; [Date].[Date].&[20070523]

Thursday, February 16, 2012

Caught in a Replication Catch-22, SQLServer2005

I am currently moving from SQL2K to 2005 and am having trouble incorporating
replication in 2005.
First off, I've found myself in a loop where I have two publications that
"don't exist" even though they show up in my Local Publishers list. I can't
delete tables that are articles in those publications because the tables are
being replicated. However, if I try to delete the publication, I get the
message that the publication doesn't exist. So the tables I need to drop are
bound to a publication that doesn't exist.
I've tried looking in the distribution and master databases to find the
missing links but I can't find anything. Without spending a lot of time
going through how I got in this mess, I'd just like to know if there are some
sp's that I can use to purge these publications once and for all.
Thanks in advance.
Roger.
You don't say which type of replication you are using. My experience
is only with merge replication, in this case I would suggest using
sp_removedbreplication in addition to normal sp_dropmergepublication
(or delete from the Gui)
Please see KB324401 for recommendations from MS. http://
support.microsoft.com/kb/324401
Tim Hill
On Feb 9, 3:33 pm, Roger Denison
<RogerDeni...@.discussions.microsoft.com> wrote:
> I am currently moving from SQL2K to 2005 and am having trouble incorporating
> replication in 2005.
> First off, I've found myself in a loop where I have two publications that
> "don't exist" even though they show up in my Local Publishers list. I can't
> delete tables that are articles in those publications because the tables are
> being replicated. However, if I try to delete the publication, I get the
> message that the publication doesn't exist. So the tables I need to drop are
> bound to a publication that doesn't exist.
> I've tried looking in the distribution and master databases to find the
> missing links but I can't find anything. Without spending a lot of time
> going through how I got in this mess, I'd just like to know if there are some
> sp's that I can use to purge these publications once and for all.
> Thanks in advance.
> --
> Roger.
|||I had a similar problem to this. The only way round it was to script
the publications & subscriptions, remove replication and then
re-enable.
On Fri, 9 Feb 2007 07:33:00 -0800, Roger Denison
<RogerDenison@.discussions.microsoft.com> wrote:

>I am currently moving from SQL2K to 2005 and am having trouble incorporating
>replication in 2005.
>First off, I've found myself in a loop where I have two publications that
>"don't exist" even though they show up in my Local Publishers list. I can't
>delete tables that are articles in those publications because the tables are
>being replicated. However, if I try to delete the publication, I get the
>message that the publication doesn't exist. So the tables I need to drop are
>bound to a publication that doesn't exist.
>I've tried looking in the distribution and master databases to find the
>missing links but I can't find anything. Without spending a lot of time
>going through how I got in this mess, I'd just like to know if there are some
>sp's that I can use to purge these publications once and for all.
>Thanks in advance.

Catching Primary Key Violation on insert error

I've read a few different articticles wrt how the handle this error gracefully.

I am thinking of wrapping my sql insert statement in a try catch and have the catch be something like

IF ( e.ToString() LIKE '%System.Data.SqlClient.SqlException: Violation of PRIMARY KEY constraint 'PK_PS_HR_Hrs'. Cannot insert duplicate key in object %')

{
lable1.text = "Sorry, you already have reported hours for that day, please select anothe rdate"

}

Is there a better way?

TIA

Dan

Find out the error number that your Exception is throwing, then trap for that particular error number. Your error might be number 2627 or 2601.

|||

Bummer-

I'm away from my asp.net enviormentt.

Um...

how do I do it?

int errorcode = ex.ToInt

if (errorcode = 123) then...

TIA

Dan

(Can't stop thinknkng about this stuff, I think I need professional help!)

|||

Catch the SqlException first, then display your message based on the returned number.

try{}catch (SqlException ex){if (ex.Number.Equals(2627)){// Display your error here}}
|||

Thanks Ed!

(Cute Kid!)

Tuesday, February 14, 2012

catalog is empty after populating

Hello,
I've got a problem with the Full Text Search of MS SQL=20
Server 2000 (SP3).
I've created a new Full Text catalog (FTC) on a database,=20
including one table and one textfield for searching. Up to=20
this everything goes fine. Population runs without=20
creating an error. But after population the catalog-size=20
is only 1 MB and the catalog doesn't contain any items. A=20
query with CONTAINS is returning 0 results.=20
I've tried the total procedure in Enterprise Manager and=20
in Query Analyzer. I've tried it with the example=20
databases NORTHWIND and PUBS, but everytime the same=20
result.
I've already searched a lot of articles and newsgroup-
entries without finding a solution for my problem.=20
Hopefully one of You may help.=20
Some facts that may help to find a solution:
-SQL Server 2000 SP3 (not upgraded from 7.0)
-Windows 2003 Server as Operating System
-MS Search Service runs correctly
Thank You in advance for every help
Andr=E9
what are the error messages you are getting in the application log in event
viewer from MSSearch and MSSCi?
Hilary Cotter
Looking for a book on SQL Server replication?
http://www.nwsu.com/0974973602.html
"Andr Bretschneider" <andre.bretschneider@.freenet.de> wrote in message
news:2a0701c47df8$4bd41c50$a601280a@.phx.gbl...
Hello,
I've got a problem with the Full Text Search of MS SQL
Server 2000 (SP3).
I've created a new Full Text catalog (FTC) on a database,
including one table and one textfield for searching. Up to
this everything goes fine. Population runs without
creating an error. But after population the catalog-size
is only 1 MB and the catalog doesn't contain any items. A
query with CONTAINS is returning 0 results.
I've tried the total procedure in Enterprise Manager and
in Query Analyzer. I've tried it with the example
databases NORTHWIND and PUBS, but everytime the same
result.
I've already searched a lot of articles and newsgroup-
entries without finding a solution for my problem.
Hopefully one of You may help.
Some facts that may help to find a solution:
-SQL Server 2000 SP3 (not upgraded from 7.0)
-Windows 2003 Server as Operating System
-MS Search Service runs correctly
Thank You in advance for every help
Andr
|||Hi Hillary,
thanks for your fast answer, But I'm sorry. I'm obviously=20
a greenhorn in SQLServer-Administration. Where can I find=20
this application log?
Andr=E9

>--Original Message--
>what are the error messages you are getting in the=20
application log in event
>viewer from MSSearch and MSSCi?
>--=20
>Hilary Cotter
>Looking for a book on SQL Server replication?
>http://www.nwsu.com/0974973602.html
>
>"Andr=E9 Bretschneider" <andre.bretschneider@.freenet.de>=20
wrote in message
>news:2a0701c47df8$4bd41c50$a601280a@.phx.gbl...
>Hello,
>I've got a problem with the Full Text Search of MS SQL
>Server 2000 (SP3).
>I've created a new Full Text catalog (FTC) on a database,
>including one table and one textfield for searching. Up to
>this everything goes fine. Population runs without
>creating an error. But after population the catalog-size
>is only 1 MB and the catalog doesn't contain any items. A
>query with CONTAINS is returning 0 results.
>I've tried the total procedure in Enterprise Manager and
>in Query Analyzer. I've tried it with the example
>databases NORTHWIND and PUBS, but everytime the same
>result.
>I've already searched a lot of articles and newsgroup-
>entries without finding a solution for my problem.
>Hopefully one of You may help.
>Some facts that may help to find a solution:
>-SQL Server 2000 SP3 (not upgraded from 7.0)
>-Windows 2003 Server as Operating System
>-MS Search Service runs correctly
>Thank You in advance for every help
>Andr=E9
>
>.
>
|||Andre,
Hilary's referring to the Window's Application Event log on the server where
SQL Server is installed as the "Microsoft Search" service cannot write it's
errors to SQL Server's errorlog files as SQL Server has a lock on these
files. Specifically, you should click on Start -> Programs -> Administrator
Tools -> Event Viewer and review the Application event log. You can click on
View and Filter and then select "Microsoft Search" as the Event Source to
see only these events. Below is an example error, you may find or you may
find a different error.
Microsoft Search
Warning Gatherer
3036
JTKNT0
Unable to access crawl seed <MSSQL://LOCALHOST/7.1333579789> in project
<SQLServer SQL0000700006>.
Error: 8007052e - Logon failure: unknown user name or bad password. .
Post any related errors in your server's Application event log.
Regards,
John
"Andr Bretschneider" <andre.bretschneider@.freenet.de> wrote in message
news:2b0901c47e0b$f559ce60$a601280a@.phx.gbl...
Hi Hillary,
thanks for your fast answer, But I'm sorry. I'm obviously
a greenhorn in SQLServer-Administration. Where can I find
this application log?
Andr

>--Original Message--
>what are the error messages you are getting in the
application log in event
>viewer from MSSearch and MSSCi?
>--
>Hilary Cotter
>Looking for a book on SQL Server replication?
>http://www.nwsu.com/0974973602.html
>
>"Andr Bretschneider" <andre.bretschneider@.freenet.de>
wrote in message
>news:2a0701c47df8$4bd41c50$a601280a@.phx.gbl...
>Hello,
>I've got a problem with the Full Text Search of MS SQL
>Server 2000 (SP3).
>I've created a new Full Text catalog (FTC) on a database,
>including one table and one textfield for searching. Up to
>this everything goes fine. Population runs without
>creating an error. But after population the catalog-size
>is only 1 MB and the catalog doesn't contain any items. A
>query with CONTAINS is returning 0 results.
>I've tried the total procedure in Enterprise Manager and
>in Query Analyzer. I've tried it with the example
>databases NORTHWIND and PUBS, but everytime the same
>result.
>I've already searched a lot of articles and newsgroup-
>entries without finding a solution for my problem.
>Hopefully one of You may help.
>Some facts that may help to find a solution:
>-SQL Server 2000 SP3 (not upgraded from 7.0)
>-Windows 2003 Server as Operating System
>-MS Search Service runs correctly
>Thank You in advance for every help
>Andr
>
>.
>
|||Hi John,=20
thanks for your advice, now I've found them.
I got five entries (3 informational, 2 errors) in the=20
application log. Here the 2 errors (I try to translate=20
them correctly from German):
Source: Microsoft Search
Type/Category: Warning Gatherer
Event Identification: 3036
Description:=20
Unable to access crawl seed <MSSQL75://SQLServer/6fe99f9f>=20
in project <SQLServer SQL0002400005>.
Error: 800700e9 - No process at the other end of the pipe.
Source: Microsoft Search
Type/Category: Warning Gatherer
Event Identification: 3024
Description:=20
Unable to start crawl for project <SQLServer=20
SQL0002400005> because there is no access to the crawl=20
seeds. Patch the error and then start again the crawl.
Obviously the second is an aftereffect of the first. So=20
I'll try to find the reason for the first error. Any idea?
Andr=E9

>--Original Message--
>Andre,
>Hilary's referring to the Window's Application Event log=20
on the server where
>SQL Server is installed as the "Microsoft Search" service=20
cannot write it's
>errors to SQL Server's errorlog files as SQL Server has a=20
lock on these
>files. Specifically, you should click on Start ->=20
Programs -> Administrator
>Tools -> Event Viewer and review the Application event=20
log. You can click on
>View and Filter and then select "Microsoft Search" as the=20
Event Source to
>see only these events. Below is an example error, you may=20
find or you may
>find a different error.
>Microsoft Search
>Warning Gatherer
>3036
>JTKNT0
>Unable to access crawl seed=20
<MSSQL://LOCALHOST/7.1333579789> in project
><SQLServer SQL0000700006>.
>Error: 8007052e - Logon failure: unknown user name or bad=20
password. .
>Post any related errors in your server's Application=20
event log.
>Regards,
>John
|||You're welcome, Andre,
The key error is Error: 800700e9 - No process at the other end of the pipe.
By chance did you or someone else remove the BUILTIN\Administrator login? If
so, you will need to either add it back with the default settings (master db
& sysadmin rights) as the MSSearch service requires that either the
BUILTIN\Administrators login
be present or that [NT Authority\System] localsystem login have the below
rights and this is why you are seeing ("Login failed for NT
AUTHORITY\SYSTEM" ) after removing the BUILTIN\Administrators login:
exec sp_grantlogin N'NT Authority\System'
exec sp_defaultdb N'NT Authority\System', N'master'
exec sp_defaultlanguage N'NT Authority\System','us_english'
exec sp_addsrvrolemember N'NT Authority\System', sysadmin
See also KB article Q263712 "INF: How To Prevent Windows NT Administrators
From Administering a Clustered SQL Server"
at http://support.microsoft.com/default...;EN-US;q263712 for more
info.
Additionally, and depending upon if you're FT Indexing documents imported
into SQL Server, you might also want to review KB article 308771 "PRB: A
Full-Text Search May Not Return Any Hits If It Fails to Index a File" at:
http://support.microsoft.com/default...&Product=sql2k
Regards,
John
<anonymous@.discussions.microsoft.com> wrote in message
news:2c6901c47e2a$8ed69410$a501280a@.phx.gbl...
Hi John,
thanks for your advice, now I've found them.
I got five entries (3 informational, 2 errors) in the
application log. Here the 2 errors (I try to translate
them correctly from German):
Source: Microsoft Search
Type/Category: Warning Gatherer
Event Identification: 3036
Description:
Unable to access crawl seed <MSSQL75://SQLServer/6fe99f9f>
in project <SQLServer SQL0002400005>.
Error: 800700e9 - No process at the other end of the pipe.
Source: Microsoft Search
Type/Category: Warning Gatherer
Event Identification: 3024
Description:
Unable to start crawl for project <SQLServer
SQL0002400005> because there is no access to the crawl
seeds. Patch the error and then start again the crawl.
Obviously the second is an aftereffect of the first. So
I'll try to find the reason for the first error. Any idea?
Andr

>--Original Message--
>Andre,
>Hilary's referring to the Window's Application Event log
on the server where
>SQL Server is installed as the "Microsoft Search" service
cannot write it's
>errors to SQL Server's errorlog files as SQL Server has a
lock on these
>files. Specifically, you should click on Start ->
Programs -> Administrator
>Tools -> Event Viewer and review the Application event
log. You can click on
>View and Filter and then select "Microsoft Search" as the
Event Source to
>see only these events. Below is an example error, you may
find or you may
>find a different error.
>Microsoft Search
>Warning Gatherer
>3036
>JTKNT0
>Unable to access crawl seed
<MSSQL://LOCALHOST/7.1333579789> in project
><SQLServer SQL0000700006>.
>Error: 8007052e - Logon failure: unknown user name or bad
password. .
>Post any related errors in your server's Application
event log.
>Regards,
>John