Showing posts with label provide. Show all posts
Showing posts with label provide. Show all posts

Thursday, March 22, 2012

adding user to specific db in sql

Hello,
I was wondering if someone can provide some assistance. I need to do
the following:
-connect to the desire servers
-cycle thru the user database
-if desire databases exist:
--check to see if desire user is present in master..syslogins
--if the desire username is in master..syslogins
--go to that desire database and exec sp_grantdbaccess and
sp_addrolemember
-if username does not exist, exec sp_grantlogin 'domain\username',
switch to the desire database and exec sp_grantdbaccess and
sp_addrolemember
I have created the section where it cycles thru and look for user
databases using a while loop. However, I can't figure out how to make
the while loop look for specific database I need.
For example, I need to look for 4 databases (gg_ts, newsfeed, procMark,
and devEnv). I can make the while loop find these users database but
for each time the while loop loops thru, I need it to look for one of
those 4 database, if exist, store it in a variable and set that
variable so I can use that variable later on in the script.
I was wondering if anyone has a solution I can use or an
example/template?
Thanks.Is this code written in T-SQL or some application tier language (like .NET)?
FYI, the list of databases are present in the "sysdatabases" catalog
table in the "master" database (if you are using T-SQL) or in the
"Databases" collection if you are using SQL-DMO.
--
HTH,
SriSamp
Email: srisamp@.gmail.com
Blog: http://blogs.sqlxml.org/srinivassampath
URL: http://www32.brinkster.com/srisamp|||hi, the code is written in T-SQL
I have a while loop looking thru the master..sysdatabases for user
databases. That portion, I am okay with. Its inside the while loop
that gets complicated. When the while loop find one of the above
databases, I want that database to be stored in a variable named
@.dbname sysname. Then I would include @.dbname into a portion of my
script, something like this:
select @.sql = @.dbname+'..sp_grantdbaccess <
username>
exec (@.sql)
at the moment, the way my script work is that it would go into every
database and add the desire user ... which isn't what I want :) . So I
made a lame script that looks something like this (without the while
loop):
code:
-- declaring a domain and a local userID, database ID, and a dbname
variable
declare @.duid varchar(40), @.dbid int, @.dbname sysname, @.sql
nvarchar(200), @.exist int
-- assigning values to the variables
select @.exist = 0
select @.duid = 'domain\username'
-- checking to see if the syslogins table in the master DB contains the
domain user
if exists (select name from master..syslogins where name = @.duid)
begin
print 'The domain user ' + @.duid + ' is present on this MSSQL
Instance.'
if exists (select name from master..sysdatabases where name =
'procMark')
begin
print 'database found ... switching to database'
if not exists (select name from procMark..sysusers where name =
@.duid)
begin print 'user is not present'
if exists (select name from tempdb..sysobjects where name like
'#result%')
begin
exec(N'drop table #result')
create table #result (result int)
select @.sql = 'select count(name) from procMark..sysusers where
name = '+''''+@.duid+''''
insert into #result exec(@.sql)
select @.exist = result from #result
if (@.exist) <
1
begin
print 'granting login to database'
exec procMark..sp_grantdbaccess @.duid, @.duid
exec procMark..sp_addrolemember 'RWXRole', @.duid
print 'permission granted to the database'
end
else print @.duid + ' has access to this database'
end
end
end
else
print 'database is not found'
end -- ending the primary if loop
else
print 'granting login to database and applying role'
exec sp_grantlogin @.duid
exec procMark..sp_grantdbaccess @.duid, @.duid
exec procMark..sp_addrolemember 'RWXRole', @.duid
print 'permission granted to the database'

The problem with the above code is ... I have to run this script
multiple times AND manually change the database name ... which I don't
want to do.|||>
select @.sql = @.dbname+'..sp_grantdbaccess <
username>

>
exec (@.sql)
Above is doable. Do you get errors from above code?
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Oberion" <
xvoid@.blastos.com>
wrote in message
news:1129209468.203301.297950@.o13g2000cwo.googlegroups.com...
>
hi, the code is written in T-SQL
>
>
I have a while loop looking thru the master..sysdatabases for user
>
databases. That portion, I am okay with. Its inside the while loop
>
that gets complicated. When the while loop find one of the above
>
databases, I want that database to be stored in a variable named
>
@.dbname sysname. Then I would include @.dbname into a portion of my
>
script, something like this:
>
>
select @.sql = @.dbname+'..sp_grantdbaccess <
username>
>
exec (@.sql)
>
>
at the moment, the way my script work is that it would go into every
>
database and add the desire user ... which isn't what I want :) . So I
>
made a lame script that looks something like this (without the while
>
loop):
>
>
code:

>
>
-- declaring a domain and a local userID, database ID, and a dbname
>
variable
>
declare @.duid varchar(40), @.dbid int, @.dbname sysname, @.sql
>
nvarchar(200), @.exist int
>
>
-- assigning values to the variables
>
select @.exist = 0
>
select @.duid = 'domain\username'
>
>
-- checking to see if the syslogins table in the master DB contains the
>
domain user
>
if exists (select name from master..syslogins where name = @.duid)
>
begin
>
>
print 'The domain user ' + @.duid + ' is present on this MSSQL
>
Instance.'
>
>
if exists (select name from master..sysdatabases where name =
>
'procMark')
>
begin
>
print 'database found ... switching to database'
>
if not exists (select name from procMark..sysusers where name =
>
@.duid)
>
begin print 'user is not present'
>
if exists (select name from tempdb..sysobjects where name like
>
'#result%')
>
begin
>
exec(N'drop table #result')
>
create table #result (result int)
>
select @.sql = 'select count(name) from procMark..sysusers where
>
name = '+''''+@.duid+''''
>
insert into #result exec(@.sql)
>
select @.exist = result from #result
>
if (@.exist) <
1
>
begin
>
print 'granting login to database'
>
exec procMark..sp_grantdbaccess @.duid, @.duid
>
exec procMark..sp_addrolemember 'RWXRole', @.duid
>
print 'permission granted to the database'
>
end
>
else print @.duid + ' has access to this database'
>
end
>
end
>
end
>
else
>
print 'database is not found'
>
end -- ending the primary if loop
>
else
>
print 'granting login to database and applying role'
>
exec sp_grantlogin @.duid
>
exec procMark..sp_grantdbaccess @.duid, @.duid
>
exec procMark..sp_addrolemember 'RWXRole', @.duid
>
print 'permission granted to the database'
>
>


>
>
The problem with the above code is ... I have to run this script
>
multiple times AND manually change the database name ... which I don't
>
want to do.
>
|||yeah I know that work. The problem is running it with a while loop.
So when my while loop runs .. it looks at master, model, tempdb, msdb,
gg_ts, newsfeed, procMark, and devEnv.
Well when this while--loop loops thru each of these database, if gg_ts,
newsfeed, procMark, and devEnv db exist, store the name into the
@.dbname variable. That's the part I am having a problem with. If I
can figure this part out, I can use:

> select @.sql = @.dbname+'..sp_grantdbaccess <username>
> exec (@.sql)
but until I figure it out, the above doesn't work ...|||I'm not sure I understand your problem correctly. When you do the exists
clause, you can then do a statement like the following:
=====
SELECT @.dbname = name FROM master..sysdatabases WHERE name = 'xxx'
SET @.strSQL = 'USE ' + @.dbname
...
=====
--
HTH,
SriSamp
Email: srisamp@.gmail.com
Blog: http://blogs.sqlxml.org/srinivassampath
URL: http://www32.brinkster.com/srisamp
"Oberion" <xvoid@.blastos.com> wrote in message
news:1129222744.380113.4630@.g49g2000cwa.googlegroups.com...
> yeah I know that work. The problem is running it with a while loop.
> So when my while loop runs .. it looks at master, model, tempdb, msdb,
> gg_ts, newsfeed, procMark, and devEnv.
> Well when this while--loop loops thru each of these database, if gg_ts,
> newsfeed, procMark, and devEnv db exist, store the name into the
> @.dbname variable. That's the part I am having a problem with. If I
> can figure this part out, I can use:
>
> but until I figure it out, the above doesn't work ...
>|||SriSamp,
====
select @.dbname = name from master..sysdatabase'
set @.strSQL = 'use ' +@.dbname
====
If I use the above in my while-loop, it would insert all the database
name, once, into the @.dbname variable.
=====
SELECT @.dbname = name FROM master..sysdatabases WHERE name = 'xxx'
SET @.strSQL = 'USE ' + @.dbname
...
=====
With your code, I have to manually replace the 'xxx' with each of the 4
databases name. Is there a way to automatically populate the 4
databases name into the 'xxx' thru a variable that can how multiple
values? So it will automatically cycle thru however many database I
specify in one run instead of 4 or 5 or 6. I hope that made more sense
...|||Ok. Does this help?
=====
DECLARE allDatabases CURSOR FOR
SELECT name FROM master..sysdatabases
WHERE name IN (<your list> )
OPEN allDatabases
FETCH next FROM allDatabases INTO @.dbName
-- The while loop will ensure that you iterate through only your
-- list of databases since we provided them in the cursor above
WHILE (@.@.FETCH_STATUS = 0)
BEGIN
-- do your stuff
FETCH next FROM allDatabases INTO @.dbName
END
CLOSE allDatabases
DEALLOCATE allDatabases
=====
--
HTH,
SriSamp
Email: srisamp@.gmail.com
Blog: http://blogs.sqlxml.org/srinivassampath
URL: http://www32.brinkster.com/srisamp
"Oberion" <xvoid@.blastos.com> wrote in message
news:1129250568.476223.245140@.z14g2000cwz.googlegroups.com...
> SriSamp,
> ====
> select @.dbname = name from master..sysdatabase'
> set @.strSQL = 'use ' +@.dbname
> ====
> If I use the above in my while-loop, it would insert all the database
> name, once, into the @.dbname variable.
> =====
> SELECT @.dbname = name FROM master..sysdatabases WHERE name = 'xxx'
> SET @.strSQL = 'USE ' + @.dbname
> ...
> =====
> With your code, I have to manually replace the 'xxx' with each of the 4
> databases name. Is there a way to automatically populate the 4
> databases name into the 'xxx' thru a variable that can how multiple
> values? So it will automatically cycle thru however many database I
> specify in one run instead of 4 or 5 or 6. I hope that made more sense
> ...
>|||SriSamp,
Thanks for the syntax, I will give that a try this afternoon and update
you.|||SriSamp, yes your syntax works great. I just need to rewrite my while
loop a bit.
Thanks for your help.

Tuesday, March 20, 2012

Adding Time In DateTime Field

Hi

I'm trying to add a time from a DateTime field to provide a total. Eg:

Field1

01/02/2007 01:00:00PM

01/03/2007 01:45:00PM

01/04/2007 03:00:00PM

I want to add the time so I get a total of 05:45. The total hours could go over 24. I know I can't Sum it. I've seen several examples of how to do this but can't make any of them work. Could someone please point me in the right direction?

Thanks

set @.d1='01/02/2007 01:00:00PM'

datepart(hh,@.d1) return : 1

DATEADD ( hour, datepart(hh,@.d1), YourDate ) add 1 hour to your data

|||

Please check your objective. All of the times you list are afternoon times. The sum of the time component for all of these is the 5:45 plus an additional 36 hours. If your answer is correct, there is more to it than just summing the time components.

Code Snippet

declare @.aTable table (field1 datetime)
insert into @.aTable
select '01/02/2007 01:00:00PM' union all
select '01/03/2007 01:45:00PM' union all
select '01/04/2007 03:00:00PM'

select datediff(day, 0, sumOfTime) as Days,
convert(varchar, sumOfTime, 114) as Time
from ( select cast(sum(cast(field1 as float)
-floor(cast(field1 as float)))as datetime)
as sumOfTime
from @.aTable
) x

/*
Days Time
--
1 17:44:59:997
*/


|||

From the nature of your question, and looking at your sample data, I assume that the sample data represents 'elapsed time' on a date. And that 01:45PM means 1 hour and 45 minutes elapsed time -NOT 13:45 o'clock.

To calculate the total 'elapsed time', it would have been so much easier if you were storing the StartDateTime and EndDateTime -then it would be relatively simple date arithematic.

If my assumptions are correct, AND you cannot re-engineer the data to collect Start/End datetime values, this will be a bit more effort.

Please confirm.

|||

Sorry, I should have been clearer. The time is just a time, the date is irrelevant. It's actually a travel time, so Arnie you're correct, it is an elapsed time. I'm purely interested in adding the hours together. So in the 3 lines of sample data they travelled for 1 hour, 1 hour 45 minutes and 3 hours. AM/PM is also irrelevant. Travel time will never go over 12 hours. So the total I want is 5:45.

I'm working with someone else's data and tables here, personally I wouldn't have used a datetime field for this data but that is what I have. I also agree it would be better to have a start and end time, but I don't.

One possible way could be to extract the time, convert it to minutes, add those minutes together and then convert it back to hours and minutes...possibly? Any ideas?

|||

YOu could use this function:

Code Snippet

CREATE FUNCTION dbo.TimeDiffInHoursAndMinutes
(
@.Firstdate DATETIME,
@.Seconddate DATETIME
)
/*
Function written by Jens K. Suessmeyer, 07/22/2007
http://www.sqlserver2005.de
*/
RETURNS VARCHAR(10)
AS
BEGIN

DECLARE @.FirstdateMinutes INT
DECLARE @.SeconddateMinutes INT

SELECT @.FirstdateMinutes = DATEPART (hh,@.Firstdate)*60 + DATEPART(mi,@.Firstdate)
SELECT @.SeconddateMinutes = DATEPART (hh,@.Seconddate)*60 + DATEPART(mi,@.Seconddate)

RETURN (
SELECT
CONVERT(VARCHAR(10), FLOOR(@.SeconddateMinutes-@.FirstdateMinutes) / 60) +
':' +
RIGHT('00' + CONVERT(VARCHAR(10), (@.SeconddateMinutes-@.FirstdateMinutes) - FLOOR((@.SeconddateMinutes-@.FirstdateMinutes) / 60)*60),2))
END;

Jens K. Suessmeyer

http://www.sqlserver2005.de

|||

This 'should' move you in the direction you want. (I've added another row to the sample data.)

Code Snippet


DECLARE @.MyTable table
( RowID int IDENTITY,
TravelTime smalldatetime
)


INSERT INTO @.MyTable VALUES ( '01/02/2007 01:00:00PM' )
INSERT INTO @.MyTable VALUES ( '01/03/2007 01:45:00PM' )
INSERT INTO @.MyTable VALUES ( '01/04/2007 03:00:00PM' )
INSERT INTO @.MyTable VALUES ( '01/04/2007 01:45:00PM' )


SELECT
Hours = sum( cast( parsename( replace( left( right( convert( varchar(20), TravelTime, 100 ), 7 ), 5 ), ':', '.' ), 2 ) AS int )) +
( sum( cast( parsename( replace( left( right( convert( varchar(20), TravelTime, 100 ), 7 ), 5 ), ':', '.' ), 1 ) AS int )) / 60 ) ,
Mins = ( sum( cast( parsename( replace( left( right( convert( varchar(20), TravelTime, 100 ), 7 ), 5 ), ':', '.' ), 1 ) AS int )) % 60 )
FROM @.MyTable


Hours Mins
-- --
7 30

|||Thank you so much Arnie that seems perfect. |||In addition and althrough already closed, I found something on my blog (didn′t know that I wrote such a thing yet :-) )

http://www.sqlserver2005.de/sqlserver2005/MyBlog/tabid/56/EntryID/31/Default.aspx

Jens K. Suessmeyer

http://www.sqlserver2005.de

Adding Time In DateTime Field

Hi

I'm trying to add a time from a DateTime field to provide a total. Eg:

Field1

01/02/2007 01:00:00PM

01/03/2007 01:45:00PM

01/04/2007 03:00:00PM

I want to add the time so I get a total of 05:45. The total hours could go over 24. I know I can't Sum it. I've seen several examples of how to do this but can't make any of them work. Could someone please point me in the right direction?

Thanks

set @.d1='01/02/2007 01:00:00PM'

datepart(hh,@.d1) return : 1

DATEADD ( hour, datepart(hh,@.d1), YourDate ) add 1 hour to your data

|||

Please check your objective. All of the times you list are afternoon times. The sum of the time component for all of these is the 5:45 plus an additional 36 hours. If your answer is correct, there is more to it than just summing the time components.

Code Snippet

declare @.aTable table (field1 datetime)
insert into @.aTable
select '01/02/2007 01:00:00PM' union all
select '01/03/2007 01:45:00PM' union all
select '01/04/2007 03:00:00PM'

select datediff(day, 0, sumOfTime) as Days,
convert(varchar, sumOfTime, 114) as Time
from ( select cast(sum(cast(field1 as float)
-floor(cast(field1 as float)))as datetime)
as sumOfTime
from @.aTable
) x

/*
Days Time
--
1 17:44:59:997
*/


|||

From the nature of your question, and looking at your sample data, I assume that the sample data represents 'elapsed time' on a date. And that 01:45PM means 1 hour and 45 minutes elapsed time -NOT 13:45 o'clock.

To calculate the total 'elapsed time', it would have been so much easier if you were storing the StartDateTime and EndDateTime -then it would be relatively simple date arithematic.

If my assumptions are correct, AND you cannot re-engineer the data to collect Start/End datetime values, this will be a bit more effort.

Please confirm.

|||

Sorry, I should have been clearer. The time is just a time, the date is irrelevant. It's actually a travel time, so Arnie you're correct, it is an elapsed time. I'm purely interested in adding the hours together. So in the 3 lines of sample data they travelled for 1 hour, 1 hour 45 minutes and 3 hours. AM/PM is also irrelevant. Travel time will never go over 12 hours. So the total I want is 5:45.

I'm working with someone else's data and tables here, personally I wouldn't have used a datetime field for this data but that is what I have. I also agree it would be better to have a start and end time, but I don't.

One possible way could be to extract the time, convert it to minutes, add those minutes together and then convert it back to hours and minutes...possibly? Any ideas?

|||

YOu could use this function:

Code Snippet

CREATE FUNCTION dbo.TimeDiffInHoursAndMinutes
(
@.Firstdate DATETIME,
@.Seconddate DATETIME
)
/*
Function written by Jens K. Suessmeyer, 07/22/2007
http://www.sqlserver2005.de
*/
RETURNS VARCHAR(10)
AS
BEGIN

DECLARE @.FirstdateMinutes INT
DECLARE @.SeconddateMinutes INT

SELECT @.FirstdateMinutes = DATEPART (hh,@.Firstdate)*60 + DATEPART(mi,@.Firstdate)
SELECT @.SeconddateMinutes = DATEPART (hh,@.Seconddate)*60 + DATEPART(mi,@.Seconddate)

RETURN (
SELECT
CONVERT(VARCHAR(10), FLOOR(@.SeconddateMinutes-@.FirstdateMinutes) / 60) +
':' +
RIGHT('00' + CONVERT(VARCHAR(10), (@.SeconddateMinutes-@.FirstdateMinutes) - FLOOR((@.SeconddateMinutes-@.FirstdateMinutes) / 60)*60),2))
END;

Jens K. Suessmeyer

http://www.sqlserver2005.de

|||

This 'should' move you in the direction you want. (I've added another row to the sample data.)

Code Snippet


DECLARE @.MyTable table
( RowID int IDENTITY,
TravelTime smalldatetime
)


INSERT INTO @.MyTable VALUES ( '01/02/2007 01:00:00PM' )
INSERT INTO @.MyTable VALUES ( '01/03/2007 01:45:00PM' )
INSERT INTO @.MyTable VALUES ( '01/04/2007 03:00:00PM' )
INSERT INTO @.MyTable VALUES ( '01/04/2007 01:45:00PM' )


SELECT
Hours = sum( cast( parsename( replace( left( right( convert( varchar(20), TravelTime, 100 ), 7 ), 5 ), ':', '.' ), 2 ) AS int )) +
( sum( cast( parsename( replace( left( right( convert( varchar(20), TravelTime, 100 ), 7 ), 5 ), ':', '.' ), 1 ) AS int )) / 60 ) ,
Mins = ( sum( cast( parsename( replace( left( right( convert( varchar(20), TravelTime, 100 ), 7 ), 5 ), ':', '.' ), 1 ) AS int )) % 60 )
FROM @.MyTable


Hours Mins
-- --
7 30

|||Thank you so much Arnie that seems perfect. |||In addition and althrough already closed, I found something on my blog (didn′t know that I wrote such a thing yet :-) )

http://www.sqlserver2005.de/sqlserver2005/MyBlog/tabid/56/EntryID/31/Default.aspx

Jens K. Suessmeyer

http://www.sqlserver2005.de

Saturday, February 25, 2012

Adding Identity column to existing table.

I am trying to add a server managed ranged Identity column to an existing
table in my database and then have SQL Server provide the management of
subscribers ranges.
I have had success with this using a test database (a book walk-though
example) but now I want to add this to a real table in my production
environment (actually a copy of the database) and then test with several
Pocket PC Sql Server CE subscribers using merge replication.
I added a column named MyIdentity as a 'int' type and choose the 'Not for
Replication' option.
I have it set up with horizonal filtering using suser_sname() which is
correct giving each subscriber only the appropriate records.
The problem is that under 'Articles', 'Identity Ranges', the settings are
disabled as if they are not an option with the article I added the
MyIdentity column to.
Any ideas as to how to get this working. Your help is greatly appreciated.
Bill Mitchell
Bill,
when you create the publication there is a checkbox which gives the option
to 'automatically assign and maintain a unique identity range for each
subscription'. If this is not checked when you create the subscription then
it is assumed you will manually set the ranges and the option is then greyed
out. Please can you recreate the publication to check this is the case.
BTW setting it manually can also be useful (see
http://www.mssqlserver.com/replicati...h_identity.asp).
HTH,
Paul Ibison
|||Paul,
Thanks, I think maybe I understand what was wrong earier. I tried your
suggestion but there was no tab on the article properties dialog as I was
creating the publication. Finally I added in a column as 'int' with the
Replicated set to "Yes". Then when I created the publication, the tab was
there and allowed me to choose for the server to manage the ranges.
If I understand correctly (I'm quite new to SQL Server), each table in a
merge replication solution in which the subscribers will be adding records
will need a single "int" column with the replication set to "Yes" prior to
creating the publication. Then during the creation of the publication, I
need to make sure and check for each of these tables (articles) ranges to be
managed. Is this correct and am I missing anything in this statement?
Thanks again,
Bill
"Paul Ibison" <Paul.Ibison@.Pygmalion.Com> wrote in message
news:uKT3J1IREHA.2408@.tk2msftngp13.phx.gbl...
> Bill,
> when you create the publication there is a checkbox which gives the option
> to 'automatically assign and maintain a unique identity range for each
> subscription'. If this is not checked when you create the subscription
then
> it is assumed you will manually set the ranges and the option is then
greyed
> out. Please can you recreate the publication to check this is the case.
> BTW setting it manually can also be useful (see
> http://www.mssqlserver.com/replicati...h_identity.asp).
> HTH,
> Paul Ibison
>
|||Bill,
for merge you need the column specified as Yes Not For Replication on the
publisher. When creating the publication there is the checkbox to have SQL
Server manage identity ranges we talked about. On the subscriber there
should be the same Identity Yes Not For Replication attribute. This allows
the replication process to do identity inserts. The ranges avoid clashes. If
you are not going to have SQL Server manage the ranges then you can manually
do it yourself. This is required if you are doing a nosync subscription ie
the subscriber already has the data so the initialization process won't send
it down. There are details on Michael Hotek's site of nice algorithms to
avoid identity clashes (http://www.mssqlserver.com/replication/).
HTH,
Paul Ibison
|||Thanks for all of your help.
Bill
"Paul Ibison" <Paul.Ibison@.Pygmalion.Com> wrote in message
news:eMO9NgMREHA.3420@.TK2MSFTNGP11.phx.gbl...
> Bill,
> for merge you need the column specified as Yes Not For Replication on the
> publisher. When creating the publication there is the checkbox to have SQL
> Server manage identity ranges we talked about. On the subscriber there
> should be the same Identity Yes Not For Replication attribute. This allows
> the replication process to do identity inserts. The ranges avoid clashes.
If
> you are not going to have SQL Server manage the ranges then you can
manually
> do it yourself. This is required if you are doing a nosync subscription ie
> the subscriber already has the data so the initialization process won't
send
> it down. There are details on Michael Hotek's site of nice algorithms to
> avoid identity clashes (http://www.mssqlserver.com/replication/).
> HTH,
> Paul Ibison
>
|||Never mind...I found it.
It's when I add an article I needed to go into this article's properties to set it before generating the snapshot.
Vince
Posted using Wimdows.net NntpNews Component -
Post Made from http://www.SqlJunkies.com/newsgroups Our newsgroup engine supports Post Alerts, Ratings, and Searching.

Friday, February 24, 2012

Adding Full-Text Search Indexing to a Cluster

Ihave an Active/Passive Cluster. Can someone point me to a Technet
article or provide the steps for adding Full-text indexing?
I can't seem to find one!
Thank you.
Jay
SQL FTS has to be installed from the start on a cluster. The SQL Server 2000
High availablilty book is pretty good for installing a cluster.
<jay.griffin@.burke.com> wrote in message
news:1107212619.013634.8160@.c13g2000cwb.googlegrou ps.com...
> Ihave an Active/Passive Cluster. Can someone point me to a Technet
> article or provide the steps for adding Full-text indexing?
> I can't seem to find one!
> Thank you.
> Jay
>
|||Jay,
Could you post the full output of -- SELECT @.@.version -- as this is helpful
in understanding your current clustered environment.
For the time being, I'm going to assume that you have a clustered SQL Server
2000 A/P environment. Correct? If so, then you should be using SQL Server
2000 Enterprise Edition and Full-text Indexing (and Full-text Search, often
referred to as SQL FTS) is installed by default.
You can use the SQL Enterprise Manager and select Server and database, you
want to FT-enable and click on Tools -> Full-text Indexing to launch the FT
Indexing Wizard. This wizard (SQLFTWiz.exe) will walk you though all the
necessary steps for adding Full-text Indexing to a selected table. Note, the
table, must have a single column, non-nullable, unique index to qualify for
a table to be FT Indexed. Also, the only restriction for FTI in a clustered
environment, is that the FT Catalog, must be created on the shared disk
drive in your clustered environment.
You may also want to do this via pure T-SQL code, and if so, checkout "Full
Text Indexing using T-SQL from a Profiler Trace" at
http://spaces.msn.com/members/jtkane/Blog/cns!1pWDBCiDX1uvH5ATJmNCVLPQ!304.entry
and this blog entry will walk you though all the necessary T-SQL code.
Hope that helps!
John
SQL Full Text Search Blog
http://spaces.msn.com/members/jtkane/
<jay.griffin@.burke.com> wrote in message
news:1107212619.013634.8160@.c13g2000cwb.googlegrou ps.com...
> Ihave an Active/Passive Cluster. Can someone point me to a Technet
> article or provide the steps for adding Full-text indexing?
> I can't seem to find one!
> Thank you.
> Jay
>
|||Thanks for your help. It is SQL 2000 Enterprise (A/P) on Windows 2000
Adv Server. Sorry to omit that important information.
Here is my problem -- Full Text indexing is not installed. When I try
to do what you indicated, Full Text Indexing is grayed out.
I was installing some other software which was going to create a
database. It gave the a warning that Full text indexing was not
installed and the software would not function properly.
If I go into the SQL Setup, I can't add/remove components. The only
option I have is to Uninstall. I am wondering how I can add full-text
indexing.
Thanks for your help,
Jay
John Kane wrote:
> Jay,
> Could you post the full output of -- SELECT @.@.version -- as this is
helpful
> in understanding your current clustered environment.
> For the time being, I'm going to assume that you have a clustered SQL
Server
> 2000 A/P environment. Correct? If so, then you should be using SQL
Server
> 2000 Enterprise Edition and Full-text Indexing (and Full-text Search,
often
> referred to as SQL FTS) is installed by default.
> You can use the SQL Enterprise Manager and select Server and
database, you
> want to FT-enable and click on Tools -> Full-text Indexing to launch
the FT
> Indexing Wizard. This wizard (SQLFTWiz.exe) will walk you though all
the
> necessary steps for adding Full-text Indexing to a selected table.
Note, the
> table, must have a single column, non-nullable, unique index to
qualify for
> a table to be FT Indexed. Also, the only restriction for FTI in a
clustered
> environment, is that the FT Catalog, must be created on the shared
disk
> drive in your clustered environment.
> You may also want to do this via pure T-SQL code, and if so, checkout
"Full
> Text Indexing using T-SQL from a Profiler Trace" at
>
http://spaces.msn.com/members/jtkane/Blog/cns!1pWDBCiDX1uvH5ATJmNCVLPQ!304.entry
> and this blog entry will walk you though all the necessary T-SQL
code.[vbcol=seagreen]
> Hope that helps!
> John
> --
> SQL Full Text Search Blog
> http://spaces.msn.com/members/jtkane/
>
> <jay.griffin@.burke.com> wrote in message
> news:1107212619.013634.8160@.c13g2000cwb.googlegrou ps.com...
|||You're welcome, Jay,
Despite what you see as "Full Text Indexing is grayed out", it is most
likely that Full Text Search (FTS) is installed because of what you see when
you attempt to add the "Full-Text Search" components via SQL Setup and
"custom installation" where the "Full-Text Search" component option is
already checkmarked. Correct?
If the above is not correct, you may have the MSSQLServer service running
under a local machine account, if so, then checkout KB article Q270671
(Q270671) "PRB: Full Text Search Menus Are Not Enabled for Local Windows NT
Accounts" at:
http://support.microsoft.com/default...;en-us;q270671
If the above is correct, then you can force the removal of the checkmark via
the removal or renaming of the following tracking registry key and the
following procedure to Re-install" the "Full-text Search" components via
deleting (or renaming) the below "tracking key" and re-install (If you're
not using a named instance, remove "<Instance_Name>\".)
NOTE: be sure to be logged on to the server as either Administrator or as a
member of the server's Admin Group!
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL
Server\<Instance_Name>\Tracking\
{E07FDDA7-5A21-11d2-9DAD-00C04F79D434}
Once you're done removed (renamed) the above tracking key, then delete the
MSSearch directory from either:
drive_letter:\Program Files\Common Files\Microsoft Shared\
or
drive_letter::\Program Files\Common Files\System\
Then using your SQL Server 2000 installation CD re-install via "Custom
Installation" the Full-Text Search component (it should be un-checked). When
this completes find and save these files: SearchSetup.log (usually under
\windows or \winnt folders) and sqlsp.log. If any problems, please post
these files.
Re-install the service pack that you may have applied to SQL Server 2000, so
that the newly re-installed MSSearch components are upgraded to SP3a levels
and then re-boot &/or restart the MSSearch and MSSQLServer services.
You may also want to consult or perform the procedures document in the
following Kb article: 827449 "How to manually reinstall the Microsoft Search
service for an instance of SQL 2000" at:
http://support.microsoft.com/default...b;EN-US;827449
Finally, and considering that this is a clustered environment, you may also
want to review the following KB articles:
812666 "How to recover a failed full-text search resource on a clustered
instance of SQL Server 2000" at:
http://support.microsoft.com/default.aspx?kbid=812666
"The full-text search results that are returned in a clustered SQL Server
2000 environment may be different when the active node changes" at:
http://support.microsoft.com/default...b;en-us;889708
Hope that helps!
John
SQL Full Text Search Blog
http://spaces.msn.com/members/jtkane/
<jay.griffin@.burke.com> wrote in message
news:1107270434.064396.309410@.c13g2000cwb.googlegr oups.com...
> Thanks for your help. It is SQL 2000 Enterprise (A/P) on Windows 2000
> Adv Server. Sorry to omit that important information.
> Here is my problem -- Full Text indexing is not installed. When I try
> to do what you indicated, Full Text Indexing is grayed out.
> I was installing some other software which was going to create a
> database. It gave the a warning that Full text indexing was not
> installed and the software would not function properly.
> If I go into the SQL Setup, I can't add/remove components. The only
> option I have is to Uninstall. I am wondering how I can add full-text
> indexing.
> Thanks for your help,
> Jay
>
> John Kane wrote:
> helpful
> Server
> Server
> often
> database, you
> the FT
> the
> Note, the
> qualify for
> clustered
> disk
> "Full
>
http://spaces.msn.com/members/jtkane/Blog/cns!1pWDBCiDX1uvH5ATJmNCVLPQ!304.entry
> code.
>
|||Thanks John.
Clarification from my previous post: "If I go into the SQL Setup, I
can't add/remove components. =ADThe only option I have is to Uninstall.
" -- ALL other options are grayed out. It is not a matter of them
already being checked. I have no option to check them. It isn't
installed and it won't let me add it.
I am assuming because this is a cluster, components have to be added
differently. Because I have no option to add/remove components under
the custom install. My only option is to Uninstall. (yes - I am
logged in as administrator).
MSSQLServer is running as a domain account and that account is in the
domain admins group.
|||You're welcome, Jay,
Ok, so we take 10 yards and punt (to use a football analogy)... Before I ask
you to un-cluster your servers and re-install SQL Server (a big effort, I
know), I want you to confirm something for me.
Is this SQL Server installed on a Domain Controller or a backup DC? As I've
seen problems with FTS working correctly when installed on a DC or BDC and
with MSSQLServer service startup account being the Domain Administrators
account. If it's not on a DC or BDC, but you are using an account that is a
member of the DOMAIN Administrator group, could you create a separate
DOMAIN\Account and add that account to the local server's Administrators
Group and then using the SQL Enterprise Manager's server property security
tab, change the MSSQLServer service startup account to the newly created
DOMAIN\Account. This change should prompt you to stop & re-start SQL Server
and click yes to this prompt. Then close and re-launch the Enterprise
Manager and see if the Full Text Indexing is still grayed out. If it is not
grayed out, then failover to your Passive node and do the same thing there.
As I've said I've seen this before in non-clustered environments where SQL
Server 2000 was installed on a DC or BDC and the MSSQLServer service
startup account being the Domain Administrators account. The solution in
this case was as I described above or resetting the MSSQLServer service
startup account use LocalSystem or as a last resort move the SQL Server off
the DC or BDC.
Let me know if this successful for you, otherwise, the fallback solution is
to un-cluster your servers and re-install SQL Server :-(
Thanks,
John
SQL Full Text Search Blog
http://spaces.msn.com/members/jtkane/
<jay.griffin@.burke.com> wrote in message
news:1107277007.739900.246620@.z14g2000cwz.googlegr oups.com...
Thanks John.
Clarification from my previous post: "If I go into the SQL Setup, I
can't add/remove components. XThe only option I have is to Uninstall.
" -- ALL other options are grayed out. It is not a matter of them
already being checked. I have no option to check them. It isn't
installed and it won't let me add it.
I am assuming because this is a cluster, components have to be added
differently. Because I have no option to add/remove components under
the custom install. My only option is to Uninstall. (yes - I am
logged in as administrator).
MSSQLServer is running as a domain account and that account is in the
domain admins group.
|||Based on what you are telling me -- I am going to have to uncluster and
re-install. The servers are not a DC. The special user I setup for
the SQL servers is in the local admins group already.
Do you know of any KB articles that would walk me through this without
losing any information?
|||Jay,
Yep, 10 yards & punt... Re-installing a Clustered SQL server is never easy,
but these references may help:
a.. SQL Server 2000 Clustering Whitepaper,
http://www.microsoft.com/SQL/techinf...vercluster.asp
a.. 815431 PRB: Installation of a Named Instance of SQL Server 2000 Virtual
Server http://support.microsoft.com/?id=815431
a.. 325485 WebCast: Microsoft SQL Server 2000 Virtual Server Basic Setup
http://support.microsoft.com/?id=325485
a.. 274446 INF: Upgrade to SQL Server 2000 Failover Solution Recommended for
All... http://support.microsoft.com/?id=274446
a.. 254321 INF: Clustered SQL Server Do's, Don'ts, and Basic Warnings
http://support.microsoft.com/?id=254321
a.. 243218 INF: Installation Order for SQL Server 2000 Enterprise Edition
http://support.microsoft.com/?id=243218
a.. 260758 INF: Frequently Asked Questions - SQL Server 2000 - Failover
Clustering http://support.microsoft.com/?id=260758
Hope this helps!
John
SQL Full Text Search Blog
http://spaces.msn.com/members/jtkane/
<jay.griffin@.burke.com> wrote in message
news:1107354007.277719.324960@.g14g2000cwa.googlegr oups.com...
> Based on what you are telling me -- I am going to have to uncluster and
> re-install. The servers are not a DC. The special user I setup for
> the SQL servers is in the local admins group already.
> Do you know of any KB articles that would walk me through this without
> losing any information?
>
|||John,
Thank you for all your help on this issue.
Jay

Thursday, February 9, 2012

Adding a user to a database in SQL Server Management Studio Express?

Can someone provide me with instructions or a link on how to add a user to a database using SQL Server Management studio Express?

I also would like to know how you set the db_owner permission to the user?

My host has an sql express database and I would like to use the same connection string on my local machine, but need to set up the username/pw on the database locally.

Thanks

go to the security tab of the management express

in the object explorer. double click logins to expand

right click and then add new user

from there you can grant the user access to database.

you can also open the database to add new user to it when you

already created a login in the security tab