|
SQL server does not exist or access denied.
What part of that error message is unclear?
|
|
|
|
|
|
thx for all
the problem was solved
BESHOY
FACULTY OF COMPUTER AND INFORMATION
COMPUTER SCINCE DEPARTMENT
|
|
|
|
|
Hello all,
I have a table in which I have added new one column and now I want to add data to it. What I want is that column starting values should be from some number and end with the number of rows.
Like if I have 1000 records in by table then I want this column to have values from 2200 to 2200 + 1000.
I hope I made myself clear.
Please help me.
Thanks in advance.
|
|
|
|
|
declare @newValue as int<br />
set @newValue = (selex max(colname) from tablename)<br />
<br />
insert into tablename ColumnName <br />
values (@newValue+1)
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
Thanks for the reply but I dont want to insert the records. I want to update one columns values which null now.
How can we do this??
|
|
|
|
|
I don't understand good ur questions.
To update columns which have null value then simple use Update tablename where colname=null and coname=anothercondition
If this is again not help then describe in detail your case.
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
Well what I want is:
Table Name: tb_Data
Columns: Name1, Name2, ID
Number of Records : 1000
Something like this:
Name1 Name2 ID
----------------------------------------
N1 N2 null
N3 N4 null
N3 N4 null
N3 N4 null
Like wise....
N3 N4 null
Now ID Column has null values and in ID Column I want it to get values starting from 2200 to 3200 that is records should be now as:
Name1 Name2 ID
----------------------------------------
N1 N2 2200
N3 N4 2201
N3 N4 2202
N3 N4 2203
Like wise....
N3 N4 3200
Is there anyway to do it by Query as Im having records in lakhs.
Thanks again.
|
|
|
|
|
hi,
Well based on your last post I have more clear your situation.
It seems that you dont have increament column in table and i make fast solution,maybe is not the best solution but it will work.
here is code down below,just copy-modify-paste and use in your real data
create table #TempTable <br />
(<br />
IdentValue int IDENTITY(1,1),<br />
Name1 varchar(255),<br />
Name2 varchar(255),<br />
ID Int<br />
)<br />
<br />
insert into #TempTable <br />
select name1,name2,id from tabela<br />
<br />
<br />
declare @i as int<br />
set @i=0<br />
<br />
declare @startValue as int<br />
set @startValue =2200<br />
<br />
declare @endValue as int<br />
set @endValue=3200<br />
<br />
while @i<(select count(*) from #temptable)<br />
begin<br />
set @i=@i+1<br />
set @startValue=@startValue+1<br />
update #tempTable set ID=@startValue where identValue=@i<br />
end<br />
<br />
delete from tabela<br />
insert into tabela <br />
select name1,name2,id from #temptable<br />
<br />
drop table #temptable<br />
select * from tabela
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
Thanks in adv.
Hello,
I want to change the filed length of a fields let suppose item_Name which is in more then 1 table
let suppose 10
the below query will give me the names of those tables
select sysobjects.name from syscolumns
left join sysobjects on sysobjects.id = syscolumns.id
where syscolumns.name like 'Item_Name' order by 1
now i want to update all those table having that field , length to more but i could not even while using cursors
Regards ,
mirza Rahman
|
|
|
|
|
use Alter Table to change the column widths.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
But in Alter table i have to specify the Name of the table one by one i want that it will take table name automatically from some cursor or some other way
in yours case if have to write this query more then 50 times
like
alter table SalesMaster
alter table PurchaseMaster
alter table ItemMaster
alter table ItemDetail
i want it will check the field automatically in those table and will update the field length
Thanks
Best Of Regards,
Mirza Rahman
|
|
|
|
|
Use your select from systobject to identify the tables, you know the column name and create dynamic SQL to execute the alter table.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
|
Based on some business objects, I need a database model to store generic property values.
The range of possible value types is known (no binary types).
What I already have:
CREATE TABLE ObjectOne
(
Id int, -- primary key
... -- more fields
)
CREATE TABLE ObjectOneProperties
(
ObjectOneId int, -- primary key, foreign key to the object one
ObjectPropertiesId int, -- primary key, foreign key to the properties
)
CREATE TABLE ObjectTwo
(
Id int, -- primary key
... -- more fields
)
CREATE TABLE ObjectTwoProperties
(
ObjectTwoId int, -- primary key, foreign key to the object two
ObjectPropertiesId int, -- primary key, foreign key to the properties
)
CREATE TABLE ObjectProperties
(
Id int, -- primary key
PropertyType varchar(255) -- property business type
??? -- property value ? foreign key(s) ?
)
Until now, I have found two possible approaches:
Store value in one table
CREATE TABLE PropertyValues
(
Id int, -- primary key
ValueInt int, -- value as int
ValueText varchar(x), -- value as text
ValuedateTime datetime, -- value as datetime
... -- all other value types
) Store value in multiple tables
CREATE TABLE PropertyIntValues
(
Id int, -- primary key
Value int -- value as int
)
CREATE TABLE PropertyTextValues
(
Id int, -- primary key
Value varchar(x) -- value as text
)
CREATE TABLE PropertyDateTimeValues
(
Id int, -- primary key
Value datetime -- value as datetime
)
CREATE TABLE PropertyXxxxValues -- for any other value types
(
Id int, -- primary key
Value xxx -- value as xxx
) I have the following selection criteria:
- High performance is required
- Database neutral (if possible)
- Stored Procedures allowed
- No Triggers
- Storage amount is not critical
Any help, suggestion or alternative solution is greatly appreciated.
|
|
|
|
|
Hmm, why not use XML as datatype for properties and store them in the same table as the main entity?
|
|
|
|
|
Hi Mika,
I never used a XML field in a table. How is the performance of such a XML field?
Is it possible to make indexes or type specific queries (for example values within a date range)?
I have found further information on this topic Entity-attribute-value model[^].
|
|
|
|
|
Jani Giannoudis wrote: How is the performance of such a XML field
This depends on what database you use. For example SQL Server 2008 has: CREATE XML INDEX[^] on the other hand SQL Server 2005 has a bit different approach: Indexes on xml Data Type Columns[^]
But in both cases I think the performance is quite good.
Jani Giannoudis wrote: Is it possible to make indexes or type specific queries
Both would be possible. You could for example store the type in schema or in the xml itself.
The link you found also seems quite good.
|
|
|
|
|
Hi..
I have one table with columns
Id int, Message varchar, QueId int
I store messages in this table. Id is auto generated and that will be the id of message. Message will be message and queid will be the Id of the message for which your reply message is posted.
So I am storing messages as well as their replies in the same table.
The message which is not the answer of any question will have value 0 in the queid field.
One message can have multiple reply messages and these replies again can have multiple replies -- just like discussion forum / blog.
So one message can have hierarchy of messages...
Now my question is that.. I want to delete a message , now if i delete a message then this message's whole hierarchy should be deleted...
I can delete the message and the messages which are replies of this message, but what about the messages which are the replies of these deleted messages ?... i.e I also want to delete the same...
Could you tell me the solution...or how can i create stored procedure which can work recursively , for deleting records...
Awaiting for reply
Thanks
Hemant Thaker
By:
Hemant Thaker
|
|
|
|
|
Am not Sure which is the wise way to do that , i think Colin and the codeProject stuff might help you because their forums is like that. but i have seen that here at codeProject, when a user Deletes a Message, the submessages still remains , you want to get rid of that. I think when you store messages, if you say Queid holds the Parents reference, then you cna use your Primary key and the queid to delete the Message with its submessages in sql you cna do something like this
Your SQL must do two things
Delete the Main Message using the "ID"
and
Delete the Child messages based on the Parent ID and the Parents Queid
The way you have design your table is confusing, this should have been separated into tables , your table is not normalized , you will always have problems working on the table, some info needs to be separated.
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswam@its.co.za
|
|
|
|
|
does anybody know the best way to store case-sensitive passwords in sql server? in mysql its easy to use the varbinary type and i'm wondering if that holds for sql server
thnx
"mostly watching the human race is like watching dogs watch tv ... they see the pictures move but the meaning escapes them"
|
|
|
|
|
I only store password hashes in the db. I use the binary type but image should work as well.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
If you don't ask questions the answers won't stand in your way.
Most of this sig is for Google, not ego.
|
|
|
|
|
thnx for that ... i thought it might be the way to go but when i tried that a few years ago i had a terrible problem with the client md5 code not producing the same result as the server md5 code so nobody could log in ... if i md5 the password on the server when they register will it match the client hash when they try to log in?
using c# & sql server
"mostly watching the human race is like watching dogs watch tv ... they see the pictures move but the meaning escapes them"
|
|
|
|
|
MD5 will always have the same results, as will any algorithm. Usually them not matching occur from improper use or poor implementation. Every time my MD5 has not matched it turned out to be programmer error on my part.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
If you don't ask questions the answers won't stand in your way.
Most of this sig is for Google, not ego.
|
|
|
|
|
ok cool
thnx
"mostly watching the human race is like watching dogs watch tv ... they see the pictures move but the meaning escapes them"
|
|
|
|