|
select cast(5 as float) / cast(10 as float)
|
|
|
|
|
Hi,
How can i check the structure of a database in mssql server?
What I mean is I need a function or script which creates the table in the database if that table doesnot exist, and moreover i also need to check the existence of columns in a given table and also check if it's datatype is valid or not,if it is a primary key and so on and so forth.
What I need is just a routine or a sql script to check the data structure of a database?
|
|
|
|
|
You can use IF EXISTS to check if most database objects exist or not. This can be tables, and stored procedures. Give google a shot and it'll turn up a bit of good stuff for you
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
I am trying to insert a new record to a database access SQL. The connection is right, The statement is right and if I run it in a local machine it works just fine using express sql. but if I use it in my business server 2003 with the original sql program it does not work. The contactid is an identity column and it should automaticaly incriment and it does under access but it won't work through the command. What am I doing wrong?
Cannot insert the value NULL into column 'ContactID', table 'PLEASANTWEBSQL.dbo.COMPPATSTAB'; column does not allow nulls. INSERT fails. The statement has been terminated.
Dim cmd As New System.Data.SqlClient.SqlCommand
cmd.CommandType = System.Data.CommandType.Text
cmd.CommandText = "insert into comppatstab (firstname, Lastname, middlename, Birthdate, address, city, state, postalcode ) Values ( ...)
This is part of my command text with the values matching.
cmd.Connection = sqlConnection1
sqlConnection1.Open()
cmd.ExecuteNonQuery()
sqlConnection1.Close()
|
|
|
|
|
MUSIWA wrote: Cannot insert the value NULL into column 'ContactID'
Your cmd.CommandText shows no indication of using ContactID...
---modified
I missed the part of ContactID being identity. Are you sure?
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
Thankyou for replying I realy appreciate it. In my command.text I did not include the contactID because I thought that it will be automatically added when I add the new record. See when I looked at the syntax I did not notice how you add the primary key value if you do not know what the number is. In other words I do not know if I need to include the contactId and what value then do you give it?
|
|
|
|
|
From what I recall, if the ContactID is indeed an identity field with an auto-increment, you do not need to add it into the insert statement. Double check that the field is indeed an identity field and that it is supposed to not have any nulls allowed.
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
Yeah you were right I had a brain fart The table was recentely made from a query and it does not automaticaly make the primary key an Identity I corrected that and the whole thing works like a charm thanks again You were a life saver!
|
|
|
|
|
MUSIWA wrote: you were right I had a brain fart
It happens...
MUSIWA wrote: it does not automaticaly make the primary key an Identity I corrected that and the whole thing works like a charm thanks again You were a life saver!
No worries, I suspected maybe something was up with the ContactID field
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
Hi When ever I am trying to restore a database through a job, I am gettingh the following Error Msg:
Cannot open backup device 'd:\ftp\db backup\SE\sg_Differential_Backup.bak'. Device error or device off-line. See the SQL Server error log for more details. [SQLSTATE 42000] (Error 3201) RESTORE DATABASE is terminating abnormally. [SQLSTATE 42000] (Error 3013). The step failed.
The command for restoring the database used is:
declare @flname nvarchar(100)
declare @BaseRestore nvarchar(2000)
Set @flname = 'd:\ftp\db backup\SE\sg_Differential_Backup.bak'
Set @BaseReStore = 'RESTORE DataBase SGSE From Disk =''' + @flname + ''' With Replace'
exec sp_executesql @BaseReStore
Thought when I am trying to restore the database from the Restore option of the database, the restoration is successful.
I am in deep trouble. Kindly help
-----Have A Nice Day-----
|
|
|
|
|
Firstly did you assiduously assiduous wrote: See the SQL Server error log for more details
When you restore a database in SQL Server you need to always restore a complete backup first.
The reason you did not have to do this from Enterprise manager, I'm interpreting the following as meaning enterprise manager
assiduous wrote: Restore option of the database
is because enterprise manager forces the restore from the previous full backup.
My first suggestion is to read the error log then if it is what I suspect you will need to first restore the full backup then restore the differential backup.
You always pass failure on the way to success.
|
|
|
|
|
Dear All,
I am working on a project towards a text retrieval system. In the system, a document is represented by features (i.e., some words and phrases conveying the essence of the document). And the similarity between a query and a certain document is dertermined by counting the matching of features. Currently, at retrieval time, features of all documents are held in memory. However, holding all feature data in memory will become impossible as the number of documents dramatically increases.
I have thought of this problem for a long time. The only way I can figure out at this time is to use database technology. However, the problem that follows is that the drop-off in efficiency (retrieval response time will increase as accessing hard disk, where database is located, is slower than accessing memory ) by using database technology. I do not have any experience and idea about this. Or there may be other better technologies available?
Sometimes, I wonder how Google to solve this problem.
Please help. Thanks!
|
|
|
|
|
Theres quite a few ways that these problems are solved - you might want to read up on different caching strategies and indexing techniques. Generally this is taken care of in a large part by the database software. Some databases servers are quite specialized at rapid retrieval - such as Berkeley DB[^]. As for similarity and feature recognition, theres loads of research into that - especially for audio fingerprinting.
If you don't want to do anything too funky then just trust that your database server was written by someone that knew what they were doing
|
|
|
|
|
hi
i have too much work at work, so i have decided to take my Company's data home to create a test Environment so that i can develop on weekends. am using SQL2000 at and Export the data to Access Database, after that when i get home ,i used SQL2005. i use Migration Assistant to Export the Access database from Access to SQL2005, but the Consstraints are not Shipped together from Access to SQL2005.Yes i can go and set them again , but my Problem come when i have a large table, i can not activate an Identity Column in that case, it will be Cancelled out with an error that like "timeout" Error. Please tell me how can i import the SQL table from Access to SQL2005 with all the Constraint and Identity field being there.
Thanks
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
hi,
Well i am using the sqlserver2000 as backend.
I have table like seatdetails and columns are
seatno,bookingdate,dateoftravel,seatstatus
the seatstatus can be 0 - rejected, 1 -pending, and 2 - accepted.
Now the issue is daily at 12:00am , i need to execute the trigger or event which should check the
dateoftravel with the date in server
if it is less then
check the status of a seat
if it is 1 (i.e status of a seat) then
the date diff of bookingdate and cureentdate
if it is equal to 3 (i.e. counter of days) then the status should be set to 0 (i.e. status of a seat) and mail sent to @mailid1 and @mailid2
regarding the changes from the sqlserver.
Thank you for helping me in advance
You can mail me the procedure suhailquadri@gmail.com
|
|
|
|
|
Set up a SQL job that executes at 12:00am every day.
As for the code, I hope you're not asking someone to write that for you. You claim to be a developer, so why can't you do it yourself? I suggest you make an attempt at it and post again if you have specific problems. Otherwise people will think you are another lazy developer who can't be bothered to do their own work and ignore your post.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
well this can be done using code behind file.
but i heard we can do it using sqlserver2000 enterprize manager
if u have any idea regarading that , please help me
|
|
|
|
|
suhailahmedmohammed wrote: well this can be done using code behind file.
but i heard we can do it using sqlserver2000 enterprize manager
if u have any idea regarading that , please help me
RTFM
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
suhailahmedmohammed wrote: hi,
Well i am using the sqlserver2000 as backend.
I have table like seatdetails and columns are
seatno,bookingdate,dateoftravel,seatstatus
the seatstatus can be 0 - rejected, 1 -pending, and 2 - accepted.
Now the issue is daily at 12:00am , i need to execute the trigger or event which should check the
dateoftravel with the date in server
if it is less then
check the status of a seat
if it is 1 (i.e status of a seat) then
the date diff of bookingdate and cureentdate
if it is equal to 3 (i.e. counter of days) then the status should be set to 0 (i.e. status of a seat) and mail sent to @mailid1 and @mailid2
regarding the changes from the sqlserver.
That's a pretty nice novel you have there. Now, what exactly is your question? I.E., where in writing the code for this are you having problems?
suhailahmedmohammed wrote: You can mail me the procedure suhailquadri@gmail.com
WHAT? Do your work yourself. This isn't rent-a-coder. This is a place where you ask specific questions when you are having specific problems. I can't wait until my device is finished.
I'm going to become rich when I create a device that allows me to punch people in the face over the internet.
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
|
|
|
|
|
hi
i have two columns in a single table.i want to join two columns and display data in that table..
|
|
|
|
|
table 1, empno(pk), empname , empage
table 2, deptno(pk),deptname,dept_empno(fk)
then when joinging the datea
select empname,emapage,empno,deptname from table1 inner join table2 on empno = dept_empno
|
|
|
|
|
In oracle database there is a table t, its creat table sql is as follows:
create table t
(
sno number(3,0)
check (sno >=1 and sno <=4)
);
If another person want to know the context of the check constraint within table t, How to write
this through SQL?
thanks
|
|
|
|
|
Hi there,
i have a website
Files hierarchy is
wwwroot/
Default.aspx
Login.aspx
data/
db1.mdb[MS Access database]
web.config
Register/
Signup.aspx
web.config
when i inserting a record from Signup.aspx to db1.mdb it was returning an error Operation must use an updateable query
i think i have to change the permissions of db1.mdb, if so how to change permissions. iam using windows xp operationg system.
thanks for any advice
i posted this in webdevelopment forum also, i confused where to post this message.....
|
|
|
|
|
You haven't posted any code, so it's difficult to help you. Did you try Googling the error message to find out what it means?
Also, this is a SQL question so it should be posted in the SQL forum. It has nothing to do with web development.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Is there anyway i can tell who has been deleting rows from a specific table. Our db (SQL Server 2000) is using SQL Authentication. This is what i need:
1. Queries run
2. IP that ran the query
3. SQL Authenticanted Username
4. Time query was run.
Is this possible?
|
|
|
|