| Author |
Topic |
|
Hotice
Starting Member
9 Posts |
Posted - 2006-05-31 : 18:33:36
|
| Is there "enumerate values" in SQL server? I know that VB.Net has enumeration. If there is enumeration in SQL server, how to do that?Thanks. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2006-05-31 : 18:41:23
|
| I know what enumeration is, but I'm wondering exactly what you want to do in the database. Do you want SQL Server to assign these numeric values for you? If so, then you'll want to use IDENTITY.Tara Kizeraka tduggan |
 |
|
|
Hotice
Starting Member
9 Posts |
Posted - 2006-05-31 : 19:04:17
|
| Suppose that I have a column in a table, the value of the column is different combination of numbers 1-5 (for example the value of the column maybe ‘1’ or ’ 2’ or ‘3’ or ‘4’ or ‘5’ or ‘1, 2’ or ‘2, 3,4’ or ’1, 2,3,4,5’) . Each number represent an value (1 represent for A, 2 for B, 3 for C, 4 for D , 5 for E). In my query, if the column value is 1, then I want to display A in the result; if the value is ‘1, 2’, then I want to display ‘A, B’; if the value is ‘2,3,4’, then I want to display ‘B, C, D’ .My question is how to enumerate all the possibilities in all orders to get the query result right?Thanks. |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2006-06-01 : 06:15:24
|
1. this is a denormalizerd db design. Normalize it.2. there's no such thing as enumeration in SQL Server.3. you could add a computed column with a user defined function to perform the conversion (i wouldn't do that)4. handle this in your app not your db (i'd do that)Go with the flow & have fun! Else fight the flow Blog thingie: [URL="http://weblogs.sqlteam.com/mladenp"] |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
Hotice
Starting Member
9 Posts |
Posted - 2006-06-01 : 12:23:06
|
| Thanks for all the replay. It is true that the db is not normalized. |
 |
|
|
h8Society
Starting Member
7 Posts |
Posted - 2007-10-28 : 04:32:50
|
| And i want to show all sql server instance in a combobox. How can i see them ? |
 |
|
|
h8Society
Starting Member
7 Posts |
Posted - 2007-10-28 : 04:35:01
|
| only local servers.Now im usin my connectionstring... Ý take it from "properties/server explorer"@"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\acer\Documents\Compare.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True");But i need all servers |
 |
|
|
h8Society
Starting Member
7 Posts |
Posted - 2007-10-28 : 10:29:31
|
i did it.To help someone who look this topic i wanna tell my answer about this problem.sql code : SELECT * FROM sysdatabases in this "select" there is a "name" column. this colomn show databases names in the system. To recieve "connection string" of this columns. there is a "file name" column. And we can change the connection string @"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\acer\Documents\Compare.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"); change the underline words with "file name" column.and then Go ! |
 |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2007-10-28 : 11:29:25
|
| those aren't instances, they are databases |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-10-28 : 13:27:56
|
| h8Society,You don't reference MDF files in a connection string. That's not how SQL Server works.http://www.connectionstrings.com/?carrier=sqlserverTara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
h8Society
Starting Member
7 Posts |
Posted - 2007-10-30 : 07:23:24
|
Hi, i did it in my project : SQL COMPARE And it works. Ýn this situation what am i doing ? i can see all servers and data connections. ? still is it wrong ? if (!string.IsNullOrEmpty(message)) { MessageBox.Show(message); return; } sourceConnectionString = string.Format(@"Data Source=.\SQLEXPRESS;AttachDbFilename={0};Integrated Security=True;Connect Timeout=30;User Instance=True",cmbDatabeses.Text); targetConnectionString = string.Format(@"Data Source=.\SQLEXPRESS;AttachDbFilename={0};Integrated Security=True;Connect Timeout=30;User Instance=True",cmbDatabases1.Text); Database source = new Database(sourceConnectionString); Database target = new Database(targetConnectionString); // source.GetTables(); //target.GetTables(); Dictionary<string, StoredProcedure> sourceSpList = source.getStoredProcedures(); Dictionary<string, StoredProcedure> targetSpList = target.getStoredProcedures(); Dictionary<string,Table> sourceTableList = source.GetTables(); Dictionary<string,Table> targetTableList = target.GetTables(); Dictionary<string,View> sourceViewList = source.GetViews(); Dictionary<string,View> targetViewList = target.GetViews();i m using visual studio express 2005 now i got bored now :S . tkizer please help. What is wrong. my Codes in a text box want a server i wrote ".\sqlexpress" and then ican see all data connections. Also in "red gate inc."'s program whic name is "sql compara 6" same thing display. |
 |
|
|
|