|
<br />
ALTER TABLE tableName ADD value int NULL<br />
<br />
DECLARE @i AS INT<br />
DECLARE @j AS INT<br />
SET @i=0<br />
SET @j=0<br />
<br />
WHILE @j<=(SELECT MAX(id) FROM tableName )<br />
BEGIN<br />
SET @j=@j+1 <br />
IF(SELECT COUNT(id) FROM tableName WHERE id=@j)=0<br />
BEGIN<br />
SET @i=@i+1 <br />
UPDATE tableName SET value=@i WHERE id=@j<br />
END <br />
END<br />
<br />
SELECT * FROM tableName WHERE value =3<br />
ALTER TABLE tableName DROP COLUMN value<br />
<code><br />
<br />
Hope it helps... <br />
<br />
<div class="ForumSig"><hr><small> <font color="Brown" size="2" face="Curier New">I Love T-SQL</font></small><br />
<small> <font color="Brown" size="1" face="Curier New">"Don't torture yourself,let the life to do it for you."</font></small><br />
</hr></div>
|
|
|
|
|
SELECT ROW_NUMBER()
OVER (ORDER BY EmployeeName) AS Row,
EmployeeId, EmployeeName
FROM Employees
|
|
|
|
|
Hi
I am in the situation to write code to pull the data from a table which has 1 Million rows per day
what are the optimal ways to search the text ?
database : SQL Server 2000
I have index on the table
The table is portioned
nrk
|
|
|
|
|
Hi,
Not necessarily optimal but this may interest you Full-Text Indexes[^]
Another possibility is to create custom keyword based index table using triggers etc
Hope this helps,
MIka
|
|
|
|
|
Hi, thanks for looking
Im currently hosting my site with godaddy, but ive been having problems when uploading and modifying my DB, since it doesnt allow remote connections from SQL Server Management Studio it only has a webapp (SQL Server web Admin)
My app is a small site, i cant have a dedicated server with them since thats too expensive, i just have a medium plan
I need a hosting company that allows me to connect remotely
Im looking for something not expensive
Im using:
ASP.NET 2.0, AJAX and SQL Server 2005
Please give me some suggestions
Thanks in advance
Alexei Rodriguez
|
|
|
|
|
Check Fort Nocs Networks
I know for sure they allow remote connections, but I have no idea about pricing.
Please... SAVE my time by rating the posts that you read!
There are 10 kinds of people in the world: those who understand binary and those who don't.
|
|
|
|
|
Thanks for the reply
They dont show much info or pricings
It must be expensive, it looks like they offer something more than just sql server hosting
Alexei Rodriguez
|
|
|
|
|
what is the mean of WHILE (1=1) shown in the sample codes as below:
--------------------------
IF (A > B)
A := A + 1;
ELSE
B := B + 1;
WHILE (1 = 1) {
A := A + 1;
}
FOR (declare X any, X := 1; X <= 2 ; X := X + 1){
S := S + X;
}
FOR (declare X any, X := 1; X <= 2 ; ){
S := S + X;
X := X + 1;
}
---------------------------
thanks
|
|
|
|
|
It makes an infinite loop.
|
|
|
|
|
To define an infinite loop
|
|
|
|
|
First, this is the SQL and Database Discussion Forum, not a programming forum.
Second, what do YOU think the WHILE is doing?
|
|
|
|
|
quick infinite loop
|
|
|
|
|
Hi,
I am using sql 2005.I have a value -0.026880000000000 but I want the result as -0.0268 just 3 decimals.If I use select convert(decimal(18,3),-0.026880000000000) I am getting -0.027 with rounded.
can anybody help me out in this.
Thx
|
|
|
|
|
Try this:
a) Multiply the value by 1,000
b) Truncate the value
c) Divide the number by 1,000
David
|
|
|
|
|
HI,
if i do like that select convert(decimal(18,3),(-0.0268000000000000000)*1000/1000) I am getting -0.027 which is again rounding.can you help me how to truncate the value with out rounding.
|
|
|
|
|
I realize someone already replied, but here is my 2 cents ...
select convert(decimal(18,3),(convert(integer,(-0.0268000000000000000)*1000)))/1000
|
|
|
|
|
select convert(int,convert(decimal(18,5),-0.026880000000000)*100000.0)/100000.0
|
|
|
|
|
DECLARE @val AS VARCHAR(255)
SET @val='-0.026880000000000'
SELECT SUBSTRING(@val,1,CHARINDEX('.',@val)+4)
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
|
|
|
|
|
|
I have written one VIEW. it returns 10 rows.
Now I need to show only 3rd row data.
Please suggest me.
|
|
|
|
|
If you have to show three rows from View then use query down:
SELECT TOP 3 * FROM viewName
If youhave to show only third row of view then use query:
SELECT TOP 1 * FROM viewName where Columnanme=conditionvalue
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
|
|
|
|
|
I don't want show all 3 records
one 3rd one ..etc 4th ,5th it could be any one of 1st to 10th..
not all
Let us see....
My view name is TestView. it has only one column customer_name.
now tell me I need to see only 6th row only....
|
|
|
|
|
SELECT TOP 1 * FROM viewName where Columnanme=conditionvalue
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
|
|
|
|
|
Please look into my previous reply....
|
|
|
|
|
select top 1 * from TestView where customer_name='CustomerNameInRowSix'
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
|
|
|
|