Quantcast
Channel: Transact-SQL forum
Browsing all 12890 articles
Browse latest View live

How to show a database to a user for which only he has the read access?

Hi All,We have a SQL Server and it has say 10 datatabases, we have created a login and also a user which has read access to just one of the 10 databases.I used use [master] DENY VIEW ANY  DATABASE to...

View Article


Create 3-dimensional array from SQL Server table using T-SQL

Hi,Is it possible to extract a 3-dimensional array from a SQL Server table?  I have the code in C# but it's taking a long time because of all the for loop statements.  I'm wondering if anyone has done...

View Article


Image may be NSFW.
Clik here to view.

Incorrect Statistics Column Order on a Composite Clustered PK

Hello All,  I've encountered a bit of strange behavior with statistics in a database I am working on. Basically I have a partitioned table that has a composite clustered PK consisting of two columns...

View Article

Coverting row data to column

Dear Allwe have data in db likeOrderNo       Item Type                 ItemName    ItemColor    1                  Main Item                   Pant           Red     1                  Main Item...

View Article

Join On 3 Tables

I have been running a query that shows me all employee id's that have 0 vacation or 0 sick time remaining.  Now I want to join in a calendar table so I can view their hire date/year also.  The tricky...

View Article


SQL Select using LEFT OUTER JOIN returning field values when I expect NULL

I am having problems with this select statement:SELECT distinct pl.id, th.trip, pc.country, pph.locationFROM people_list pl, people_travelhistory th, people_country pcLEFT OUTER JOIN people_info pph on...

View Article

using varchar record in SELECT query

Hi, from a VARCHAR field I get the string ",1,2,3,4,5,6,".I wish to use it in a SELECT query like:SELECT * FROM TABLE WHERE ID IN (1,2,3,4,5,6)Is there a way to obtain this in a tsql query ?Thank...

View Article

How to find last login date of a sql login?

i want to disable the SQL Logins which are not logged in last 15 days. (I schedule a job every night to check and disable)For this i want to find  last login date of all sql logins in an instance if...

View Article


FORMAT works in 2012 but not in 2008 - What am i missing?

Msg 195, Level 15, State 10, Line 159'FORMAT' is not a recognized built-in function name.Msg 195, Level 15, State 10, Line 280'FORMAT' is not a recognized built-in function name.Getting this running...

View Article


Displaying different sums in the same row based on date ranges

Say I had a table like thisDECLARE @t1 TABLE (RowId INT PRIMARY KEY IDENTITY(1,1), BusinessType VARCHAR(100), SalesPerson VARCHAR(100), Category VARCHAR(100), OrderAmount DECIMAL(10,2), OrderDate...

View Article

Image may be NSFW.
Clik here to view.

Need help with query

I am trying to get numbers that appeared in 2 consecutive rows only for columns C1, C2, C3, C4, C5, C6, C7, C8 and output it . For instance in the sample data below: rows 1 and 2 have 3,5,6,12,14 in...

View Article

How to add 5 hours to an existing date field in the database

Have a date field 2013-11-21 00:00:00.000 but need to add 5 hours to it to make it 2013-11-21 05:00:00.000.Please how can I do this?Mijecarr

View Article

Question about selecting distinct from CTE

I have a query which is basically proprietary, so I can't show the details here.All the Select * From stuff works, but I'm getting some dupes, which aren't real dupes, but according to the client they...

View Article


Aging Report SQL Query

Dear Guys, I have tried for aging report query , but still my expected results is not come. Please go through below the table and script data for your reference. Please wirte a query for aging report....

View Article

Calculations in SQL Server

I need to expand my query and do some calculations in side of it.  What I am needing is to get a few percentages.  I need to calculate my % Can Solicit which would be the [Yes]/[Counts Received] and [%...

View Article


TRUNCATE vs DELETE

HiFrom background reading I understand that there are some fundamental differences between using TRUNCATE and DELETE with no WHERE clause. For instance, TRUNCATE is a DDL command and logged at the page...

View Article

Compare Consecutive Rows in a table

Hi,I want to compare consecutive rows for each employee. I need to compare SchedulEnd column of the first row with the ScheduleStart of the second row as so on. if both the values are same then i need...

View Article


How to run a large script from sqlcmd and continue despite errors

I am on SQL Server 2008 R2.I have  a large sql file (4 GB size) which has various insert  statements created by genarate script of SQL Server 2008, i.e, generate script facility to create insert...

View Article

Text-Based Best/Worst Categories Assigning

Dear friends,Got a table with Customer IDs and Non-Numerical rating of some sort an example...

View Article

SQL Weight Multiplication

Hi all i have two columns in a table : +--------------------+----------------+ | Units/Pk | PackWeight/Vol |+--------------------+----------------+ | 1.0000000000000000 | 150g...

View Article
Browsing all 12890 articles
Browse latest View live


Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>