Thursday, March 29, 2012
CREATE TABLE with a DEFAULT for Microsoft Access
This doesn't work with a Microsoft Access database. The DEFAULT is causing a syntax exception. Trying to find any help with Google has prooved very frustrating and given me no leads, so do any of you know how it is done in a CREATE TABLE statement? (i.e. not seperately).
CREATE TABLE [MyTable] (
[MyField] VARCHAR(50) DEFAULT ""
)
Thanks for reading,
- David
(btw, I posted this in the general SQL forum as there didn't seem to be one for non-application-type MS Access questions. Hope that was right.)When you use the Table Design within Access there is Default Value property for a column.
By the way there is a Microsoft Access section with dbforums.|||I know about that, I want to set it using an SQL statement though. I am creating the database tables through script not using Access itself.
I mentioned why I didn't use the Microsoft Access forum in my edit. I looked at the messages that were on the first few pages and they seemed to all be application-orientated.
Thanks for your reply,
- David|||Ok, but it is just a suggestion to maybe have your question duplicated in the MS Access (you never know who might be popping in there to view stuff).
Also, have you looked at the Access documentation there is a section about Jet SQL Reference (not sure if that is what you need to reference)...although it looks as though there isn't a mention of DEFAULT. I agree with you when you 'downgrade' from a DB engine that has everything to something that lacks, it is frustrating.
Good luck....|||CREATE TABLE [MyTable] (
MyField Text(50) DEFAULT Hello World,
MyID Integer NOT NULL DEFAULT 1
)
Sorry for pulling a Hello world stuff on ya but that should work.|||I tried running that SQL in MS Access itself and got the same error I have been seeing with other attempts:
---------------
Microsoft Access
---------------
Syntax error in CREATE TABLE statement.
---------------
OK Help
---------------
It then selects the CREATE keyword in the SQL window.
I am using Access 2002/XP for this, should I be using something else?|||Just an observation, but MS-Access is a client side program. By default, it ships with the Microsoft-Jet database engine. If you have MS-Access 2002, you have MSDE on the CD, which is a slightly scaled down version of MS-SQL.
It might be worthwhile for you to install MSDE and use that as your database engine. It would put you on much more familiar ground!
-PatP|||Thanks Pat, but it's not for that sort of use. The product gets installed on web servers that don't have SQL Server or MSDE available to them. (if it does, it would use them anyway). :(
Thursday, March 22, 2012
Create stored procedure
I have a problem. I would like to create a stored procedure from a script file. I must use inparameters as well. I'm using ms Access 2000.
Please help me!
Mike.I'm not sure that I understand what you mean by inparameters, but if you just read the script file into a string variable, then execute that string variable as a command, then you should be "good to go".
-PatP|||Why would you want to do backend application development from access..
I would imagine it would be severe hoop jumping...
Get the sql server client side tools...
unless we're really talking about MSDE...|||Originally posted by Brett Kaiser
Why would you want to do backend application development from access.. Why do some folks like leather undies? There is no accounting for taste.
I'd suggest using OSQL or better yet Visual Studio, but that's just me!
-PatP|||Originally posted by Pat Phelan
Why do some folks like leather undies?
I have no response|||We are currently (trying) to create an application with Access forms and SQL server database with stored procedures. If you can get out of it, please do. Certainly the part with the stored procedures parameters is a hell. I would also suggest MSDE with osql.
But, probably, you can't drop the Access, so if you can supply some more info and i'll look into it.sql
Create standby database without backup/restore
I would like to create a standby database without backup restore.
We currently have a continous access storage ( disk duplication)but I would like to change to logshipping instead.
The database is 1 TB large and backup and restoring would take at least 2 days.
And we already have the datafile duplicated , soI would like to use these datafiles.
How can this be done?
Have you tried to issue:
BACKUP DATABASE <mydatabase> WITH NORECOVERY
This will place the database in a recovering state where you can apply transaction logs, as long as you have log backups which contain the next LSN needing to be applied.
Monday, March 19, 2012
Create project in MS Access 2000
Hallo
I am getting the “overflow” message (MS SQL Server Database Wizard) on attempt of creating a project in MS Access using SQL Server 2005 Express Edition.I am actually able to open an existing DB.
I was wandering why is this happening and what can I do to create such a project
Thank you
The visual tools in Access 2000 do not work with SQL Server 2005.|||
Thank you, for your answer.
I do not really need the visual tool with MS Access 2000. What I would like to do is to create a database on the server using MS Access 2000 and I was wondering whether it's possible.
Regards, Greater
|||The only way to create a database on SQL Server 2005 from Access 2000 that I can think of would be to create an ADO Command object and execute a "create database" scriptSunday, March 11, 2012
Create Primary Key with increment and format?
And, importantly, the value is set to "increment".
The format is "phd"000 - so it starts outphd001,phd002, and so on...
How to do this in an SQL table? Can that format be done? Or is it better not to do it via SQL but in coding instead?In SQL Server you do Unique constraint or Unique index for no duplicates the former allow nulls the later not null being primary key and set IDENTITY property on the column for auto increament. Run a search for Unique constraint and Unique index and the IDENTITY property in SQL Server BOL(books online). Hope this helps.
Create or modify MSDE Database
On Administrator session, I have created an CUSTOMER MSDE database. That's OK.
On user session, I want to access on my database CUSTOMER but I have on error : "Unable to connect to the database". And, in French : "Echec de la connexion de l'utilisateur Machine_Name/User_Name".
What is the error ? I don't know what to do any more.
How to give right to the user ? Have you an idea ?
Thank's.
Patrice A. BONNEFOY.Did you create a username to use to gain access to the MSDE database? If you're using Windows authentication then you need to add a user like Machine_Name/ASPNET. If you are using Sql authentication then you have to add some username or use an existing one.
This link may helpful for doing this|||Hi,
Thank you for your assistance. Now, I think of being able to repair me.
Best regards.
Patrice BONNEFOY.
www.pabonnefoy.net/
Wednesday, March 7, 2012
create login for db access on the fly
How can i create logins on the fly to access a database.
I have a login which can access a database through my webapp. The enduser
will access also through my webapp, but they have a different login to the
database.
My question how can this be done? I've tried to execute the following, but
that did not work.
EXEC sp_addlogin 'username','password';
EXEC sp_defaultdb 'username', 'database';
use database;
EXEC sp_grantdbaccess 'username';
EXEC sp_addrolemember 'standard','username';
result:
Server: Msg 15247, Level 16, State 1, Procedure sp_addlogin, Line 17
User does not have permission to perform this action.
Server: Msg 15132, Level 16, State 1, Procedure sp_defaultdb, Line 14
Cannot change default database belonging to someone else.
Granted database access to 'jos'.
'username' added to role 'standard'.Use either Windows Authentication or Application Roles.
I'm not sure in what context it would make sense to add users
"on-the-fly". To add a user requires a login to the database with the
db_acces
groups rather than individual users.
David Portas
SQL Server MVP
--|||Hi David,
I agree with you, but it is for emergency app which needs to create logins
for authenication means, because the user will access the database through
the webapp and doens't know their database password.
The user will be added to a databaserole.
Could you help me build this functionality?
"David Portas" wrote:
> Use either Windows Authentication or Application Roles.
> I'm not sure in what context it would make sense to add users
> "on-the-fly". To add a user requires a login to the database with the
> db_acces
> groups rather than individual users.
> --
> David Portas
> SQL Server MVP
> --
>|||You need sy
permissions. The error message indicated that you didn't have those
permissions so you'll have to use a login that does.
David Portas
SQL Server MVP
--|||Depends what you mean by on the fly, but, if you want the users to access th
e
DB w/o knowing the pwd or accnt they are going in as (ie, they can log into
your site (web-wise) with an accnt and pwd but knowing their accnt and pwd
alone won't give them direct access to the DB) you could set up SQL
Authentication on the DB, capture the users accnt value, modify it (in a
fixed way) and use the modified accnt value and a pwd in a COM or .NET
Assembly to actually access the DB. Means a bit more work on the DB end
tho... Or, you could access the DB with a specific accnt/pwd and pass in th
e
users web accnt as a parameter to your sprocs so you'd know who had requeste
d
the access... not sure what your ultimate goal is.
"Ezeki?l" wrote:
> Hi,
> How can i create logins on the fly to access a database.
> I have a login which can access a database through my webapp. The enduser
> will access also through my webapp, but they have a different login to the
> database.
> My question how can this be done? I've tried to execute the following, but
> that did not work.
> EXEC sp_addlogin 'username','password';
> EXEC sp_defaultdb 'username', 'database';
> use database;
> EXEC sp_grantdbaccess 'username';
> EXEC sp_addrolemember 'standard','username';
> result:
> Server: Msg 15247, Level 16, State 1, Procedure sp_addlogin, Line 17
> User does not have permission to perform this action.
> Server: Msg 15132, Level 16, State 1, Procedure sp_defaultdb, Line 14
> Cannot change default database belonging to someone else.
> Granted database access to 'jos'.
> 'username' added to role 'standard'.
>
Saturday, February 25, 2012
Create Link from SQL 2000 to AS400
I have found an
issue when I try to view or access the tables on the AS400 from my client machine. I receive the following error when I make that attempt:
Error 7399: OLE DB Provider 'MSDASQL' reported an error.
Data Source Name not found and no default driver specified.
Any help anyone can give me on this issue would be greatly appreciated
Thanks
PhilHi,
Could you be more specific?
You need to create link from SQL 2000 to AS400 but which is the AS400 database?
You have installed the adequate driver?
My apologies for my english. I currently write in portuguese.
Regards,
Dlson Castro.
delson_castro@.ig.com.br
Originally posted by pholtquist
Hi
I have found an
issue when I try to view or access the tables on the AS400 from my client machine. I receive the following error when I make that attempt:
Error 7399: OLE DB Provider 'MSDASQL' reported an error.
Data Source Name not found and no default driver specified.
Any help anyone can give me on this issue would be greatly appreciated
Thanks
Phil|||It sounds like the error is from the linked server defined incorrectly on SQL Server.
You say yhou are accessing the tables from your client machine. If the SQL Server is on a different machine, remember that you need to set up the ODBC DSN (or the 'DB2OLEDB' driver) on the server, not your client.
See sp_addlinkedserver in BOL for a description of what is needed.
Please provide more information if this does not help or is unclear.
HueyStLoui
Originally posted by pholtquist
Hi
I have found an
issue when I try to view or access the tables on the AS400 from my client machine. I receive the following error when I make that attempt:
Error 7399: OLE DB Provider 'MSDASQL' reported an error.
Data Source Name not found and no default driver specified.
Any help anyone can give me on this issue would be greatly appreciated
Thanks
Phil
Create index question
Thanks.If you're on SQL Server 2000, or on SQL Server 2005 with any SKU apart from
Enterprise Edition, then creating an index is an offline operation. This
means that creating a clustered index takes an exclusive table lock and
read/write access to the table is blocked. It also means that creating a
non-clustered index takes a shared table lock to block only write access to
the table.
If you're on SQL Server 2005 Enterprise Edition, you can make use of the
various online index operations, which do not hold long-term blocking
lockss. See Books Online for CREATE INDEX for more details.
Thanks
--
Paul Randal
Lead Program Manager, Microsoft SQL Server Storage Engine
http://blogs.msdn.com/sqlserverstorageengine/default.aspx
This posting is provided "AS IS" with no warranties, and confers no rights.
"Tim Kelley" <tkelley@.company.com> wrote in message
news:uwIAu0GzGHA.3704@.TK2MSFTNGP02.phx.gbl...
> Will creating an index while a database is in use block user access?
> Thanks.
>|||It depends on what SQL Server version you are using. SQL Server 2000 and
older will block user access. In SQL Server 2005 it could be an online
operation depending on the kind of index operation you are going to perform.
See Create Index in SQL Server 2005 Books online for more details on what
index operations are online and what are offline.
Bob
"Tim Kelley" wrote:
> Will creating an index while a database is in use block user access?
> Thanks.
>
>|||Hi Tim
Even if you're using SQL 2000, you can always kill off a create index
command without much penalty so why not just try it out & kill the command
if you're blocking users too long? You might be surprised how fast some
indexes on otherwise seemingly large tables can be created..
I often use the script at the URL below with SQL 2000 to monitor blocking
from another session during index creation & just kill off the index
creation if necessary. This often gets the job done without requiring a
system outage.
http://blogs.sqlserver.org.au/blogs/greg_linwood/archive/2005/10/02/50.aspx
SQL 2005 is a different story of course, due the online indexing
capability..
Regards,
Greg Linwood
SQL Server MVP
"Tim Kelley" <tkelley@.company.com> wrote in message
news:uwIAu0GzGHA.3704@.TK2MSFTNGP02.phx.gbl...
> Will creating an index while a database is in use block user access?
> Thanks.
>
Friday, February 24, 2012
CREATE FILE access denied
the Management Studio, from regular queries, etc. No other posts seem to
resolve this problem exactly that I can find. Thanks for any insight into
this problem...
USE MASTER
CREATE DATABASE XYZ
ON (Name = XYZ_data, FILENAME='C:\\XYZ_data.mdf')
LOG ON (Name = XYZ_log, FILENAME='C:\\XYZ_log.ldf')
Error message:
Msg 1802, Level 16, State 4, Line 2
CREATE DATABASE failed. Some file names listed could not be created. Check
related errors.
Msg 5123, Level 16, State 1, Line 2
CREATE FILE encountered operating system error 5(Access is denied.) while
attempting to open or create the physical file 'c:\XYZ_data.mdf'.
Hi
Check that the account that SQL Server runs under has file system
permissions on c:\
OS Error 5 = access denied.
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/
"XCode247" <XCode247@.discussions.microsoft.com> wrote in message
news:7DE6CBB0-087A-4CD2-9B45-AEAE45532C06@.microsoft.com...
>I get this error message when trying to create a database. This happens
>from
> the Management Studio, from regular queries, etc. No other posts seem to
> resolve this problem exactly that I can find. Thanks for any insight into
> this problem...
> USE MASTER
> CREATE DATABASE XYZ
> ON (Name = XYZ_data, FILENAME='C:\\XYZ_data.mdf')
> LOG ON (Name = XYZ_log, FILENAME='C:\\XYZ_log.ldf')
> Error message:
> Msg 1802, Level 16, State 4, Line 2
> CREATE DATABASE failed. Some file names listed could not be created. Check
> related errors.
> Msg 5123, Level 16, State 1, Line 2
> CREATE FILE encountered operating system error 5(Access is denied.) while
> attempting to open or create the physical file 'c:\XYZ_data.mdf'.
>
|||Yes, sure enough...
In Configuration Manager, Service properties. The 'Log on as' account was
'Network Service'. The help button from that page says a 'domain user account
with minimal rights' is recommended. Changing the account causes it to work.
CREATE FILE access denied
the Management Studio, from regular queries, etc. No other posts seem to
resolve this problem exactly that I can find. Thanks for any insight into
this problem...
USE MASTER
CREATE DATABASE XYZ
ON (Name = XYZ_data, FILENAME='C:\\XYZ_data.mdf')
LOG ON (Name = XYZ_log, FILENAME='C:\\XYZ_log.ldf')
Error message:
Msg 1802, Level 16, State 4, Line 2
CREATE DATABASE failed. Some file names listed could not be created. Check
related errors.
Msg 5123, Level 16, State 1, Line 2
CREATE FILE encountered operating system error 5(Access is denied.) while
attempting to open or create the physical file 'c:\XYZ_data.mdf'.Hi
Check that the account that SQL Server runs under has file system
permissions on c:\
OS Error 5 = access denied.
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/
"XCode247" <XCode247@.discussions.microsoft.com> wrote in message
news:7DE6CBB0-087A-4CD2-9B45-AEAE45532C06@.microsoft.com...
>I get this error message when trying to create a database. This happens
>from
> the Management Studio, from regular queries, etc. No other posts seem to
> resolve this problem exactly that I can find. Thanks for any insight into
> this problem...
> USE MASTER
> CREATE DATABASE XYZ
> ON (Name = XYZ_data, FILENAME='C:\\XYZ_data.mdf')
> LOG ON (Name = XYZ_log, FILENAME='C:\\XYZ_log.ldf')
> Error message:
> Msg 1802, Level 16, State 4, Line 2
> CREATE DATABASE failed. Some file names listed could not be created. Check
> related errors.
> Msg 5123, Level 16, State 1, Line 2
> CREATE FILE encountered operating system error 5(Access is denied.) while
> attempting to open or create the physical file 'c:\XYZ_data.mdf'.
>|||Yes, sure enough...
In Configuration Manager, Service properties. The 'Log on as' account was
'Network Service'. The help button from that page says a 'domain user account
with minimal rights' is recommended. Changing the account causes it to work.
CREATE FILE access denied
the Management Studio, from regular queries, etc. No other posts seem to
resolve this problem exactly that I can find. Thanks for any insight into
this problem...
USE MASTER
CREATE DATABASE XYZ
ON (Name = XYZ_data, FILENAME='C:\\XYZ_data.mdf')
LOG ON (Name = XYZ_log, FILENAME='C:\\XYZ_log.ldf')
Error message:
Msg 1802, Level 16, State 4, Line 2
CREATE DATABASE failed. Some file names listed could not be created. Check
related errors.
Msg 5123, Level 16, State 1, Line 2
CREATE FILE encountered operating system error 5(Access is denied.) while
attempting to open or create the physical file 'c:\XYZ_data.mdf'.Hi
Check that the account that SQL Server runs under has file system
permissions on c:\
OS Error 5 = access denied.
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/
"XCode247" <XCode247@.discussions.microsoft.com> wrote in message
news:7DE6CBB0-087A-4CD2-9B45-AEAE45532C06@.microsoft.com...
>I get this error message when trying to create a database. This happens
>from
> the Management Studio, from regular queries, etc. No other posts seem to
> resolve this problem exactly that I can find. Thanks for any insight into
> this problem...
> USE MASTER
> CREATE DATABASE XYZ
> ON (Name = XYZ_data, FILENAME='C:\\XYZ_data.mdf')
> LOG ON (Name = XYZ_log, FILENAME='C:\\XYZ_log.ldf')
> Error message:
> Msg 1802, Level 16, State 4, Line 2
> CREATE DATABASE failed. Some file names listed could not be created. Check
> related errors.
> Msg 5123, Level 16, State 1, Line 2
> CREATE FILE encountered operating system error 5(Access is denied.) while
> attempting to open or create the physical file 'c:\XYZ_data.mdf'.
>|||Yes, sure enough...
In Configuration Manager, Service properties. The 'Log on as' account was
'Network Service'. The help button from that page says a 'domain user accoun
t
with minimal rights' is recommended. Changing the account causes it to work.
Sunday, February 19, 2012
CREATE ENDPOINT to Expose a single DB instance
I have been looking at this statement for allowing access from a remote location to a specific database on my SQL Server (2005) from a client application.
Is it possible to do this using this method? I see lots of examples using this to expose Web Services of DB objects, however I need the client application to be able to authenticate to and access all objects in the database. If so, could some one provide a simple example of the arguments to use? For example, which protocol arguments are valid for this? I would like to use SQL Server Authentication. Is this possible?
Regards,
-Troy
I think the answer is to create a new instance of SQL Server on a non-standard port and move the DB to that instance. At least that is what I've chosen to do. If anyone knows of a better way, let me know.
Create device in emulator from Management Studio
i know i have the chance to access my mobile device (physical or emulator) from Management Studio.
I went to Connect Object Explorer, server type Sql Server Mobile but i can′t connect to my emulator and i can′t see any way to connect to a physical device either. How can i do this?
The only thing i can do is create a sql server mobile database (.sdf).
Thanks
SP
Moving to Sql Server Compact Edition forum where it has got better chance of being answered.
-Thanks,
Mohit
|||You can do this only if your device (or emulator) is connected through active sync.
Object Explorer:
Connect->
Database file-> Select 'Browse for more' and then select 'Mobile Device' from the file browser.
If you want to create a new database on the device, then just select 'New database' instead of 'Browse'
Thanks
Pragya