Showing posts with label head. Show all posts
Showing posts with label head. Show all posts

Wednesday, March 21, 2012

Help needed: Granting Create table permisions on specific Schema Options


Having some trouble getting my head around setting access to specific
schemas- here's my problem:

I've created a specific schema that I only want certain users to
control

Problem: Even though I give them full access...the cannot create
tables under that schema...my code is below (flyer is the schema,
eflyerAdmin is the role, and eflyer is the user):

GRANT
ALTER,
CONTROL,
DELETE,
EXECUTE,
INSERT,
REFERENCES,
SELECT,
TAKE OWNERSHIP,
UPDATE,
VIEW DEFINITION
ON SCHEMA::flyer
TO eflyerAdmin
GO
-- Add an existing user to the role
EXEC sp_addrolemember N'eflyerAdmin', N'eflyer'gdev (paul.afamdi.okeke@.gmail.com) writes:

Quote:

Originally Posted by

Having some trouble getting my head around setting access to specific
schemas- here's my problem:
>
I've created a specific schema that I only want certain users to
control
>
>
Problem: Even though I give them full access...the cannot create
tables under that schema...my code is below (flyer is the schema,
eflyerAdmin is the role, and eflyer is the user):
>
GRANT
ALTER,
CONTROL,
DELETE,
EXECUTE,
INSERT,
REFERENCES,
SELECT,
TAKE OWNERSHIP,
UPDATE,
VIEW DEFINITION
ON SCHEMA::flyer
TO eflyerAdmin
GO
-- Add an existing user to the role
EXEC sp_addrolemember N'eflyerAdmin', N'eflyer'


You also need:

GRANT CREATE TABLE TO eflyerAdmin

And it's sufficient to grant CONTROL on the schema, since CONTROL implies
the rest.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx

Monday, March 19, 2012

HELP needed with SQL - timetabling problem

I've been scratching my head for long enough, so it's time to humbly ask if someone's done it before (which is of course the case :-):

My database is a travel timetable, and has these four tables:

1. tblCity: CityID (PK), CityName

2. tblStop: StopID (PK), CityID (FK), StopName

3. tblTime: TimeID (PK), StopID(FK), RouteID (FK), arrival, departure

4. tblRoute: RouteID (PK), RouteName, startDate, endDate

I tried to keep it neat and simple. Now I need to do searches on it with two parameters: DestinationCity and TravelDate

Query should return the routes on which the Destination City is if the date falls in between those when the route is operating. I came up with this:

SELECT DISTINCT tblTime.RouteID

FROM (tblCity INNER JOIN tblStop ON tblCity.CityID = tblStop.StopCity)

INNER JOIN (tblRoute INNER JOIN tblTime on tblTime.RouteID=tblRoute.RouteID

WHERE tblRoute.startDate<TravelDate

AND tblRoute.endDate>TravelDate)

ON tblStop.StopID = tblTime.StopID

WHERE CityName='DestinationCity';

When I run this I'm getting no records, while there are some routes that operate on the given date to the chosen destination... Any clues what am I doing wrong? THANKS!


You are not really doing anything wrong travel scheduling uses ANSI SQL time interval current SQL Server does not have it but SQL Server 2005 has it. So the time part of your query is making SQL Server to return no records. I found a UDF(User defined function) that can do it. Try the link below and also check out the Time Tracker starter kit it may have something close to what you want. Hope this helps.

http://www.novicksoftware.com/UDFofWeek/Vol1/T-SQL-UDF-Volume-1-Number-38-udf_DT_AddTime.htm


|||Great! So this IS a problem for me - I'm trying to do this in Access..! Any suggestions how this can be solved in Access - if at all...?|||

I have found sample code using SQL Server time interval DATEDIFF, try the links below now you will get the time and date in between. Sorry it took so long, if you have not found a solution. Hope this helps.

http://databasejournal.com/features/mssql/article.php/3076421
http://www.stanford.edu/~bsuter/sql-datecomputations.html