|
Hi,
I installed SQL Server 2005 on my pc, but i didn't get default databases like(northwind, adventureworks...etc).
anybody help me how to get/install these default databases
steps or link will be appriciated.
thanks
Ramana
|
|
|
|
|
|
what is the difference between sql,ms sql and sqlserver 2000
Signature preview salil_k_singh 11:06 15 Jul '07
|
|
|
|
|
SQL is the generic term for the programming language used to query databases, for example select column1 from table1
MS SQL is the gerneric term for Microsft's implementation of SQL or it is sometimes used as the generic name for any of Microsoft's SQL Server versions
SQL Server 2000 is s specific version of Microsoftd database system, SQL Server
Hope this clarifies
Bob
Ashfield Consultants Ltd
|
|
|
|
|
This sounds like a homework problem
|
|
|
|
|
Hi All,
I have some prob in c#.So i want to CREATE a TABLE on Button's "click" event.That's mean when I click on "ok" botton "a new table have to create on my existing DATABASE ".So how i do it in C#..?
ReGardZ
"ChiNthaKa"
CheeN
|
|
|
|
|
The same as you do any other time, issue a CREATE TABLE command - for example
CREATE TABLE Fred(Column1 int NOT NULL, Column2 varchar(50) NULL...etc)
Bob
Ashfield Consultants Ltd
|
|
|
|
|
|
yep, thats another way
Bob
Ashfield Consultants Ltd
|
|
|
|
|
yep
I Love T-SQL
|
|
|
|
|
Hi Chinthaka ,
You can write the following code in the button onclick event . Before that you should import System.Data.SqlClient namespace .
<br />
SqlConnection conn= new SqlConnection("ConnectionString");<br />
conn.Open();<br />
MessageBox.Show("Connection est.."); <br />
SqlCommand comCreate = new SqlCommand("CREATE TABLE EMP_TABLE_CREATE(EmpID INT , EmpName VARCHAR(20))",conn);<br />
int intCreate = comCreate.ExecuteNonQuery();<br />
MessageBox.Show("Table Created.." + intCreate); <br />
SqlCommand conInsert = new SqlCommand("INSERT INTO EMP_TABLE_CREATE VALUES(11,'MyName')",conn ) ;<br />
int intInsert = conInsert.ExecuteNonQuery(); <br />
MessageBox.Show("Row Inserted.." + intInsert); <br />
MessageBox.Show("Displaying Row : "); <br />
SqlCommand conSelect = new SqlCommand("SELECT * FROM EMP_TABLE_CREATE",conn) ;<br />
SqlDataReader dr= conSelect.ExecuteReader(); <br />
dr.Read();<br />
while(dr.HasRows)<br />
{<br />
MessageBox.Show(dr.GetInt32(0).ToString() +":"+dr.GetString(1)) ; <br />
dr.NextResult(); <br />
}<br />
conn.Close(); <br />
Hope this is what you wanted . Let me know if you have any further queries .
Thanks
Priya Rohan
|
|
|
|
|
Hi, in SQL Express when we design the table, which option/data type that could set the field as auto number like in Microsoft access? Thank in advance
|
|
|
|
|
Ok, now i found it. It is locate in Identify Specification
|
|
|
|
|
I'm trying to find out how many records are in a table using this code but I keep getting -1 for n.
Dim command As String, data As ADODB.Recordset, n As Integer<br />
<br />
rsGuest.Open("Guest", ADOConnection,ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)<br />
command = "SELECT [Guest ID] from Guest"<br />
<br />
data = ADOConnection.Execute(command)<br />
n = data.RecordCount
I read on another webisite that I need to add this line:
data.CursorLocation = ADODB.CursorLocationEnum.adUseClient
but when I do I get this error:
Operation is not allowed when the object is open.
So what should I do. Thank you for your help.
Mike
|
|
|
|
|
forgot to add I'm doing this with vb.net 2005 with microsoft access 2007.
|
|
|
|
|
If you are using vb.net , I would recomment using the System.Data.Oledb classes rather than com interop with ADODB. It would be both easier and more performant.
To get the number of records currently in a table Use "Select Count(*) as nRecs from Mytable" for your query.
For your ADODB approach to work, you have to navigate to the end of the recordset before the count is accurate (use Recordset.MoveLast). Obviously, this is slow...
To changed to a client side cursor, set the cursortype variable BEFORE opening the connection.
Hope thies suggestions help.
|
|
|
|
|
Hi,
you could try a SELECT COUNT(*) FROM Guest and use ExecuteScalar, then
cast to integer.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Hi thank you both for your help. I don't have much experience with database programming and I'm not sure what ExecuteScalar is a method of or how I would use it.
To clarify the question of whether I was trying to get the number of rows or the highest id number, I was looking for the number of rows.
thanks again Luc and blueboy,
Mike
|
|
|
|
|
Check this link[^], you can learn more about ExcuteScalar method.
I Love T-SQL
|
|
|
|
|
If you want to get maximum value of Guest ID then use this query
select max([Guest ID]) from Guest
If you have to get number of rows on table then refer to Luc Pattyn's answer.
I Love T-SQL
|
|
|
|
|
Hi.
How can I link DBase III Files in SQL Server 2000.( Linked Server ).
|
|
|
|
|
Hi all,
I am trying to fetch a CsV file from an Ftp site on to a SQL table every three hours.The Csv has the same fields as the table in Sql.
How do i go about this problem? your ideas are most appreciated.
Please advice.
Thank you
|
|
|
|
|
If you're using 2005 search google for SSIS FTP Task. If you're using an earlier version of SQL Server search google for DTS FTP Task. If you run into any problems, then let us know what your specific problem is and what the specific symptoms are and we'll give you a hand.
|
|
|
|
|
Thank you mark,
I have manged to copy the file from the FTP task to the local Pc where SQl is running.However now would like to update my table with the Bulk Insert task in to the table.
How will I make sure that every 30 Minutes its getting a new file from the Ftp and then Insert it to My table in Sql2005.No Duplicated data will be enterd in to the table more than once.
As I am dumping the file on two one folder how will the bulkinsert task remembers this file is used and the other one is going to be used.
Thank you
|
|
|
|
|
Create a data flow task. Use the flat file transform as your source and either Sql Server destination or OleDb destination transform. I personnally don't like the Sql Server destination because it seems buggy to me.
If you want to prevent duplicate data you have a couple options:
1) create an empty table you can load using the data flow task. Then use a sql command to copy the data from the loading table into your target for all records which don't exist in the target. I recommend that you include a step to truncate your loading table before loading it will data. This option is probably the easiest if you're not familiar with SSIS and will probably perform best if you are working with a large dataset.
2) Add a lookup transform to your data flow task to match existing records from your target table with records in your flat file source. Then redirect any errors (ie. records which don't match, thus don't exist already in your target) to your destination transform.
3) Use 2 source transforms, one for your flat file source and one for your target table. Then use a merge transform and use it to filter any matches and return only records which don't have a match. Then pass the results to your destination transform.
Options 2 and 3 may not be viable if your target table is large, unless you have a way to filter the data for the lookup/merge. Like if you can filter the data by a date range or by some foreign key based on your knowledge of the data that is in your flat file source.
Hope this helps
|
|
|
|