Solved

setting a sql bit field

Posted on 2013-02-07
7
312 Views
Last Modified: 2013-02-13
I have an excel spreadsheet and I am importing it into sql.  One column is True or False,
How do I map it to a column that is of datatype bit?
0
Comment
Question by:Jeff_Kingston
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 15

Expert Comment

by:Aaron Shilo
ID: 38865626
where is the problem just directly map the column .

do you get an error?
0
 

Author Comment

by:Jeff_Kingston
ID: 38865645
No, I just get null in all rows regardless of the true/false value in the imported field.
0
 
LVL 15

Expert Comment

by:Aaron Shilo
ID: 38865729
well i guess the fastest way for you is to load the excell into a STAGE table with column type Nvarchar and then move the data into your permanent table.
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 48

Accepted Solution

by:
PortletPaul earned 500 total points
ID: 38866608
1 = true
0 = false

change the column data in Excel perhaps? (i.e. to exclusively 1 or 0, no nulls, and not text 'True' 'False')
0
 
LVL 12

Expert Comment

by:Harish Varghese
ID: 38871678
Hello Jeff,

Ideally, a column of boolean values TRUE/FALSE in Excel should be automatically mapped to bit field when you import into SQL Server table. I tried a sample file and it works fine for me. Would you mind attaching the file here, after removing any sensitive info?

-Harish
0
 

Author Closing Comment

by:Jeff_Kingston
ID: 38885367
Worked like a dream.  Thanks
0
 
LVL 48

Expert Comment

by:PortletPaul
ID: 38885422
excellent. have fun.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MS SQL with ODBC 5 35
Query group by data in SQL Server - cursor? 3 29
Sql server get data from a usp to use in a usp 5 15
sql 2008 how to table join 2 12
Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

774 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question