|
Experts,
In my oracle database i have a column "Description". I have to show only 25 characters while writing the select command. Is there any way for that or i have to use cursor
|
|
|
|
|
|
hello
TSQL to print the content/inside of stored proc, definition of view and tables?
The idea is to automate detection of any changes to stored proc or view/table schema.
Thanks
dev
|
|
|
|
|
Uhm it's called source control and there are a vast number of systems built to meet this need. And they almost all cost money.
Otherwise you can look into the system tables and possibly the schema views, all the procedure scripts are in there. You can write then out or copy them to another table where you could simply do a != comparison on the relevant fields.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
You may use
1. information_schema.columns for columns
2. information_schema.tables for tables
3. sp_helptext 'sp_procedurename' for SP Text
|
|
|
|
|
I have a primary key in StudentTable in mySQL database called (schoolDB)... I was using it for testing and now i want to rest the primary key to start from 1
how can I do that?
|
|
|
|
|
Try this :
ALTER TABLE yourTable AUTO_INCREMENT=1
Be sure to delete all rows first.
Cheers
I don't like my signature at all
|
|
|
|
|
|
You're oversimplifying things a bit in my opinion.
It does need to be unique, and it does not matter what the values actually are if you are using surrogate keys.
But there is such a thing as natural keys, and there's nothing wrong in using them if it fits the model.
Here[^] is yet another article on the subject by Joe Celko.
"When did ignorance become a point of view" - Dilbert
|
|
|
|
|
Jörgen Andersson wrote: You're oversimplifying things a bit in my opinion
I'm sure I was.
Thanks for the link, I'll read the article.
|
|
|
|
|
Use
DBCC CHECKIDENT('Customer', RESEED, 0) for Resetting Identity seed.
Regards,
Hiren.
"We owe a lot to the Indians, who taught us how to count, without which no worthwhile scientific discovery could have been made." - Einstein
Microsoft Dynamics CRM
|
|
|
|
|
In SQL Server 2005...
How to get Column Value From a Statement if Table Name passes dynamically through a variable....?
|
|
|
|
|
You need to use dynamic sql in your prodecure.
Declare @SQL varchar(100)
set @SQL = 'Select ' + @Field + ',' + @Field2 +' from TableName'
Exec (@SQL)
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Declare one more variable and assign first column value and Print this value.......
Okay..........
|
|
|
|
|
But why use a stored procedure at all? Just do the same thing but in regular code.
|
|
|
|
|
Hi I am using a SQL statement to access data from a database, if I hardcode a specific name in the field I get, the name being searched for is returned and displayed. Of-course this isn't a convient way of doing things so I introduced a text box to take in the data, store it in a variable then, this is were my problem lies, I try and used my variable in the SQL statement but it does not work. My code is as below:
<br />
static private string GetConnectionString()<br />
{<br />
<br />
return<br />
"Driver={Microsoft Access Driver (*.mdb)};"<br />
+ "Dbq=c:\\Users\\Tichaona\\Documents\\My Dropbox\\SET10101 Software Architecture\\coursework1\\patients.mdb;Uid=java;Pwd=password;";<br />
}<br />
<br />
private void BtnSearch_Click(object sender, EventArgs e)<br />
{<br />
String nameSearch = TxtBxName.Text; <<<The variable I wish to use<br />
try<br />
{ <br />
<br />
string connectionString = GetConnectionString();<br />
string queryString = "SELECT Name FROM patients WHERE Name LIKE '%nameSearch%';"; <<<Here<br />
using (OdbcConnection connection =<br />
new OdbcConnection(connectionString))<br />
{<br />
OdbcCommand command = connection.CreateCommand();<br />
command.CommandText = queryString;<br />
<br />
<br />
try<br />
{<br />
connection.Open();<br />
<br />
OdbcDataReader reader = command.ExecuteReader();<br />
<br />
<br />
<br />
while (reader.Read())<br />
{<br />
<br />
LstBxResults.Items.Add(reader.GetString(0));<br />
<br />
<br />
}<br />
<br />
reader.Close();<br />
}<br />
<br />
catch (Exception ex)<br />
{<br />
MessageBox.Show(ex.Message);<br />
<br />
<br />
}<br />
}<br />
}
catch (Exception er)<br />
{<br />
MessageBox.Show("There is an error {0}" + er);<br />
}<br />
<br />
<br />
}<br />
<br />
<br />
}<br />
}<br />
<br />
<br />
|
|
|
|
|
Change the line
string queryString = "SELECT Name FROM patients WHERE Name LIKE '%nameSearch%';";
into
string queryString = "SELECT Name FROM patients WHERE Name LIKE '%" + nameSearch + "%'";
Use Code block instead of inline code for your code while posting here
[Edit]As Piebal's suggestion, Use parameters with command object Click here[^][/Edit]
thatraja |Chennai|India|
Brainbench certifications Down-votes are like kid's kisses don't reject it Do what you want quickly because the Doomsday on 2012
modified on Thursday, November 25, 2010 9:50 AM
|
|
|
|
|
Thanks it works great...
|
|
|
|
|
|
Negative several million!
Look up "SQL injection attack".
|
|
|
|
|
PIEBALDconsult wrote: Negative several million!
Look up "SQL injection attack".
Yes dude it's true, But he is just expecting just correct the error. Also here before I received a rude comment from Enquirer for the same type of suggestion. Ok Here after I'll add the additional details along with answer. Thanks
thatraja |Chennai|India|
Brainbench certifications Down-votes are like kid's kisses don't reject it Do what you want quickly because the Doomsday on 2012
|
|
|
|
|
Never ever ever etc. suggest concatenation. Not once, not even a little bit.
|
|
|
|
|
OK Deal
thatraja |Chennai|India|
Brainbench certifications Down-votes are like kid's kisses don't reject it Do what you want quickly because the Doomsday on 2012
|
|
|
|
|
According to question, Good Answer.
|
|
|
|
|