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

Populate information on each line returned of a select statement

Hi all,SELECT StockItem.Code, StockItem.Name, BinItem.confirmedQtyInStock , (CASE WHEN BinItem.BinName = 'W2' THEN BinItem.confirmedQtyInStock END) AS 'W2', StockItem.ItemID, Warehouse.Name AS...

View Article


Fixing a Date Value from flat file import into SQL via DataTable C#

I have a table which was created by importing a time card flat file from American Airlines. In the process the data values get messed up. The Flight Date is a string value. I need to fix the Flight...

View Article


msg 156 unclear

followiing Unpivot Query Gives error 156.....any ideaselect School_Year,COL,DatePairfrom #stagedata4unpivot                               (DatePair FOR COL IN  ( T1M1,T1M2) ) As uperror:-----------Msg...

View Article

Can't Get The Right Join

I have two tables (terrible data architecture I know...) One table itemsShipped one table itemsDamaged.  I need to get a count of item from itemsDamaged in my query, but when I use an Inner Join (or an...

View Article

TSQL Help

I am trying to find the solution for the following, Any help would be hightly appreciated.CREATE TABLE #A ( CustomerId int, TranDate datetime, TranCount int )CREATE TABLE #B ( CustomerId int, TranDate...

View Article


INSERT INTO MSAccess Linked Table Memo Field FROM SQL Server VARCHAR Field

I know I am doing the opposite of everyone else.  But I need to INSERT INTO MSAccess Linked Table Memo Field FROM SQL Server VARCHAR Field.  Don't ask why...I have tried CAST and it does not seem to...

View Article

calculating age using sql server function

Hi ya,I have a table which will be having DOB and I want to calculate the current age of persons, i want to save it into currentage as default. I have searched over the interent and find some solutions...

View Article

Image may be NSFW.
Clik here to view.

Become our FIRST Microsoft TechNet T-SQL Guru of 2014!!

Happy New Year!Time for a fresh start!We're looking for the first Gurus of 2014!!This is your chance to make your mark on the Microsoft developer community.All you have to do is add an article to...

View Article


Check to see if a job is running and stopping/re-starting it

Hi All,I am trying to accomplish the following via a sql stored proc/script and need help:1. Check to see if  the job named "Data Load" is running2. If it is running, Stop it first and then start...

View Article


TSQL Help needed using time datatype

i have a requirement to get the appropriate RunID based on the Starttime.I'm not able to get results if Starttime is beween 00:00 and 05:00 for ABC Dataset. Please...

View Article

Need help with copy stored procedure from one database to another

Hi.  I have 2 databases which have the same table structures but one database doesn't have any stored procedures.  The database without the stored procedures will be used for archiving data only.  I...

View Article

Recursive sql

I need help please.I have a table with payments. I need to check for each idno if he has payments for a certain year that exceeds the total amount allowed. In my example the total amount allowed for...

View Article

Image may be NSFW.
Clik here to view.

Running Total Break By Year

Hello all,I have sql server 2008 R2 and I'm trying to come up with a running total calculation and then break by year (start over in new year) If anyone has some suggestions, I'd be very grateful!Table...

View Article


list all folders, and subfolders, in a directory

I'm trying to find a way to list all folders, and subfolders, in a directory.  I ran the code below and got a message that says 'Access is Denied'.  There is no way access is denied to that folder. How...

View Article

IF LOGIC

hii need to know how to see previous valueexample, i have two coumns           category       reason        program            active            open             1now for category      reason we can...

View Article


sql query

I'm trying to join to tables and get counts but not sure if this is right.Table1 has columns -  name, model, os, memory, locationTable2 has columns -  location, descriptionThis is output I'm trying to...

View Article

group by clause with where clause should return count zero also

Dear friendsSELECT * FROM A1A ACCEPT 2AACCEPT 3CACCEPT 4CACCEPT 5BHOLD 6GHOLD 7GHOLD 8BREJECT 9GREJECT 10HREJECT 11HREJECT 12ANEW 13HREJECT 14HNEW 15CNEW 16DNEW 17ENEW 18DACCEPT 19DACCEPT 20FACCEPT...

View Article


Replace invalid XML characters using SQL query

 Hi,   I am populating a dataset in .net with output from sql 2005 database. One of the columns in the table is a 'varchar(max)' type. This dataset is then converted to XML using WriteXml and written...

View Article

Case statement for other info

Hi guys, I really need your help on a case please.  I need to retrieve info from a column that contains a name instead of a numeric value such as " CASE WHEN EventCodes = 'Registered' THEN...

View Article

TSQL Help

I need to write TSQL which gives the Result as below from Table A and Table B. Any help would be appreciated.Table A :LogId LogDate         NumberOfRecords 1       1/1/2013       1000 1       1/5/2013...

View Article
Browsing all 23857 articles
Browse latest View live