|
It's all right - I'll 5 vote Colin for you. Sheesh, come on guys - he's helping you; show some appreciation.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Can you please tell me how to delete a perticular row from a table in SQL Server 2005?
|
|
|
|
|
delete from tablename where id in(1,4,6)
this sql query deletes row 1,4 and 6
I Love SQL
|
|
|
|
|
Suresh R.. wrote: how to delete a perticular row from a table in SQL Server 2005
you can have this...
--Deleting single or multiple rows
DELETE FROM TABLE WHERE ID = VALUE
DELETE FROM TABLE WHERE ID IN (VALUE1, VALUE2, VALUE3)
--deleting top 100 rows
DELETE FROM TABLE WHERE ID (SELECT TOP 100 ID FROM TABLE ORDER BY ID)
--delete records in one table based on values in another table
DELETE FROM TABLE A
WHERE EXISTS
( SELECT ID
FROM TABLE B
where B.ID = A.ID)
--delete records in one table based on values that doesn't match in another table
DELETE FROM TABLE A
WHERE NOT EXISTS
( SELECT ID
FROM TABLE B
where B.ID = A.ID)
--deletes all rows and reinitializes the table
TRUNCATE TABLE TABLENAME --(not reccommended if you
--don't know the exact use of truncate stmt)
--deleting duplicate rows from a table
Check This[^]
Regards J O H N
"Even eagles need a push." David McNally
|
|
|
|
|
Hi!
I have a project to talk about "Concurrency Control" in SQL Server. Please! give me some imformation (or ebooks)talking about "Concurrency Control".
Thanks!
|
|
|
|
|
|
i am making reports using sql2005 reporting service. i have 2 reports in a project.what i want is that when i click the value in first report that value is going as a parameter to other report (2nd report) and the second report will generate the result on the basis of the value that what clicked in report 1.
thanks
Salman
|
|
|
|
|
|
I create an insert trigger that calls a stored procedure. If an error is encountered when calling the stored procedure, then the trigger appears to affect the insert action such that multiple records are inserted recursively. How can this problem be sorted out.
|
|
|
|
|
when use the getdate() function it gives the date and the time ,can't i get only the date without time.
|
|
|
|
|
You can try the following:
CONVERT(NVARCHAR(20), GETDATE(), 101)
You can play arround with the third parameter to get different date formats
Say, CONVERT(NVARCHAR(20), GETDATE(), 102), etc
|
|
|
|
|
hi
like i use devenv to open visual studio environment
what is the shortcut key for Sql Server
Regards,
Prashanth
|
|
|
|
|
You have to configure a shortcut key to use SQL Management Studio from within VS, I think.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Assuming you've installed Sql Server Management Studio into it's default location, you would use "C:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\SqlWb.exe", so if you have the path set up you would use SqlWb .
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi all,
when i use select convert(varchar(10),getdate(),101)
query the output is server system date
But i want my local system's date
regards,
Prashanth
|
|
|
|
|
pashitech wrote: i want my local system's date
If SQL Server is not on your local machine, you cannot do this.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
SQL on MS SQL Server runs on the server itself. It has no access to your local machine.
That is conceptually how all database systems work.
If you want the local time then send it to SQL server with the rest of the request. However note that that probably isn't a good idea in terms of SQL Server. Timezone problems make that very problematic. And if you are not dealing with timezones then it shouldn't matter whether the client or server time is used.
|
|
|
|
|
below given a database structure. in table A if any formid insert then table B auto insert formID, each Distinct EmpID
----- row insert manually----------
===== row insert Automatically========
Table A
FormID FormName
1 Department
2 Employee
-----3(FormID)------Location(FormName)---new insert row
Table B
FormID EmpID
1 1
2 1
====3(FormID)===1(EmpID)======>>autoinsert through trigger
1 2
2 2
=====3(FormID)===2(EmpID)======>>autoinsert through trigger
1 3
2 3
=====3(FormID)===3(EmpID)======>>autoinsert through trigger
any one help me through insert trigger on Tble A
|
|
|
|
|
Could you please explain what you want in a clearer fashion? I must admit that this is a rather confusing description.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
scon.ConnectionString = <br />
"integrated security= true ;" +"initial catalog =my;" + <br />
"data source =BUDDHIKA\\SQLEXPRESS;";<br />
<br />
<br />
scon.Open();<br />
<br />
sc.Connection = scon;<br />
<br />
sc.CommandText = "create login " + textBox6.Text +<br />
" with password ='" + textBox7.Text + "' ";<br />
<br />
sc.CommandText += "exec sp_addsrvrolemember " <br />
+ textBox6.Text+ ",sysadmin ";<br />
<br />
sc.CommandText += "create user " + textBox6.Text + " from login " <br />
+ textBox6.Text + " use my ";<br />
<br />
sc.CommandText += "execute sp_addrolemember " <br />
+ comboBox3.SelectedItem.ToString() + "," + textBox6.Text <br />
+ " use my";<br />
<br />
SqlDataReader sd = sc.ExecuteReader();<br />
<br />
sd.Close();<br />
<br />
sc.CommandText = "insert into my.dbo.sys_usr values <br />
('" + comboBox4.SelectedItem.ToString() + "','" + textBox1.Text <br />
+ "','" + textBox46.Text + "','" + textBox2.Text + "','" <br />
+ comboBox2.SelectedItem.ToString() + "','" <br />
+ Box3.SelectedItem.ToString() + "')";<br />
<br />
sd = sc.ExecuteReader();
when i run this code get an error
Incorrect syntax near the keyword 'with'.
Incorrect syntax near the keyword 'with'. If this statement is a common table expression or an xmlnamespaces clause, the previous statement must be terminated with a semicolon.
|
|
|
|
|
prasadbuddhika wrote: sc.CommandText = "create login " + textBox6.Text +
" with password ='" + textBox7.Text + "' ";
try to replace with
<br />
sc.CommandText = "create login " + textBox6.Text +<br />
" with [password] ='" + textBox7.Text + "' ";
I Love SQL
|
|
|
|
|
What is wrong with this code is the huge potential for someone to inject SQL into your database. You should look at paramterising this.
|
|
|
|
|
Apart from leaving you wide open to SQL Injection attacks, the variable names are really bad. What would you expect if I swapped textBox46 and textBox2 around here? How could you tell when looking at the code?
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
|
Hi
I am getting following error on connection string in xmlbulkload:
"QueryInterface for interface SQLXMLBULKLOADLib.ISQLXMLBulkLoad failed."
Thanks
Hardik Panchal
|
|
|
|