|
Hi everybody
please i want to know how to index a column actualy a foreing key
i have a foreing key who megrate from a table to an other one
but i have to index the foreing key in the second table
is it a possibility to do that in sql server ??
try to be good if you can't be the best
|
|
|
|
|
If you want to add a foreign key constraint:
ALTER TABLE dbo.tblForeignTableName
ADD CONSTRAINT keyConstraintName
FOREIGN KEY(fldForeignFieldName)
REFERENCES dbo.tblPrimaryTableName(fldPrimaryFieldName)
ON UPDATE CASCADE
ON DELETE CASCADE
----------
There go my people. I must find out where they are going so I can lead them.
- Alexander Ledru-Rollin
|
|
|
|
|
Hi ,
as you know in sql server we have just datetime we don't have date & time
so when i want to recuperate the date of something in ma textbox i recuperate also the time
can you giveme a solution ??
thank you very much
try to be good if you can't be the best
|
|
|
|
|
When you recover this value from the database and store it in a datetime variable, you can check the date part by calling:
datevariable.Date;
That's it, well pretty much hehe, this actually returns the date with the time part set to 00:00:00
to put in a text box, you can simply call something like.
datevariable.ToShortString();
or
datevariable.ToString("MM/dd/yyyy");
you should change the formatting as you see fit.
I hope I addressed what you are looking for .
daniero
|
|
|
|
|
thnx man , i will try the first because i tried the second before & it dosen't work
thanks a lot
try to be good if you can't be the best
|
|
|
|
|
Hello Coders
In my 2.0 Application 2 DataSets. Here 2 DataSets tables are same. Let us assume the first DataSets Table is one, Second DataSet is also having one Table. both tables are same Tables.
DatasetA.table[0].rows.count=1000
DatasetB.table[0].rows.count=0
DatasetB.Tables[0].Merge(DatasetA.Tables[0]);
DatasetA.table[0].rows.count=1000
DatasetB.table[0].rows.count=1000
But i want this changes should be reflected to database table.
Here where i done the Mistake,
<br />
cnn = new SqlConnection("server=figmdtest01;database=CPOPMFigMD04Dev25ACA;uid=CPOPM;pwd=CPOPM");<br />
cnn.Open();<br />
<br />
cnn1 = new SqlConnection("server=(local);database=Master;uid=sa;pwd=''");<br />
cnn1.Open();<br />
<br />
cmd = new SqlCommand("select PatientProfileId,First,Middle,Last,SSN,Birthdate,Zip,MedicalRecordNumber from cus_FigMD_PatientSearch", cnn);<br />
<br />
SqlDataAdapter dataAdapt1 = new SqlDataAdapter(cmd);<br />
<br />
DataSet ds11 = new DataSet();<br />
dataAdapt1.Fill(ds11);<br />
<br />
cmd2 = new SqlCommand("select PatientProfileId,First,Middle,Last,SSN,Birthdate,Zip,MedicalRecordNumber from demo", cnn1);<br />
<br />
SqlDataAdapter dataAdapt3 = new SqlDataAdapter(cmd2);<br />
<br />
DataSet ds33 = new DataSet();<br />
dataAdapt3.Fill(ds33);<br />
MessageBox.Show(ds33.Tables[0].Rows.Count.ToString()); <br />
ds33.Tables[0].Merge(ds11.Tables[0]);<br />
MessageBox.Show(ds33.Tables[0].Rows.Count.ToString()); <br />
ds33.AcceptChanges();<br />
MessageBox.Show(ds33.Tables[0].Rows.Count.ToString()); <br />
dataAdapt3.S.Update(ds33.Tables[0]);<br />
MessageBox.Show(ds33.Tables[0].Rows.Count.ToString()); <br />
anybody anysounds, plz help me will be appriciated greatly
regards
Rupesh
|
|
|
|
|
I have installed MSDE software in one machine. it's running fine. Daily i am testing. if's working fine. But two weeks later, when i am trying to start MSSQL Server, It's not running. MSSQL Server immediately turn to off mode. what happened to the software? Please give any suggestions.
knarasimharao
|
|
|
|
|
Hi guys
The question is simple. Is is worth starting to learn SQL server 2000 now?
I've been programming to retrieve data from databases for a while & i'm currently familiar with the db design concepts & SQL.
Do u think what i learn about SQL 2000 would be of any use for version 2005? Are the changes so drastic to make my SQL 2000 knowledge useless?
Thanx for any tips 
|
|
|
|
|
SQL 2005 builds on the foundation of SQL 7.0 and SQL 2000. Knowlege of an older version will almost always apply to a newer version.
We need to graduate from the ridiculous notion that greed is some kind of elixir for capitalism - it's the downfall of capitalism. Self-interest, maybe, but self-interest run amok does not serve anyone. The core value of conscious capitalism is enlightened self-interest.
Patricia Aburdene
|
|
|
|
|
I want to pass a(numerical) value from a dropdownlist to an SQL select using the DropDownList SelectedIndexChanged event.
Here's my code so far.
protected void MyDropDownList_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList MyDropDownList = (DropDownList)("MyDropDownList");
MyLabel.Text = MyDefinitionDropDownList.SelectedItem.Value.ToString();
string strSQL;
strSQL = "SELECT COUNT(*) as count from MyTable where ID= ???";
}
My problem is that I don't know what should replace the '???'. I've tried
strSQL = "SELECT COUNT(*) as count from MyTable where ID= MyLabel.Text";
but this is interpreted as "SELECT COUNT(*) as count from MyTable where ID= MyLabel.Text"
even though my debugger tells me MyLabel.Text is grabbing an OK value.
If I do strSQL = "SELECT COUNT(*) as count from MyTable where ID= 6" for example it works fine.
I think my problem is with casting?
Thanks
Majella
|
|
|
|
|
try:
strSQL = "SELECT COUNT(*) as count from MyTable where ID=' " + MyLabel.Text + " ' ";
Or better yet use parameters (see Colin Mackay's article here[^]) for reasons and examples.
We need to graduate from the ridiculous notion that greed is some kind of elixir for capitalism - it's the downfall of capitalism. Self-interest, maybe, but self-interest run amok does not serve anyone. The core value of conscious capitalism is enlightened self-interest.
Patricia Aburdene
|
|
|
|
|
|
how copy a coloumn ? from one table to another table using SQL query
naidu
-- modified at 6:44 Sunday 7th May, 2006
|
|
|
|
|
What do you want to do:
copy the data from one column in a database table to a different column in another table?
If so, you need a key field that will have identical values in both tables:
Update t2 set t2.c2 = t1.c1 from t1 where t2.ct2key = t1.ct1key
This specifies that the value in c2 of t2 should be set to the value found in t1.c1 where the rows to use are identified by the field t1.ct1key having a value equal to that in t2.ct2key
If this is *not* what you want, then rephrase your question to be more specific, perhaps including and example so we can understand...
We need to graduate from the ridiculous notion that greed is some kind of elixir for capitalism - it's the downfall of capitalism. Self-interest, maybe, but self-interest run amok does not serve anyone. The core value of conscious capitalism is enlightened self-interest.
Patricia Aburdene
|
|
|
|
|
Hi..
I have used Full Text Search successfuly with English words (through a stored procedure) but when i use it with arabic words like this(in the Sql Analyzer):
DECLARE @HowManyResults int
EXEC SearchProject 'المواقع العامة','ar-SA',@HowManyResults OUTPUT
I get the error:
Server: Msg 7619, Level 16, State 1, Procedure SearchProject, Line 17
Execution of a full-text operation failed. A clause of the query contained only ignored words.
Does any one know how to solve this problem?
|
|
|
|
|
without seeing the stored procedure you are using, this will be difficult to guess.
We need to graduate from the ridiculous notion that greed is some kind of elixir for capitalism - it's the downfall of capitalism. Self-interest, maybe, but self-interest run amok does not serve anyone. The core value of conscious capitalism is enlightened self-interest.
Patricia Aburdene
|
|
|
|
|
Thank you for your respond...
The stored procedure code:
CREATE PROCEDURE SearchProject
(
@SearchString varchar(500),
@CultureName varchar(50),
@HowManyResults int OUTPUT
)
AS
CREATE TABLE #SearchTable
(
FieldNO int,
ProjectNO int,
ProjectName varchar(1000),
ProjectDescription varchar(1000),
ProjectImage varchar(1000),
CultureID int
)
INSERT INTO #SearchTable (FieldNO,ProjectNO,ProjectName,ProjectDescription,ProjectImage,CultureID)
SELECT P.FieldNO, PL.ProjectNO,PL.ProjectName,PL.ProjectDescription,P.ProjectImage,PL.CultureID
FROM FREETEXTTABLE(Project_Locale,*,@SearchString) AS FT JOIN Project_Locale AS PL ON FT.[KEY]=PL.ProjectCultureID
JOIN Project AS P ON P.ProjectNO=PL.ProjectNO
WHERE PL.CultureID=dbo.GetCultureID(@CultureName)
INSERT INTO #SearchTable (FieldNO,ProjectNO,ProjectName,ProjectDescription,ProjectImage,CultureID)
SELECT P.FieldNO, PL.ProjectNO,PL.ProjectName,PL.ProjectDescription,P.ProjectImage,PL.CultureID
FROM Project_Locale AS PL ,Project AS P,
ProjectField_Locale AS FL,
FREETEXTTABLE(ProjectField_Locale,*,@SearchString) AS FT2
WHERE FL.FieldNO=P.FieldNO
AND FL.FieldCultureID=FT2.[KEY]
AND PL.ProjectNO=P.ProjectNO
AND PL.CultureID=dbo.GetCultureID(@CultureName)
AND FL.CultureID=dbo.GetCultureID(@CultureName)
INSERT INTO #SearchTable (FieldNO,ProjectNO,ProjectName,ProjectDescription,ProjectImage,CultureID)
SELECT P.FieldNO, PL.ProjectNO,PL.ProjectName,PL.ProjectDescription,P.ProjectImage,PL.CultureID
FROM Project_Locale AS PL ,Project AS P,
Feature_Locale AS PFEA,
ProjectFeature AS FP,
Feature AS F,
FREETEXTTABLE(Feature_Locale,*,@SearchString) AS FT3
WHERE FT3.[KEY]=PFEA.FeatureCultureID
AND FP.ProjectNO=P.ProjectNO
AND FP.FeatureNO=PFEA.FeatureNO
AND PL.ProjectNO=P.ProjectNO
AND F.FeatureNO=PFEA.FeatureNO
AND PFEA.CultureID=dbo.GetCultureID(@CultureName)
AND PL.CultureID=dbo.GetCultureID(@CultureName)
SELECT @HowManyResults=COUNT(DISTINCT ProjectNO) FROM #SearchTable
SELECT DISTINCT * FROM #SearchTable
RETURN
GO
As i said before :this stored procedure was working fine with english words.
|
|
|
|
|
As a first step, try changing the data types in the SP and the internal table from varchar to nvarchar, so they expect unicode text rather than ansi text...
We need to graduate from the ridiculous notion that greed is some kind of elixir for capitalism - it's the downfall of capitalism. Self-interest, maybe, but self-interest run amok does not serve anyone. The core value of conscious capitalism is enlightened self-interest.
Patricia Aburdene
|
|
|
|
|
Should i change the Data Type for all the tables used in the stored procedure or only in the #SearchTable table?
|
|
|
|
|
At least the #searchtable, and the fields being searched in the other tables.
varchar stores only single byte text, nvarchar stores Unicode. Any UI used to display nvarchar needs to be unicode aware and select the appropriate locale and a font that supports the needed characters. Enterprise manager and query analyzer may default to both a locale and font that results in some characters being displayed as an empty 'box' character...
We need to graduate from the ridiculous notion that greed is some kind of elixir for capitalism - it's the downfall of capitalism. Self-interest, maybe, but self-interest run amok does not serve anyone. The core value of conscious capitalism is enlightened self-interest.
Patricia Aburdene
-- modified at 13:19 Sunday 7th May, 2006
|
|
|
|
|
Thank you very much..
I will try it and then i will tell you about the results
|
|
|
|
|
Hi..
I have changed all the data types used by the stored procedure (all the tables and the #SearchTable).
Each time i modify a data type for a table the compiler tell me to repopulate the fulltextIndex for that table and that what i did.
But after all these modifications i got the same error at the SqlAnalyzer.
Is there another thing i should do?
|
|
|
|
|
Look here[^]. The last section on Noise words might be pertinent...
We need to graduate from the ridiculous notion that greed is some kind of elixir for capitalism - it's the downfall of capitalism. Self-interest, maybe, but self-interest run amok does not serve anyone. The core value of conscious capitalism is enlightened self-interest.
Patricia Aburdene
|
|
|
|
|
This article[^] may also have some useful info
We need to graduate from the ridiculous notion that greed is some kind of elixir for capitalism - it's the downfall of capitalism. Self-interest, maybe, but self-interest run amok does not serve anyone. The core value of conscious capitalism is enlightened self-interest.
Patricia Aburdene
|
|
|
|
|
Hi..
When i used the code (part of the procedure):
SELECT P.FieldNO, PL.ProjectNO,PL.ProjectName,PL.ProjectDescription,P.ProjectImage,PL.CultureID
FROM FREETEXTTABLE(Project_Locale,*,@SearchString) AS FT JOIN Project_Locale AS PL ON FT.[KEY]=PL.ProjectCultureID
JOIN Project AS P ON P.ProjectNO=PL.ProjectNO
WHERE PL.CultureID=dbo.GetCultureID(@CultureName)
With arabic words(inputs:@CultureName,@SearchString) it works fine but when i call the whole stored procedure(SearchProject) i got the error i mentioned before..I think the problem exists in the line :
INSERT INTO #SearchTable (FieldNO,ProjectNO,ProjectName,ProjectDescription,ProjectImage,CultureID)
But i dont know what is the problem and how to solve it?Is there a problem with cultures in the temporary table?
|
|
|
|
|