Skip to content
Advertisement

Tag: sql-server

SQL – Subtracting a depleting value from rows

I have a situation where I need to take a “quantity consumed” from one table, and apply it against a second table that has 1 or more rows that are “pooled lots” of quantities. I’m not sure how to describe it better, here’s what I mean from a table perspective: I need a resulting rowset from a SQL query that

NVARCHAR(?) for Email addresses in SQL Server

For Email addresses, how much space should I give the columns in SQL Server. I found this definition on Wikipedia: http://en.wikipedia.org/wiki/Email_address The format of email addresses is local-part@domain where the local-part may be up to 64 characters long and the domain name may have a maximum of 253 characters – but the maximum 256 characters length of a forward or

How to count number of records per day?

I have a table in a with the following structure: I would like to know how I can count the number of records per day, for the last 7 days in SQL and then return this as an integer. At present I have the following SQL query written: However this only returns all entries for the past 7 days. How

A way to extract from a DateTime value data without seconds

I have an sql DateTime (ms sql server) and want to extract the same date without the seconds: e.g. 2011-11-22 12:14:58.000 to become: 2011-11-22 12:14:00.000 How can I do this? I was thinking to use DATEADD in combination with DATEPART but seems very error prone (besides performance issues) Answer For a solution that truncates using strings try this: CHAR(16) works

Advertisement