SQL Server :: How To Check Sum Two Fields And Take 10% Of The Sum
Nov 8, 2010
I'm using sql server 2008...In my database i have a table named 'Employee' and this table contains two fields namely 'count' and 'number'.What i have to need is that ,sql query to find out ten percentage of the sum of count and number...ie; 10% sum(count+number)..
How do I check if my value is empty AND Isnull? I need to check for both, using ISNULL is not enough because the data can change just so that it is empty.
I want to generate 30,000 cards and each card must be duplicate check with database. In my card, there are 2 things. Serial No and CardID. If any card already exists then I generate another card id but with the same serial no.
So how faster way I can generate 30,000 card with duplicate check? Which one I have made application, it takes about 25 minutes to insert.
to loop through each field in a record to test for a value and then set a flag at the end of each record if an instance of this value occurs in any fields?I have a table where some fields values are have a *c* at the beginning of the text eg "*c* value" . What I would like to do is run a select query off the table and at the end of each record have a field called "Change Flag" and a value of "Changed" or "No Change" depending if a *c* has been encountered.
There are a number of tables to run this against all with differening numbers of fields/
I have a sql data souce that returns several columns of data, and they are displayed in a DetailsView on a pretty simple vb.net page. I'm stuggling with one field though for the details view.
It's a template field, and if ClientType=1 (this value is determined else where on the page), then the label in the template field should have Text='<%# Bind("ClientName") %>', but if the ClientType = 0, then the label in the template field should have Text='<%# Bind("ClientTemporaryName") %>'
How do I tell the details view to set the text for ClientName to one or the other?
I have a relatively complex dataset (numerous tables, some with multiple records) generated from reading in an XML file. I need to connect said dataset fields to an ASP form. At the moment I'm assigning them manually, like so in the pageload:
I did some looking into binding the textboxes (and dropdownlists, and checkboxes, and and and...) directly, but it seemed to be too many formats to use.
So this works fine, but as the number of fields increases, those load and unload lists are going to get unwieldy.
I am working on Crystal Reports 8.5 and SQL Server 2000 as backend. I have a stored procedure which has been added to the Crystal Report. So that fields are visible in the Fields object section from where i can drag and drop the fields on the report and display it. But now as they want more fields i have written two select statements for displaying required fields. But these newly added fields are not visible in the Fields object section in the Crystal Reports. I have done verify database, removed and again attached the SP but the problem is not solved.
I got an excel spreadsheet (will have tons eventually) that have "Start Date" and "End Date" columns, with a format of "dd/mm/yyyy".For time being, I just want to import these to a temporary table in my database, and use the SQL Server Import/Export wizards.
Now this wizard import the the above fields as nvarchar, instead of date or datetime (not sure which would be better?).I tried to convert the columns to datetime after importing, but this is not allowed (Saving changes is not permitted. The changes you made require that the following tables to be dropped and re-created, ......).
So I deleted the temporary table, and ran the wizard again, this time trying to edit the mappings and specify the two fields to be date times, but this also fails.I also fiddled around with convert and cast, but always end up getting "Conversion failed when converting date and/or time from character string." errors.
I looked myself skew, and are pretty sure all the fields in the excel sheet do have values, and are in the "dd/mm/yyyy" format.(I've been absent from SQL for a long long time!)
I have taken over development of a asp.net 3.5, c#, MSSQL website, which I did not create.
There is a form on the website which adds all kinds of information into my SQL database. I have added two fields to the database, two corresponding extra form questions and added to the c# code behind so that these new fields are treated in exactly the same way as the existing ones.
I am therefore completely stumped as to why those two fields aren't populated in the database when I submit the form.
No page errors or anything, it's just the fields remain empty when the other pre-existing ones are populated just fine.
Is there something obvious I'm missing - for example is there a setting in the database I'm not enabling to allow the two new fields to be written to by my c# file?
I was not a programmer before this, I'm just picking it all up as I go along.
I was wondering if people out there test the length of their text values before inserting them into an SQL INSERT or UPDATE command? I got lazy and stopped doing it lately but I do restrict the length of some of my character fields so that I have a NCHAR(50) field but don't test the length of the string when inserting or updating and just rely on the server to fire back any problems.Am I being 'efficient' or 'lazy' or even 'dangerous'?I appreciate the opinion of you as just about anyone has more experience with SQL Server than I do.
My users will enter a city/station where an incident occured, and the date. The trigger below does work, but it will occasionally put spaces between the citystation and the date. I think this happens when the citystaion name is not very long, but not sure.
(ex: city____08242010)
How can I make sure that if the incidentid is going to have spaces, that sql deletes those spaces? I need the id to be space free.
ALTER AS TRIGGER [dbo].[tr_AddID1] ON [dbo].[tblIncidents] INSTEAD OF INSERT..........
I'm currently developing a software application for my client. Part of the project is to keep track of his stock's shipping status. The client must insert the stock's pick-up date, expected time of departure (ETD) and expected time of arrival (ETA). The stocks will be called out using Grid View and the status, being one of the keys of the database, will be shown. Before the current date reaches pick-up date, the status must show "in warehouse", and after the current date reaches pick-up date and is before ETD, status must show that its "on the way to the port", and after ETD and before ETA, "in freight", and finally after ETA, "arrived". What datatype should I use for the database and where should I program it so that it changes automatically accordingly ?
I'm trying to dynamically populate a drop down box with fields from a SQL Server Database, but I'm having some issues. I am able to get it to work well with only one field, but I need to get display two fields in the ddl. I've seen that you can do it in the command statement, but I have two different data types and I think that causes it to throw an error: Conversion failed when converting the varchar value 'This is a Title' to data type int.
I have to generate a unique token no which will have three fields an incrementer,comp_code anddate.I have problem in generating a unique incrementer. Incrementer should be incremented by 1 like 0001,0002 etc, should be unique and based on no of record inserted.
Q1: I have an Asp.net page , one textarea there the user can enter all his details like name age gender; how do get the get name, age, gender in seperate fields(text fields). how can i split?
Q:
dawn barric 25 male answer: text1: dawn barric text2: 25 text3: male
I have following query (against db2/400 data base using linked server).
SET @SQLSTRING = 'SELECT * FROM OPENQUERY( AS400SRV_MSDASQL, ''SELECT glmcu as business_unit, SUM(CASE WHEN ((date(digits(dec(gldgj + 1900000,7,0)))) >= ''''' + CONVERT(varchar(11),@DateFrom1,121) + ''''' and (date(digits(dec(gldgj + 1900000,7,0)))) <= ''''' + CONVERT(varchar(11),@DateTo1,121) + ''''') THEN glu / 100 ELSE 0 END) AS quantity1 from VGIPRDDTA.F0911 where glmcu = '''' 1000131'''' and (glsub = ''''00200 '''' or glsub = ''''00315 '''') and gllt = ''''AA'''' and gldct = ''''JE'''' and globj = '''' '''' and glum = ''''CY'''' group by glmcu order by glmcu'')'
The query works fine but I need to modify my selection for fields 'glmcu' (BusinessUnit) and 'glsub' (CostCenter). Instead of hard coding the selection I will need to retrieve the selection (and grouping) from another table.
I have created a class which inherits the HyperLinkField. I need to find the data values of the fields specified in the DataNavigateUrlFields property. I have not been able to figure out how to do this.