Primary Key Not Showing

Nov 25, 2005

I am using the Server Explorer in VS2005. I have created an additional field in a small test table with 3 other fields. The new field called foo_key does not show up when I query the table ( it has 7 records ).

I have some tables that I'd like to insert an auto-incrementing integer primary key. But at this point I cant figure out what's wrong. I have toggled the field as primary key on and off.It seems if I create a new table, then I see the primary key field and its autoincrementing as desired.

Could it be that I cannot add such a field if my table already has some records ? ...and to get one in would mean rebuilding a new table and shifting the records....pls advise



andrewcw

View 2 Replies


ADVERTISEMENT

Convert Composite Primary Key Into Simple Primary Key

Jan 11, 2007

Uma writes "Hi Dear,
I have A Table , Which Primary key consists of 6 columns.
total Number of Columns in the table are 16. Now i Want to Convert my Composite Primary key into simple primary key.there are already 2200 records in the table and no referential integrity (foriegn key ) exist.

may i convert Composite Primary key into simple primary key in thr table like this.



Thanks,
Uma"

View 1 Replies View Related

Adding Primary Key To A Table Which Has Already A Primary Key

Aug 28, 2002

Hi all,
Can anyone suggest me on Adding primary key to a table which has already a primary key.

Thanks,
Jeyam

View 9 Replies View Related

Auto Incremented Integer Primary Keys Vs Varchar Primary Keys

Aug 13, 2007

Hi,

I have recently been looking at a database and wondered if anyone can tell me what the advantages are supporting a unique collumn, which can essentially be seen as the primary key, with an identity seed integer primary key.

For example:

id [unique integer auto incremented primary key - not null],
ClientCode [unique index varchar - not null],
name [varchar null],
surname [varchar null]

isn't it just better to use ClientCode as the primary key straight of because when one references the above table, it can be done easier with the ClientCode since you dont have to do a lookup on the ClientCode everytime.

Regards
Mike

View 7 Replies View Related

SQL Server 2008 :: Change Primary Key Non-clustered To Primary Key Clustered

Feb 4, 2015

We have a table, which has one clustered index and one non clustered index(primary key). I want to drop the existing clustered index and make the primary key as clustered. Is there any easy way to do that. Will Drop_Existing support on this matter?

View 2 Replies View Related

4 Key Primary Key Vs 1 Key 'artificial' Primary Key

Jan 28, 2004

Hi all

I have the following table

CREATE TABLE [dbo].[property_instance] (
[property_instance_id] [int] IDENTITY (1, 1) NOT NULL ,
[application_id] [int] NOT NULL ,
[owner_id] [nvarchar] (100) NOT NULL ,
[property_id] [int] NOT NULL ,
[owner_type_id] [int] NOT NULL ,
[property_value] [ntext] NOT NULL ,
[date_created] [datetime] NOT NULL ,
[date_modified] [datetime] NULL
)

I have created an 'artificial' primary key, property_instance_id. The 'true' primary key is application_id, owner_id, property_id and owner_type_id

In this specific instance
- property_instance_id will never be a foreign key into another table
- queries will generally use application_id, owner_id, property_id and owner_type_id in the WHERE clause when searching for a particular row
- Once inserted, none of the application_id, owner_id, property_id or owner_type_id columns will ever be modified

I generally like to create artificial primary keys whenever the primary key would otherwise consist of more than 2 columns.

What do people think the advantages and disadvantages of each technique are? Do you recommend I go with the existing model, or should I remove the artificial primary key column and just go with a 4 column primary key for this table?

Thanks Matt

View 5 Replies View Related

Union Not Showing What I Want

Nov 22, 2004

Hi all,

I have two Selects that I want to union into one table:

The first select has this data:
Date | Yes
2004-11-20 | 4

The second select has this data
Date | No
2004-11-20 | 3

When I unioned them I want the data to show as:
Date | Yes | No
2004-11-20 | 4 | 3

I thought that I could make a 'dummy' column for each of the selects, union them and it would work right, but the output I am getting is:

Date | Yes | No
2004-11-20 | 4 | 0
2004-11-20 | 0 | 3

Can someone point me in the right direction?

Thanks,

Mike

View 1 Replies View Related

SQL Showing Last 24 Hours

Oct 31, 2005

SELECT sysjobs.name, sysjobservers.last_run_outcome, CONVERT(varchar(8), sysjobservers.last_run_date, 112) AS LastRunDate, CONVERT(varchar(8),
sysjobservers.last_run_time, 8) AS LastRunTime, GETDATE() AS CurrentDateTime
FROM sysjobs LEFT OUTER JOIN
sysjobservers ON sysjobs.job_id = sysjobservers.job_id
WHERE (sysjobservers.last_run_outcome = 0) AND (CONVERT(varchar(8), sysjobservers.last_run_date, 112) >= DATEADD(day, - 1, GETDATE()))

I am wanting a similar solution, I need to convert an "int" to a time format, when I use this where ">= DATEADD(minute, - 720, GETDATE())" for the last_run_time I get this error:

Syntax error converting datetime from character string.

View 3 Replies View Related

Why Not Showing The Nulls?

Jan 19, 2007

Hi,

I have two tbls joined via a varchar field.. which in tbl I have to use a CASE statement to format it correctly for the JOIN..

All works well.. however, if I add a WHERE clause to the statement, with the WHERE clause affecting only one of the JOINED tbls.. All the NULLS are not shown.

I should get results like:

Postcode Count

tf4 0
tf5 23
tf6 15
tf7 0
etc

Whereas, when I add the where clause, none of the "zeros" are shown, so I get:

tf5 23
tf6 15

Why is this?



Here's the SQL:



SELECT ISNULL(COUNT(CASE LEN(REPLACE(dbo.Customers_Trade.PostCode, ' ', '')) WHEN 5 THEN LEFT(REPLACE(dbo.Customers_Trade.PostCode, ' ', ''), 2)
WHEN 6 THEN LEFT(REPLACE(dbo.Customers_Trade.PostCode, ' ', ''), 3) ELSE LEFT(REPLACE(dbo.Customers_Trade.PostCode, ' ', ''), 4) END), 0)
AS PCCount, dbo.UkPostcodes.Postcode, dbo.UkPostcodes.Town, dbo.UkPostcodes.County, dbo.UkPostcodes.Area, dbo.UkPostcodes.Country,
dbo.UkPostcodes.Master_Account
FROM dbo.UkPostcodes LEFT OUTER JOIN
dbo.Customers_Trade ON dbo.UkPostcodes.Postcode = CASE LEN(REPLACE(dbo.Customers_Trade.PostCode, ' ', ''))
WHEN 5 THEN LEFT(REPLACE(dbo.Customers_Trade.PostCode, ' ', ''), 2) WHEN 6 THEN LEFT(REPLACE(dbo.Customers_Trade.PostCode, ' ', ''), 3)
ELSE LEFT(REPLACE(dbo.Customers_Trade.PostCode, ' ', ''), 4) END
WHERE (dbo.Customers_Trade.TradeCustomerID IN
(SELECT DISTINCT TradeCustomerID
FROM dbo.Orders_Trade
WHERE (DATEDIFF(d, order_date, GETDATE()) < 60))) AND (dbo.Customers_Trade.is_activated <> 'No') OR
(dbo.Customers_Trade.BillingAccountID <> '') AND (dbo.Customers_Trade.BillingAccountID IN
(SELECT DISTINCT TradeCustomerID
FROM dbo.Orders_Trade
WHERE (DATEDIFF(d, order_date, GETDATE()) < 60) AND (is_activated <> 'No')))
GROUP BY dbo.UkPostcodes.Postcode, dbo.UkPostcodes.Town, dbo.UkPostcodes.County, dbo.UkPostcodes.Area, dbo.UkPostcodes.Country,
dbo.Customers_Trade.Master_Account, dbo.UkPostcodes.Master_Account





does not show the nulls:



where as:



SELECT ISNULL(COUNT(CASE LEN(REPLACE(dbo.Customers_Trade.PostCode, ' ', '')) WHEN 5 THEN LEFT(REPLACE(dbo.Customers_Trade.PostCode, ' ', ''), 2)
WHEN 6 THEN LEFT(REPLACE(dbo.Customers_Trade.PostCode, ' ', ''), 3) ELSE LEFT(REPLACE(dbo.Customers_Trade.PostCode, ' ', ''), 4) END), 0)
AS PCCount, dbo.UkPostcodes.Postcode, dbo.UkPostcodes.Town, dbo.UkPostcodes.County, dbo.UkPostcodes.Area, dbo.UkPostcodes.Country,
dbo.UkPostcodes.Master_Account
FROM dbo.UkPostcodes LEFT OUTER JOIN
dbo.Customers_Trade ON dbo.UkPostcodes.Postcode = CASE LEN(REPLACE(dbo.Customers_Trade.PostCode, ' ', ''))
WHEN 5 THEN LEFT(REPLACE(dbo.Customers_Trade.PostCode, ' ', ''), 2) WHEN 6 THEN LEFT(REPLACE(dbo.Customers_Trade.PostCode, ' ', ''), 3)
ELSE LEFT(REPLACE(dbo.Customers_Trade.PostCode, ' ', ''), 4) END
GROUP BY dbo.UkPostcodes.Postcode, dbo.UkPostcodes.Town, dbo.UkPostcodes.County, dbo.UkPostcodes.Area, dbo.UkPostcodes.Country,
dbo.Customers_Trade.Master_Account, dbo.UkPostcodes.Master_Account

View 3 Replies View Related

AVG Not Showing The Right Results

Mar 29, 2008

Here's my code

View Table 3:

SELECT dbo.VIEW1Client.ID, dbo.VIEW1QA.Score, dbo.VIEW1Client.Score AS Score2, CASE WHEN dbo.VIEW1Client.Score = dbo.VIEW1QA.Score THEN 1 ELSE 0 END) AS Calibrate
FROM dbo.VIEW1QA CROSS JOIN
dbo.VIEW1Client
WHERE dbo.VIEW1Client.ID = '1'


View Table 4: (I created a view table using View Table 3 to get the average and it seems not providig the right average, instead I get 0:

SELECT ID, AVG(Calibrate) AS Perc
FROM dbo.VIEW3
GROUP BY ID

Any Ideas please?

View 4 Replies View Related

Old Version Keeps Showing

Oct 9, 2007



Hi,

I modified something on the package, saved it and click on build. When i ran the package, it hit an error. when i saw the object that has an error, it was the one i modified. my changes were not applied. i stopped the runtime. and double click again on that package, it reflected my changes. why during runtime it's showing the old version? what's the proper way of saving the package and building it? What's the different of Build and Rebuild?

cherriesh

View 4 Replies View Related

Why Not Showing Nulls?

Jan 18, 2007

Hi,

I have the following query:



SELECT COUNT(dbo.UkPostcodes.Postcode) AS PCCount, dbo.UkPostcodes.Postcode, dbo.UkPostcodes.Town, dbo.UkPostcodes.County,
dbo.UkPostcodes.Area, dbo.UkPostcodes.Country
FROM dbo.UkPostcodes LEFT OUTER JOIN
dbo.Customers_Trade ON dbo.UkPostcodes.Postcode = CASE LEN(REPLACE(dbo.Customers_Trade.PostCode, ' ', ''))
WHEN 5 THEN LEFT(REPLACE(dbo.Customers_Trade.PostCode, ' ', ''), 2) WHEN 6 THEN LEFT(REPLACE(dbo.Customers_Trade.PostCode, ' ', ''), 3)
ELSE LEFT(REPLACE(dbo.Customers_Trade.PostCode, ' ', ''), 4) END


GROUP BY dbo.UkPostcodes.Postcode, dbo.UkPostcodes.Town, dbo.UkPostcodes.County, dbo.UkPostcodes.Area, dbo.UkPostcodes.Country

The query should take all of the UK postcode regions (districts) and then match them up to the postcodes in a customer tbl...

What I'm trying to show is the count for postcode resutls, even the postcodes where there are no customers.



However it won't show any 0 counts - any ideas?

View 4 Replies View Related

Images Are Not Showing...

Jan 15, 2007

Hi,

I have two different reports and in these two reports one contains images which is working fine at development site as well as server site but when same report is called from another report using linking facility given in sql report images disappears on server site at development site it is working fine.

Can any one help me out.

Thanks in advance.

Wasim.

View 4 Replies View Related

Showing The Values Of Database

Oct 23, 2006

how can i show the values of my database in for example texbox.can u give me some simple code on how to connect to my SQldatabase server express? and how i can retrieve the file?thnx

View 2 Replies View Related

SQL Data Not Showing In Label

Mar 13, 2008

Here is my code.  Basically what I am doing is selecting from the database based on the current user.   The ReaderResults.Text label is not showing the info pulled from the database, and the ReaderError.Text label is not showing an error.  I also tried putting the ReaderResults.Text label inside the loop and that didnt work. Any suggestions?
'Database ConnectionDim con As New SqlConnection("Data Source = .SQLExpress;integrated security=true;attachdbfilename=|DataDirectory|ASPNETDB.mdf;user instance=true")Dim currentUserID
currentUserID = Context.User.Identity.Name.ToString()
Label1.Text = currentUserID
Dim selectSQL As String
selectSQL = "SELECT companyKey FROM Company WHERE UserID = ('" + currentUserID + "')"Dim cmd2 As New SqlCommand(selectSQL, con)
Dim reader As SqlDataReaderDim CompanyKey
Try
con.Open()
reader = cmd2.ExecuteReader()Do While reader.Read()
CompanyKey = reader("CompanyKey").ToString()
Loop
reader.Close()Catch err As Exception
ReaderError.Text = "Error selecting record."
ReaderError.Text &= err.Message
ReaderResults.Text = CompanyKey
Finally
con.Close()
End Try

View 1 Replies View Related

SQL Data Not Showing Up In My Label

Mar 13, 2008

The ReaderResults.Text is not returning a value.  I am not sure what is going on because the table and all columns are full, Label1.Text shows the current username of the user loggedon, and no error is showing up in ReaderError.Text.  Anyone have any ideas?
 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'Database ConnectionDim con As New SqlConnection("Data Source = .SQLExpress;integrated security=true;attachdbfilename=|DataDirectory|ASPNETDB.mdf;user instance=true")
'Job1 InfoDim currentUserID
currentUserID = Context.User.Identity.Name.ToString()
Label1.Text = currentUserID
Dim selectSQL1 As String
selectSQL1 = "SELECT companyKey FROM Company WHERE UserID = ('" + currentUserID + "')"Dim cmd1 As New SqlCommand(selectSQL1, con)
Dim reader As SqlDataReaderDim CompanyKey
'Job1 Select
Try
con.Open()
reader = cmd1.ExecuteReader()Do While reader.Read()
CompanyKey = reader("CompanyKey").ToString()
Loop
reader.Close()Catch err As Exception
ReaderError.Text = "Error selecting record."
ReaderError.Text &= err.Message
ReaderResults.Text = CompanyKey
Finally
con.Close()
End Try

View 3 Replies View Related

Why Arent The Breaks Showing Up?

Apr 4, 2008

Hi,
 We have an internal mail system, but when the user writes something into the textbox (textarea), he often uses enter to get the message over several lines, our problem is that when the message is saved to the database and retrieved, all the breaks are gone and its all on a single line. In the database its stored inside a field called "message nvarchar(MAX)". How can i preserve the linebreaks?
example, user writes:
Hello,Nice day,to go fishing.
output, after it has been saved and retrieved:
Hello, Nice day, to go fishing.
 
Patrick

View 1 Replies View Related

New View Not Showing Columns

Jul 9, 2001

Any idea why I cannot see (in Enterprise Manager) all the coulmns of a selected table? All I get is * all columns - not each one, meaning I cannot select individual columns in my new view. Could it be the version? I am running SQL 7.0 SP1

Thanks

View 2 Replies View Related

System Databases Not Showing

Oct 25, 2000

Hi,

I installed desktop edition of SQL Server7.0 but System databases are not displaying.only showing pubs and northwind only.any body help me.

Thank you

Novah

View 2 Replies View Related

Attached Db Successful In QA But Not Showing In EM

Nov 13, 2001

I used Query Analyser to De-tach a SQL 7 database and that worked fine. The database became 'invisible' in Enterprise Manager and the entry was removed from the sysdatabases in Master. The mdf and ldf file remain in the file system. However, when I ran the sp to Attach the database QA said successful but it does not show in Enterprise Manager or in sysdatabases in Master. I'm going to run through the procedure again and if problems I'll check the logs but has anyone else had difficulty with this. Also with attaching the db to a SQL2000 install I believe the logins on the SQL7 install are not brought over. In my case, the client is using trusted logins with their database application so their is probably not a lot to manually recreate on the SQL 2000 install but doees anyone have nay sample code/script that can give me an idea of what is required in the area of getting logins out of the Master of SQL7 and into SQL2000.

Great forum...

Have a great day,

ChrisE

View 3 Replies View Related

Query Showing Tablesize In MB

Jul 5, 2004

Hello all,

Is there an SQL query that can be run against a database that displays both the number of rows and the physical size of the tables in that database?

I'm basically after the information displayed in Taskpad view >> Table Info, but in an easy to manipulate and publish format.

Thanks for your time.

View 5 Replies View Related

SQL Server Not Showing The Drives

Mar 13, 2006

My sql server is not showing all of my drives in server. Please help me

View 5 Replies View Related

New Cluster Drive Not Showing Up

Oct 3, 2007

I've added a new drive to a clustered instance of sql 2000. Go to the node the instance is active on, the drive shows up. But...try to add a backup device that lives on the new drive (which was, after all, the whole point of the exercise) and SQL Server is blind to that drive. I have vague recollections of it recognizing the clustered drives when i set up all this a couple years ago. Could it be that it recognizes all the drives it'll ever recognize at the moment of installation? Anybody know?

thanks,
Garth
:beer:
:D :D :D
:beer:

View 6 Replies View Related

Query Not Showing All The Records?!

Feb 8, 2008

I want to have all the ethnicities from the Ethnicgroup table to be displayed in a particular area which is in where clause as
aggcourseid

The problem is that even when I have a left join on the EthnicGroup table it will not return all the ethnicities but will only return those who were existing in that particular aggcourseid.

i.e. If there is no African student in E2, it will not show up in the result whereas I want to display all the ethnicities and if there is no record for aggcourseid, it should show up as 0/NULL for that ethnicity.

I have tried all sorts of joins but the problem is whenever I put in the aggcourseid in where clause, it wont bring all the records


declare @mpid char (13)


set @mpid = '011142'

create table #temp_et (
[Year]int NOT NULL,
[Ethnicity] varchar(20),
[Starts]float(4),
[Success]float(4),
[Retention]float(4),
[Achievement]float(4)
)

--Year 05/06
insert into #temp_et
select
CAST(LEFT(pv.pg_expendyrid,2) AS int)[Year],
eg.pg_ethnicgroupname[Ethinicity],
sum([pvstart]) [Starts],

(case when sum(pvstart) = 0 THEN 0 Else convert(decimal(6,3),(sum(pvach)*1.00)/(sum(pvstart)*1.00)*100)end)[Success],
(case when sum(pvstart) = 0 THEN 0 Else convert(decimal(6,3),(sum(pvcomp)*1.00)/(sum(pvstart)*1.00)*100)end)[Retention],
(case when sum(pvstart) = 0 THEN 0 Else convert(decimal(6,3),(sum(pvach)*1.00)/(sum(pvcomp)*1.00)*100)end)[Achievement]
--into temp_et
from [FECAS].Proachieve.dbo.pv_midpoint pv
left join [FECAS].Proachieve.dbo.GN_AggCourseStructure gn on pv.pg_aggcourseid = gn.pg_aggcourseid
left join [FECAS].Proachieve.dbo.PG_ethnicGroup eg on pv.pg_ethnicgroupid = eg.pg_ethnicgroupid

where pv_midpointid = @mpid
and pg_expendyrid = '05/06'

and pv.pg_aggcourseid LIKE 'E2%'

group by
eg.pg_ethnicgroupname,
pv.pg_expendyrid
order by
eg.pg_ethnicgroupname

View 14 Replies View Related

Database Showing Suspect

Feb 9, 2004

I moved a database file (.mdf) from the Microsoft SQL Server data directory to another location, and moved it back into the original location. After which the database staus changed to suspect.

How do I make it live? Thanks

View 1 Replies View Related

Index Showing Fragmentation

May 11, 2015

We have nightly job running to reorg all in one of our prod database. But the index on one of the table fragmenting quickly by the morning showing 90% fragmentation.

View 9 Replies View Related

Showing Column As Rows....

Apr 26, 2008

i have 2 columns like
Col1====col2
username=======saif====mr@hotmai.com
email=======saif@hotmail.com
name======saifullah
I want to get these records from sql like
username email name
saif saif@hotmail.com saifullah
________________________________-
how can I achive this

Muhammad Saifullah

View 3 Replies View Related

Published SQL Server Not Showing In AD

Aug 26, 2005

I've been unable to determine why several published instances of my SQL Servers are not showing in AD. I searched under the Computer container in the domain in which the SQL Server was installed and did not see any SQL Server folder. I have used both the GUI and T-SQL to publish various instances, and it appeared to have worked since from the GUI the "Publish" option no longer worked and I recieved no error from Query Analyzer after issuing the command. The version is SQL Server 2000 8.0 running SP3a.

I also ran a VBScript to query the directory for published instances of SQL server, but did not get any results returned in the recordset. Any ideas?

Thanks in advance to anyone that can help.

nu_dba

View 1 Replies View Related

SQLServer05 Installation Not Showing

Dec 25, 2005

Hi @all,
I just installed SQLServer 2005 Developer edition on a WinXPPro Virtual PC. Installation went fine, however i see no items in my Start menu. There's only SQL Server 2005 Configuration tool. Where's all other stuff gone?

Everything should be on my computer, but I can't get to it. I.e. if i go check the installation (Add&remove progs/Server 2005 and click Change) there's everything there, Analysis server, Business intelligence, etc. But no items in my Start menu.

Also, if i re-enter either of the 2 installtion CDs, there's only
two things in the INSTALL part: Server components and Run SQL Native Client Install... Where's "install server" link?

Please bear with me. Newbies are hard
Thank you very much for any advice.
Jan

View 1 Replies View Related

Database Keeps Showing As Suspect...

Feb 20, 2006

I am currrently working on a ASP.Net 2.0 project using Sql Server 2000 with SP4. Whenever I run any query the connected database keeps showing as 'Suspect' and I can't access it from Enterprise Manager/ Query Analyzer. But my ASP.NET pages work fine. I can access my records as well as update them through my ASP pages.
Please help me out....
Here is the code which I use in my ASP.Net page

******************************************************
Dim selectsql As String
selectsql = "select au_fname FROM Authors"
Dim con As New SqlConnection("Data Source=.SQLEXPRESS;AttachDbFilename=""C:Program FilesMicrosoft SQL ServerMSSQLDatapubs.mdf"";Integrated Security=True;Connect Timeout=30;User Instance=True")
Dim cmd As New SqlCommand(selectsql, con)
Dim ass As SqlDataReader

Try
con.Open()
ass = cmd.ExecuteReader
Do While ass.Read
Dim newitem As New ListItem()
newitem.Text = ass("au_fname")
'newitem.Value = ass("zip")
ddl.Items.Add(newitem)
Loop

ass.Close()

Catch ex As Exception
lblmsg.Text = "error has occured "
lblmsg.Text &= ex.Message

Finally
If (Not con Is Nothing) Then
con.Close()
End If
End Try
*********************************************

View 6 Replies View Related

Table Object Is Not Showing.

Oct 2, 2006

declare @MinVoter varchar(20)
declare @field varchar(20)
declare @sql1 varchar(100)
declare @tableName varchar(20)
set @tableName = '00221'

print @tableName

print '======================================='



select @field = ad_str1
from @tableName
where id_voter = @MinVoter

Server: Msg 137, Level 15, State 2, Line 15
Must declare the variable '@tableName'.

can someone fix this syntax.

View 20 Replies View Related

Showing Totals As Well As Details

May 14, 2007

This is showing the details I am looking for. Is there a way to show the totals for the clients for 418 and totals for 417?

SELECT NAME.Nickname1, NAME_1.Nickname1 AS Expr1, SLPTRANS.ActyExpID, SLPTRANS.TimeSpent / 3600 AS Hours
FROM CUSTOMC INNER JOIN
NAME AS NAME_1 ON CUSTOMC.RecordIDQ = NAME_1.RecordID INNER JOIN
NAME ON CUSTOMC.ControllerQ = NAME.RecordID INNER JOIN
SLPTRANS ON CUSTOMC.RecordIDQ = SLPTRANS.ClientID
WHERE (NAME.NameType = 0) AND (CUSTOMC.Service_Cont = 'YES') AND (SLPTRANS.ActyExpID = '417') OR
(SLPTRANS.ActyExpID = '418') AND (SLPTRANS.StartDate BETWEEN @IncludeStartDate AND @IncludeEndDate)

View 5 Replies View Related

Showing Friendly Values In The GUI

Jul 20, 2005

I am new to SQL server and I am looking for the best practiceregarding the following:The GUI for the database I am creating has a number of questions like:A. Where are you currently living?1) In my own home2) In the home of a family member3) In a shelter4) On the streetHowever, for speed of data entry, the GUI (it's a web front-end,ASP/VBScript) accepts the number only. Futhermore the database onlystores the number entered.So for example for the above question, when the user is doing the dataentry, they would just enter a 1, 2, 3, or 4.However, when viewing the data, the end user wants to see the textthat corresponds to the number. So for example, if the user entered"3" for the above question, when they are viewing the data in the GUI(not to make edits, just viewing), they want to see "(3) In ashelter".My question is how best to display these friendly values?Should I do all the conversions in a stored procedure? If so, whatwould be the best way to do that? I tried something like this:SELECT Current_living =CASE Current_livingWHEN 1 THEN '(1) In my own home with my partner'WHEN 2 THEN '(2) In the home of a family member'ELSE NULLENDFROM tbl_DemographicInfo WHERE ClientID = @ClientIDbut I can't figure out how to do this for multiple fields.ALSO, I'm not sure if burying this stuff in a stored proc is the wayto go, because if the client wants a slight change to the friendlyname I have to get into the SP and change it. Seems like there mustbe a better way.I can also do this in the ASP code, but that also doesn't seem likethe best practice.I can have a lookup table, but again, where do I do the conversion?In an SP? With a view?Again, I'm looking for the best practice here. I know some ways Icould do it (like in the ASP), but I want to do it efficiently andcorrectly.Any help/comments are greatly appreciated.thanks in advance,Jon LaRosajlarosa at alumni dot brown dot edu

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved