Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8999895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:14:27+00:00 2026-06-16T00:14:27+00:00

Hi i have one table in sql server and i have added one bit

  • 0

Hi i have one table in sql server and i have added one bit for each week day. I have one property that’s a date and i want to update all the table updating the bit depending of the dayofWeek of this date. I have read something about t-sql (datepart) but i dont know how can I do it, somebody can help me a little?

Here is a screenshot of my table

http://i.imgbox.com/adpsLL0D.jpg

For instance, in the firsts three records (2012-11-04, the last month, sunday) i want to update updating “prt_Dom” to 1.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:14:28+00:00Added an answer on June 16, 2026 at 12:14 am

    I’m not completely sure what you’re trying to do, but perhaps something like this?

    set language spanish
    go
    
    update dbo.MyTable
    set
        prt_Lun = case when datename(dw, prt_fecha) = 'Lunes' then 0x1 else 0x0 end,
        prt_Mar = case when datename(dw, prt_fecha) = 'Martes' then 0x1 else 0x0 end,
        prt_Mie = case when datename(dw, prt_fecha) = 'Miércoles' then 0x1 else 0x0 end,
        prt_Jue = case when datename(dw, prt_fecha) = 'Jueves' then 0x1 else 0x0 end,
        prt_Vie = case when datename(dw, prt_fecha) = 'Viernes' then 0x1 else 0x0 end,
        prt_Sab = case when datename(dw, prt_fecha) = 'Sábado' then 0x1 else 0x0 end,
        prt_Dom = case when datename(dw, prt_fecha) = 'Domingo' then 0x1 else 0x0 end
    where
        ...
    

    If your logic is really this simple then you don’t need the prt_% columns at all, because you can always derive the bit values from prt_fecha on demand. But I’m guessing that you’re setting defaults here that you may override later, in which case the table would make sense.

    And when working with dates be careful with culture-specific settings such as SET DATEFIRST and SET LANGUAGE.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In SQL Server 2008: I have one table, and I want to do something
In SQL Server 2008 I have two tables. One table for users: id_user -
I have a database in SQL Server 2008 and one particular table has information
I have a DataGridView which is filling from Table in SQL Server Database. One
I have 2 Identical tables in SQL Server 2008, one is the Live table
I have SQL Server 2008 R2 and one of my tables has a date
I have a SQL Server table full of orders that my program needs to
I have a table in a SQL Server 2005 database with a trigger that
In Microsoft SQL Server : I've added an insert trigger my table ACCOUNTS that
I have a table in SQL Server, tblMain. There's a trigger that when a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.