Creating A Yes/No Field In SQL Server
Jul 3, 2006
hi,
i need to create a yes/no field in a SQL Server database table. I know that i could previously do this in Microsoft Access and i believe that SQL Server now uses Boolean(0 or 1) for this. Does anyone have any ideas as to how to convert these 0 or 1 to yes or no with a default of yes?
I am taking the output from this table and displaying in Excel as yes or no not 0 or 1.
Thanks
View 7 Replies
ADVERTISEMENT
Mar 9, 2007
Hi all. Hiw can i create a field in a query?
/*
table - HrSetTaxTable
taxpaytype taxcode salrate1 salrate2 basetax perover
A A1 1000 200 100 5
B A2 2000 300 90 5
B A3 3000 400 80 5
A A4 4000 500 70 5
C A5 5000 600 60 5
B A6 6000 700 50 5
C A7 7000 800 40 5
*/
How could I add another field(varchar type) named TTP.
If taxpaytype is equal to A, TTP = Daily
If taxpaytype is equal to B, TTP = Weekly
If taxpaytype is equal to C, TTP = Monthly
so my expected result.
/*
taxpaytype taxcode salrate1 salrate2 basetax perover TTP
A A1 1000 200 100 5 Daily
B A2 2000 300 90 5 Weekly
B A3 3000 400 80 5 Weekly
A A4 4000 500 70 5 Daily
C A5 5000 600 60 5 Monthly
B A6 6000 700 50 5 Weekly
C A7 7000 800 40 5 Monthly
*/
Thanks.
-Ron-
View 1 Replies
View Related
Nov 30, 2000
I have built a table called Visit_Fact, which is detailed medical data. Within this table I have to create several index fields.
Well one of the fields ([Diag Code]) that should be included will have null values.
Well in Access I was able to build my new field called IndKey which has the following SQL statement:
IndKey: [PracticeCode]&[Physician Code]&[Chart #]&[Visit #]&[InsCoNum]&[CPT]&[Modifier]&[Units]&[Diag Code]
1. Example data with Diag Code = null
ABCD1234ABCDEF1234567MEDI19921301
2. Example data with Diag Code <> null
ABCD1234ABCDEF1234567MEDI19921301708.1
This runs fine in Access and if the Diag Code is null, Access does not care, it still puts all the other information together. Such as the examples above.
Well I tried doing this in a Stored Procedure and when I ran across a record that had a null value for the [Diag Code] it made the IndKey field Null for that record. If it was not null then it looked like Example 2.
What is the proper way of creating my unique field in SQL Server?
View 2 Replies
View Related
Feb 21, 2007
well i guess we were all a newb once so here goes
something is wrong with the below it just doesnt like the date part
create table PLN_Workgroup_Resource
(
Dte date(ddmmyyyy),
Workgroup varchar(20),
AM_Hrs integer(3),
PM_Hrs integer(3),
EVE_Hrs integer(3)
)
;
View 4 Replies
View Related
Nov 7, 2007
I am creating a new filed in SQL Server 2005, and I want the field to have the default of '0'
I select the data type as numeric and save my changes, I then visit our front end database to see if the default value is just '0' but it appears as '0.00'
SO i thought about changing the default value to int (im thinking this means integer?) and changing it to '3' but it still displays the decimal point and two 0's
Am I doing something wrong here? I just want it to display '0'
Thanks
View 12 Replies
View Related
Sep 1, 2006
In my Derived Column Transformation Editor I have something like this:
DAY([Schedule]) + MONTH([Schedule]) + YEAR([Schedule])
where [Schedule] is a database timestamp field from a OLEDB Datasource.
I want to produce a string something like: "DD/MM/YYYY"
using the expression above, I get something really wierd like "1905-07-21 00:00:00"
Help much appreciated!
View 10 Replies
View Related
Apr 15, 2008
Hi all,
My code below creates a trigger that fires whenever a change occurs to a 'myTable' row, but this is not what I want. I only want to log changes made to a single field called 'Charges', when that field is changed I want to log it, can anyone tell me how to modify my code to do this, thanks
Create Trigger dbo.myTrigger
ON dbo.[myTable]
FOR UPDATE
AS
Declare @now DATETIME
Set @now = getdate()
BEGIN TRY
Insert INTO dbo.myAuditTable
(RowImage,Charges,ChangeDate,ChangeUser)
SELECT 'BEFORE',Charges,@now, suser_sname()
FROM DELETED
Insert INTO dbo.myAuditTable
(RowImage,Charges,ChangeDate,ChangeUser)
SELECT 'AFTER',Charges,@now, suser_sname()
FROM INSERTED
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION
END CATCH
View 3 Replies
View Related
May 5, 2015
Looking to write an query that will update a field for multiple items, like 1,500.
something like:
UPDATE INMAST
SET FPRICE = 111.11
WHERE
INMAST.FPARTNO = 'xxx'
only issue I'm having is a need to do a JOIN because there's one more condition that must be met from another table, i've tried this:
SET FPRICE = 111.11
JOIN INVCUR
ON
(inmast.fpartno + inmast.frev)= (invcur.fcpartno + invcur.fcpartrev)
WHERE
INMAST.FPARTNO = 'NRE'
AND
invcur.flanycur = 'TRUE'
but that is giving me an error around the JOIN
View 11 Replies
View Related
Feb 27, 2008
I'm trying to create a calculated field using SQL Server Express, from within the Visual Web Developer Express 2008 IED. The field I am trying to create is called "total" and is supposed to be the sum of the subtotal, salestax, and shipping fields.
Is this possible from within VWD 2008? How?
Thank you!!!
View 3 Replies
View Related
Jul 11, 2005
I'm using DTS to import data from an Access memo field into a SQL Server ntext field. DTS is only importing the first 255 characters of the memo field and truncating the rest.I'd appreciate any insights into what may be causing this problem, and what I can do about it.Thanks in advance for any help!
View 4 Replies
View Related
Oct 17, 2007
I am trying to drag data from Informix to Sql Server. When I kick off the package
using an OLE DB Source and a SQL Server Destination, I get DT_DBDATE to DT_DBTIMESTAMP
errors on two fields from Informix which are date data ....no timestamp part
I tried a couple of things:
Created a view of the Informix table where I cast the date fields as datetime year to fraction(5), which failed.
Altered the view to convert the date fields to char(10) with the hopes that SQL Server would implicitly cast them
as datetime but it failed.
What options do I have that will work?
View 1 Replies
View Related
Jul 23, 2005
Hi ,Have a Visual C++ app that use odbc to access sql server database.Doing a select to get value of binary field and bind a char to thatfield as follows , field in database in binary(16)char lpResourceID[32+1];rc = SQLBindCol(hstmt, 1, SQL_C_CHAR,&lpResourceID,RESOURCE_ID_LEN_PLUS_NULL , &nLen1);and this works fine , however trying to move codebase to UNICODE antested the followingWCHAR lpResourceID[32+1];rc = SQLBindCol(hstmt, 1, SQL_W_CHAR,&lpResourceID,RESOURCE_ID_LEN_PLUS_NULL , &nLen1);but only returns 1/2 the data .Any ideas , thoughts this would work fine , nit sure why loosing dataAll ideas welcome.JOhn
View 2 Replies
View Related
Nov 19, 2006
Hi,
I'm importing an Access database to SQL Server 2000.
The issue I ran into is pretty frustrating... All Memo fields that get copied over (as Text fields) appear to be fine and visible in SQL Server Enterprise Manager... except when I display them on the web via ASP - everything is blank (no content at all).
I didn't have that problem with Access, so I ruled out the possibility that there's something wrong with the original data.
Is this some sort of an encoding problem that arose during database import?
I would appreciate any pointers.
View 14 Replies
View Related
May 28, 2015
We have a stock code table with a description field and a brand field - when the data was entered, some of the records were entered with the brand field in the description field.
ie.
Code Description Brand
ABC1 BLANK DVD SONY
ABC2 SONY BLANK DVD SONY
what I need to do is identify where the Brand is in the Description field ...
I have tried ;
select * from Table
where Description Like Brand
not very successful.
View 3 Replies
View Related
Aug 20, 2006
Hi all,
i've a reasonable amount of experience with MS Access and less
experience with SQL Server. I've just written an .NET application that
uses an SQL Server database. I need to collate lots of data from around
the company in the simplest way, that can then be loaded into the SQL
Server database.
I decided to collect the info in Excel because that's what most people
know best and is the quickest to use. The idea being i could just copy
and paste the records directly into the SQL Server database table (in
the same format) using the SQL Server Management Studio, for
example.
Trouble is, i have a problem with line feed characters. If an Excel
cell contains a chunk of text with line breaks (Chr(10) or Chr(13))
then the copy'n'paste doesn't work - only the text up to the first line
break is pasted into the SQL Server database cell. The rest is not
pasted for some reason.
I've tried with MS Access too, copying and pasting the contents of a
memo field into SQL Server database, but with exactly the same problem.
I've tried with 'text' or 'varchar' SQL Server database field formats.
Since i've no experience of using different types of databases
interacting together, can someone suggest the simplest way of
transferring the data without getting this problem with the line feeds?
I don't want to spend hours writing scripts/programs when it's just
this linefeed problem that is preventing the whole lot just being
cut'n'pasted in 5 seconds!
cheers
Dominic
View 6 Replies
View Related
Sep 20, 2007
I am attempting to create a stored procedure that will launch at report runtime to summarize data in a table into a table that will reflect period data using an array type field. I know how to execute one line but I am not sure how to run the script so that it not only summarizes the data below but also creates and drops the table.
Any help would be greatly appreciated.
Current Table
Project | Task | Category | Fiscal Year | Fiscal Month | Total Hours
---------------------------------------------------------------------------------------------------------
Proj 1 | Task 1 | Cat 1 | 2007 | 01 | 40
Proj 1 | Task 1 | Cat 2 | 2007 | 02 | 20
Proj 1 | Task 1 | Cat 3 | 2007 | 03 | 35
Proj 1 | Task 1 | Cat 1 | 2008 | 01 | 40
Proj 1 | Task 1 | Cat 2 | 2008 | 02 | 40
Proj 1 | Task 1 | Cat 3 | 2008 | 03 | 40
Proposed Table
Project | Task | Category | Fiscal Month 01 | Fiscal Month 02 | Fiscal Month 03 | Fiscal Year
---------------------------------------------------------------------------------------------------------------------------------------------------
Proj 1 | Task 1 | Cat 1 | 40 | 0 | 0 | 2007
Proj 1 | Task 1 | Cat 2 | 0 | 20 | 0 | 2007Proj 1 | Task 1 | Cat 3 | 0 | 0 | 35 | 2007
Proj 1 | Task 1 | Cat 1 | 40 | 0 | 0 | 2008
Proj 1 | Task 1 | Cat 2 | 0 | 40 | 0 | 2008
Proj 1 | Task 1 | Cat 3 | 0 | 0 | 40 | 2008
Thanks,
Mike Misera
View 6 Replies
View Related
Aug 25, 2015
I'm new to SQL and I'm trying to write a statement to satisfy the following:
If [Field1] contains text from [Field2] then return [Field3] as [Field4].
I had two tables where there were no matching keys. I did a cross apply and am now trying to parse out the description to build the key.
View 8 Replies
View Related
May 4, 2006
Good morning...
I begin with SQL, I would like to add a field that will be date like 21/01/2000.
Actually i find just "datetime" format but give me the format 21/01/2000 01:01:20.
How to do for having date and time in two different field.
Sorry for my english....
Cordially
A newbie
View 3 Replies
View Related
Jul 11, 2007
Hi,My webhost (1and1) is running SQL Server 2000 and their web tool supports the import of .bak files. However, when I try to import my .bak files created in SQL Server Management Studio Express I get the following error:"The backed-up database has on-disk structure version 611. The server
supports version 539 and cannot restore or upgrade this database.
RESTORE FILELIST is terminating abnormally."I have Googled this error and learnt that 2005 .bak files are not compatible with 2000 .bak files. I'm just wondering if there are any work arounds to this or alternative tools that I can create 2000 compatible .bak files from from 2000/2005 .mdf files.Thanks in advance.
View 4 Replies
View Related
Oct 13, 2006
Превед!Prompt me please some asp.net 1.1 pivote table component that can use both SQL Server database (SQL queries) and Analyse Services database (MDX queries).Thanks.
View 3 Replies
View Related
Jul 1, 2006
I have two problems on creating new SQL server database in Visual Web Developer 2005 Express using SQL server 2005 Express.
The 1st problem: (It is resolved)
After installed SQL Server 2005 express and Visual Web Developer 2005 Express. When I tried to create a SQL server database in VWD the following error occurred:
"connection to SQL Server files (*.mdf) require SQL server express 2005 to function properly. please verify the installation of the component or download from the URL: go.microsoft.com/fwlink/?linkId=49251"
I was stuck with this problem for few days. I did several times of install/reinstall of VWPExpress and SQL server Express, made very sure following proper de-installation sequence as specified in the release readme. But it did not resolve the problem.
Latter I found out that if I login with another Windows XP user account, I don't get the problem.
Changing the security authority of XP file systems and IIS didn't help.
And to prove that I was doing the installation correctly, I tried a new installation of the VWDExpress with SQL server 2005 express in another machine, it worked and I could create new empty SQL database.
After 2 days of frustrating changing of options, parameters, server names, messing with the registry etc.... Finally, I found a way to overcome this problem.
The solution is:
In Visual Web Developer 2005 Express, select:
Tools -> Options -> Database Tools -> Data Connections,
Change the setting: "SQL Server Instance Name (blank for default)" to "SQLEXPRESS". (where SQLEXPRESS is the default server instance name)
That solved this 1st problem.
I still don't know the exact reason for this problem. But I recalled I did installed the VWDExpress few weeks ago, I might have installed it without selecting SQL server 2005 express at that point. I guess the subsequent install/re-install did not clean up those junk in the registry.
I still have the 2nd problem:
The "Create new SQL database..." option is always grayed out when I right click on the Data connections in the "Database Explorer" tab.
I have a bypass for this difficulty for time being:
I have to do it by using the "Add connection....", put in the server name: "myserver/SQLEXPRESS" and a new database name.
Any input form anyone ? Appreciated!
View 3 Replies
View Related
Sep 23, 2007
I have several general questions about this but I thought I would describe what I am doing first. My senior project team is developing a web application that will wind up using SQL Server for the database. We are writing it in ASP.net and developing the database on SQL Server Express. My job is to develop and deploy the database. I have an ERD designed and am getting ready to start coding the tables, constraints and stored proceedures but am unsure of a couple of things.
1) How do I create a new schema?
2) I can see how to create tables in the GUI but what I am trying to do is create scripts that can be used to create the tables and objects on the actual server that our client will be using. How do I create scripts in 2005 Express? Do I just go click on the new query button?
3) Are scripts that work for Express going to have any problem executing on SQL Server?
View 1 Replies
View Related
Feb 8, 2006
I got sql 2000 installed on my machine. I got a sql 2000 database instance on my computer and I installed sql 2005 server enterprise but I have got no server instance from sql 2005 like what i have in sql 2000 when i first install, i can have an own server instance on my computer.
is it becos when i have a previous sql 2000 server instance on my computer??
View 7 Replies
View Related
Aug 5, 2015
I am trying to install SQL Server 2014 on W10. SQL Server installed, but failed to create a server that be connected to. SQL Server Configuration Manager has no options for creating a server either. How do I create the server.
View 4 Replies
View Related
Dec 15, 2006
My question is what is the proper way to do this? I have been try the ways that it is instructing me to do.
By creating the name, then I go to a list of potential sources, one being: the local, then another being: the actual domain on the network, last one being: the name of the created data source. I have already tried the local & domain, I will try the last one.
But, my question is if this selection is not going to connect to SQL SERVER. Then, "What should I do within the server to make this connection possible to a client computer look for the access?"
View 1 Replies
View Related
May 24, 2006
I am trying to create a linked server in SQL Server 2005 to show tables in our AS400. I made the connection, however, the tables are not showing up under the Linked Server name.
How do you get the linked tables to display in the Linked Server folder?
David
View 4 Replies
View Related
Dec 18, 2006
Hi,
I am using SQL Express 2005 sp1
When I created a linked Server to the DB2 on iseries ( V4R5) , the SELECT statement fetches me only the first record and the following message appears.
OLE DB provider "MSDASQL" for linked server "DB2TEST" returned message "[IBM][Client Access Express ODBC Driver (32-bit)]Driver not capable.".
Msg 7330, Level 16, State 2, Line 1
Cannot fetch a row from OLE DB provider "MSDASQL" for linked server "DB2TEST".
I am using 'MSDASQL' which refers to the DSN setup on my machine using the ODBC "Client Access Driver 32-bit"
Strangely when I used the same DSN in SQL 2000 within the DTS package, I was able to connect and import data and worked like a charm.
Can anyone advice me where I am going wrong.
Thanks in advance
View 1 Replies
View Related
Sep 17, 2007
I need to create a linked server to a SQL 2005 server (B) from another SQL 2005 server (A). Problem is that Server B's name has a dash in it, and SQL Server doesn't like dashes in the name when running a query against the linked server. Server B's network name is Server-B. For example, from Mgt Studio on Server A, I've created a link to Server B whose name is Server-B, so in my query from Server A, I issue: SELECT * FROM Server-B, and get the following error message:
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '-'.
Any ideas,
Thnx
Roz
View 3 Replies
View Related
Feb 19, 2008
Hi,
I was just wondering if SQL Server offers Packages as an option as Oracle does? I just worked on an oracle project and I thought the idea of creating packages to house stored procedures and functions to be really cool and I was wondering if SQL server offers the same option. Thanks in advance.
View 4 Replies
View Related
May 14, 2008
Hello All
how to dynamically create ODBC DSN For SQL Server with SQL Authentication
Thanks in Advance
Regards
Balagangadharan.R
View 1 Replies
View Related
Apr 17, 2001
Hi,
I am using SQL Server 7.0..When I go to the Enterprise Manager and try to Create a New database, the Datafile defaults to C:MSSQL7 and the Transaction Log Defaults to C:MSSQL7 folders...
Is there some setting on the Server itself so that the defaults are different..Like D:Data etc....
I know I can type in the correct folder but my main question is that is there some setting in Enterprise Manager or some System Table so that a new database and its Transaction Log is created on a different default drive..
Thankx
KP
View 2 Replies
View Related
Apr 3, 2002
I have a SQL Server 6.5 db on a server, we need to migrate SQL Server to another server.
We have about 400 users connected to an OBCD driver pointing to the original server and
would like to connect them to the new server.
How can I do this without changing all the users OBCD settings?
Is there a function to alias the new server?
View 1 Replies
View Related
Sep 24, 2007
Hello,
any one --can you explain the meaning of 'Creating an Image of a server.'
View 2 Replies
View Related