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

How to get only column names from different tables as single table columns

Hi All,   I have one requirement in which we want only column names from different tables.for example : I have three tables T1 ,T2, T3 having  col1 clo2 clo3 -->  T1 ,   col3 col5 ,clo6 --> T2 ,...

View Article


how to use alias column in where condition in sql server 2008

how can i use alias column in where condition in sql server 2008. eg suppose i have a table,  i need to show one extra column by the using of other column value. now i want to use new column in where...

View Article


Pivot table

DECLARE  @SOURCE TABLE  (FAMILY_ID INT,CHILD_ID INT,CHILD_FIRSTNAME VARCHAR(50)) INSERT INTO @SOURCE  VALUES ('060616754','1','A'),('060616754','2','B'),('060616754','3','C') SELECT * FROM @SOURCE...

View Article

T-SQL help require to construct a query to sum on varchar column

Guys, I have a column varchar(400) wherein currency_amount is stored. I need to sum currencyamount however getting the error like  Arithmetic overflow error converting varchar to data type numeric.Any...

View Article

Conversion failed when converting the nvarchar value to data type int when...

Thank you for your help!!!  I've created a stored procedure to return results as xml.  I'm having trouble figuring out why I'm getting the error message "Conversion failed when converting the nvarchar...

View Article


validating check digit for Upc code or inserting 12th digit automatically...

if exists(select 1 from INFORMATION_SCHEMA.ROUTINES where ROUTINE_NAME = 'udf_Calculate_UPCA_CheckDigit' ) begin drop function dbo.udf_Calculate_UPCA_CheckDigit end go create function...

View Article

Image may be NSFW.
Clik here to view.

Require help with Pivot table query in SQL Server 2008

Hi,I have a query regarding converting columns to rows in SQL Server 2008. Please look at the table below. I need the output to look something like this :The columns for the children can be dynamic or...

View Article

Special permission on Db_datareader user for execute sp_helptext

Hi friends I have a question.  Is there a method that allow a user db_datareader execute the procedure sp_helptext?. I tried the following with bad results:1) I created a role in my database and i...

View Article


conversion failed when converting date and or time from character string

Hi,I am getting the following error :conversion failed when converting date and or time from character stringI am using Sql Server 2008.(database designed for sql 2005 later moved to sql server...

View Article


Need to join the data, of different tables

I have some data in 3 tables, Table 1 has all the names say, table1 has column Name with data as A,B,C,D,E. Table 2 has columns Name,Logins_T2,Entering_T2. Same way table2 has columns...

View Article

How to change a column value in a Select statement ?

Hi All,I am trying to select the Name from the customers table and I wanted a way to in the select statement to set name to 'unknown' if the Name is set to NULLSelect Name from Customers  -- I want to...

View Article

unpivot rows in a table

Environment: SQL Server 2008 R2Problem: How I would unpivot the following table. Code:CREATE TABLE [dbo].[ind_subject_scores]( [ind_scr_id] [int] IDENTITY(1,1) NOT NULL, [id] [char](9) NULL,...

View Article

Find all Null Values for Each Row and Update Results in Another Column

I need to find all the columns that have a null value for each row and update the results in another column. Below is an example of what the data may look like with the column "MissingEntries" that...

View Article


Insert a new row in table where certain conditions exist

Hi all.I am working on a database in Microsoft Sql 2008 r2 and im trying to insert a new row into a table where certain conditions exist it's similar to an update / insert  hence why im a little...

View Article

Image may be NSFW.
Clik here to view.

Get date from previous record

I have a StartDate and EndDate for a Pay Code.  This tracks when employees rates changed by pulling the first and last time they got paid at any given rate.  I need the StartDate for the next increase...

View Article


Sporadically getting error "string or binary data would be truncated" in SQL...

I am facing a strange SQL exception:-The code flow is like this:.Net 4.0 --> Entity Framework --> SQL 2008 ( StoredProc --> Function {Exception})In the SQL Table-Valued Function, I am...

View Article

Need to create a Star Schema for my Process

Hi,I have a Stg table which has the data like belowIssueId  ProductName  CompanyName   Status    CreateDate1            abc                   AAA                 Active   2014-01-012            abc...

View Article


Way to populate data for current quater months from last month of previous...

Hi  I have a requirement to load forecast data into the SSAS cube. My current data:Snapshot_M       Date         F_Quantities1/1/2014        1/1/2014    1002/1/2014        2/1/2014    903/1/2014...

View Article

Image may be NSFW.
Clik here to view.

Could you please suggest the T-SQL

We have 2 date parameter WeekEnding Start Date And WeekEnding Endatewhich is generally starts on                              Saturday to Saturday                             Saturday  to Sunday...

View Article

looking for select statement dynamic way?

hello experts,i have below primary table,CREATE TABLE A ( A_Id int NOT NULL PRIMARY KEY, A_NAME VARCHAR(10) NOT NULL )Now, this table has refernce either with one or more table, let say with 2 tables...

View Article
Browsing all 23857 articles
Browse latest View live


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