How do you give a column a description in SQL. I have a project where the table will created with SQL using the legacy database systems 6 byte field names. the old system (DB2/400) has field(column) descriptions that I would like to move over but how?
I know I could create a view over the table and use the more descriptive field names.. but I would like for them to be in the same table..
like emhrdt - column name (for reference to the legacy systems source code) Employee Hire Date - column descriptions (so programmers for the new system know what it means).
I wrote this quick SQL for project documentation purposes.
/* Provides Table Name, Column Name, Extended Description */ select a.name as tbl_name, b.name as column_name, d.name as data_type, d.length as length, d.xprec as prec, d.scale as scale, b.usertype, b.scale, c.value from sysobjects as a inner join syscolumns as b on a.id = b.id inner join sysproperties as c on b.colid = c.smallid and a.id = c.id inner join systypes as d on b.xtype = d.xtype
I want to select multiple records based on descriptions that are the same. Descriptions is my column and I really want to find duplicate records based on the description column.
Is there an easy way to add descriptions or comments to database objects? So, for instance, I might have a table that a number of analysts are using, and I'd like an easy way to save comments or descriptive data about each of the columns in the table. That way, all consumers of the DB can easily look up the meaning of each column, table, stored procedure, etc. I could maintain all of this information in a system separate from my RDBMS, but I'm wondering if there are existing ways to do this already built into SQL Server. I've seen something similar to this built into Oracle systems.
Hi Guys, I just need a script to get all Job Id and Job Descriptions from Sql Server Agent/Jobs and then save it into a text file. I'm not sure how to accomplish this using Sql Server Management Objects(SMO). Any sample scripts and/or stored procedures, etc. would be appreciated. Thanks for your help. -W2528
I am JOINing a Table with a View, and the View can have multiple rows relating to the join condition(i.e. My view as 4 columns, and can look like the following: A B C D A E F G B H I J I want this to look like - A B C D E F G B H I J I want one row, but not one column, I need to maintain each value in its own column, withinin a single row. Doesn't matter to me if that transition happens in my View or as the outcome of my Join. I've been looking at the PIVOT command, but that appears to only work with an aggrgrate function. I don't want to calculate/aggreagte anything, just combine my multiple rows in one. This is my VIEW stmt - SELECT [PKG ID] AS PKG_ID, [APPR GRP NAME], [USRID OF APPR], [APPR STATUS]FROM dbo.pkgapproversWHERE ([APPR STATUS] = 'approved') AND ([APPR GRP TYPE] = 'E') This is my Join stmt - set @sql = N'SELECT DISTINCT [PKG ID] AS PKG_ID, [ELM ACT] AS Action, [END EXEC DATE] AS "Exec Date", [COMMENT] AS Comment, [USRID OF APPR] FROM [PkgAction] FULL JOIN vw_PkgApprovals ON PkgAction.[PKG ID] = vw_PkgApprovals.[PKG_ID] WHERE 1=1'
I have a requirement to set Description values for our cube dimensions and attributes.
I've done this for regular dimensions but I cant seem to find a way for role playing dimensions. I can set the base dimension descriptions but not the 'clones'. Is this possible?
Would like to know if it is possiblefor any of you to suggest how to conditionally diaplay a Column based on the values of the other columns. Here's my query SELECT [ProductionDay] ,DATEPART(wk,StartTime) AS WeekCount ,(AVG([RNTDuration])) AS AvgRNT ,MIN([RNTDuration]) As LeastRNT ,MAX([RNTDuration]) As WorstRNT ,dbo.fn_MinimumRNT_sp([ProgramNo],[Machine],[ProductionDay]) AS BestRNT ,dbo.fn_MinimumRNT(SubAssemblyNo,[Machine]) AS BestRNT_txt ,SUM([LoadingDuration]) AS LoadingTime ,[ProgramNo] AS ProgramNo ,COUNT(RNTID) AS PartsCount ,[SubAssemblyNo] ,[Sheetsize] FROM [RPMS].[dbo].[List_MachineShopRNT] where Machine = @iMachine and dateadd(month, datediff(month, 0, [StartTime]),0) = @dtMonthStartDate Group by DATEPART(wk,StartTime), [ProductionDay],[Machine],[ProgramNo],[SubAssemblyNo],[Sheetsize]
Here I would like to Run the function dbo.fn_MinimumRNT_sp or dbo.fn_MinimumRNT if the ProgramNo is 100
======================================================== I have one table store below information, and other one table is store staff name and phone number. how to display of table c data by new column and using the key staff_code1=staff_id or staff_code2= staff_id or staff_code3=staff_id ? ---------------------------------------------------------
Table A staff_code1,staff_code2,staff_code3
Table B staff name staff_id staff_phone -----------------------------------------------
Table C display in new column . staff name-1 code1 staff name-2 code2 , staff name-3 code3 peter id-01 susuan id-03 david id-05
Hi,I have a DataGrid whose DataSource is an SQLDataSource. This SQLDataSource references a SQL Server table with an Identity column, named Id. The SQLDataSource has generated an Update statement for me, but this only works if the Id column is selected for display in the DataGrid, and has Visible = True. If not, then the @original_Id parameter to the generated Update statement has a value of Nothing, and the Update has no effect. So is there a way to enable the Update statement to work, without the user having to see the Id column in the DataGrid? Many thanks,Keith.
My first ASP.NET/SQL project. I'm creating an Asset Management DB. I wish to view the Asset number, the full name of the user it's assigned to and the Make and Model of each record in the DB. However assets are split into different categories e.g. monitors, PCs, Preinters etc. and they are all in different tables. The SQL below displays the asset number, Name of person assigned and the model of the asset. SELECT Hardware.AssetNo, [User].FullName, MonitorModel.Model, PCModel.Model AS Expr1, PrinterModel.Model AS Expr2 FROM Hardware INNER JOIN [User] ON Hardware.UserID = [User].UserID INNER JOIN Model ON Hardware.ModelID = Model.ModelID LEFT OUTER JOIN MonitorModel ON Model.MonitorModelID = MonitorModel.MonitorModelID LEFT OUTER JOIN PCModel ON Model.PCModelID = PCModel.PCModelID LEFT OUTER JOIN PrinterModel ON Model.PrinterModelID = PrinterModel.PrinterModelID This outputs:- Asset number FullName Model Expr1 Expr2 00000 User Name Model NULL NULL 00001 User Name NULL Model NULL 00002 User Name NULL NULL Model However what i hope to acheive is output Model, Expr1, Expr2 into one column like so:- Asset number FullName Model 00000 User Name Model Can i do this in the SQL or do i have to do it in my ASP.NET (VB) Page? Using VSWD 2005 Ex Edition and SQL Server 2005 Ex Edition Thank you for your replies
I am trying to display component usage in January for the past year, if I want to display the year in different column, what should I do? eg. component_id component_description qty_used_on_2005_Jan qty_used_on_2006_Jan C58B0BDD tape drive 2 3 Currently I am using this sql: select cast(year(date_complete) as varchar(10)) + ' Jan' as Year, component_id, component_description,sum(component_qty) as total_qty_used from view_jobComponent where month(date_complete) = 1group by component_id, component_description, cast(year(date_complete) as varchar(10)) + ' Jan'order by component_id, component_description which I will get something like this: Year component_id component_description total_qty_used 2005 Jan C58B0BDD tape drive 22006 Jan C58B0BDD tape drive 3
I have a column in the following select startement called displayvalue. Displayvalue is a varchar column. Primary everything entered into this column is numeric, but there are times when NR is entered. In the select query if it sees NR, I would like to have NR changed in the resultset to NULL or blank. NR doesn't come up all of the time, but I have not idea how to do this in the select statment.
Here goes..
SELECT SAMPLE.SAMPLEID, SAMPLE.U_WORKORDERNUMBER, SAMPLE.U_SAMPLEDATETIME, SDI.PARAMID, SDI.DISPLAYVALUE FROM SAMPLE SAMPLE, SDIDATAITEM SDI WHERE ( (SAMPLE.SAMPLEID = SDI.KEYID1) AND (SAMPLE.U_WORKORDERNUMBER = '0060') AND (SAMPLE.U_SAMPLEDATETIME > '31-DEC-2003') AND (SDI.PARAMID = 'BOD') ) ORDER BY SAMPLE.SAMPLEID ASC, SDI.PARAMID ASC
I have created a trigger in SQLExpress which looking for any insertion to a specific table in a database:
Create Trigger Tg_Insert on [tablename] FOR Insert AS Select * FROM Inserted --------------------------------------------------------- Assume there is nothing wrong with this trigger as I have already checked the output with Query tool. My question is how can I display the newly inserted data to the client? In my case, Console application. I want to do something like Console.WriteLine("data from inserted table here"); How can I achieve this? FYI, I'm using VS2005 with sqlexpress 2005. Thanks in advance.
The tables are what the tables are. Here is what I am trying to accomplish:
ID CODES DESCRIPTIONS -- ----------------- -------------------------------------- 01 Code1,etc Description1,Description2,Description3
I've found two different queries which return each code and associated description by ID in separate rows. Perhaps the next step is to aggregate from this?
Hello I know how I can display a list of names in alphebetical order on my website: Select L as [Last Name] From Name_CatEWhere Education = 'yes'Order ByLName ASC However, to make things a little more orginised I would like to view my database table column in alphabetical order also, but ithie code does not work within my database. What do I need to change in the following code, to view my database table column in a-z order? SELECT LName FROM Name_CatEORDER BY LName ASC Thanks Lynn
Hi,please help me, i have a data driven site,i need to display a table who look like this Name Total Used RemainingA 10 5 5B 20 13 7C 12 12 if you would look on the field of total, used and remaining, they look like an excel formula which is total - used = remaining or vise versa.but the problem in this table is the database, it look like thisname On/OffA 1A 1A 0and soon....... B 1B 0B 1and soon.... until C so how do i count the total, is the number of A's or B's or C's in the whole database then Group By the 'name' fieldthen how do i count the used is the number of ON in the On/Off field while remaining is counting the Off,so my question is i have RUN this using 3 different gridview each has its own datasource, that look like this for the used select name, count(on/off) from myTable where on/off = 1 group by name for the remaining select name, count(on/off) from myTable where on/off = 0 group by name and for the total, just used the same Select but without the where clause,i get this problem when the field "used" (please refer from the 1st table) it has a blank value, which is because my data base show that in deed name "C" has not been used, but eve though it should show '0' instead of a blank, so how can i do that???please help me, thanks
I have created a table with short name as the file name but have entered the description in the column box (when creating a new table - see attached). I would like to show this description information in query analyser. Can this be done? I used sp_help <table name> but it doesn't show the description.
I am having two table i.e( tbl_oldEmployee , tbl_NewEmployee ),which is having Column name Employee Name and City same in both table but inside column data is different in different table.but i want to view the Employee name and City from tbl_NewEmployee to tbl_oldEmployee which is having EmployeeId common with tbl_oldEmployee extra record also required (i.e tbl_NewEmployee having 6 record and tbl_oldEmployee having 10 record,so i need to display data from tbl_oldEmployee but first 6 record which id match with tbl_NewEmployee id should be replaced and extra data from tbl_oldEmployee also display).