CASE Statement in a SELECt
I want to do something like this in a SELECT where I set the value of one field based on another. Is this possible. If not are there any alternatives? ThanksCASE WHEN [var_cpnt_brkpt_ct] = '0'THEN...
View ArticlePerformance benefit of using CROSS APPLY
HI GuysWhile working today with SQL i got one concern:I have one table tblHierarchy. It has fields: ID, ParentID,externalRefAnd this table stores hierarchy upto 6 level (it may vary but not more than...
View ArticleHow to generate test data
HiI need to generate some test data and would like to know if there are any built functions in SQL Server 2012 that let you do that apart from using loops. In PostgreSQL I use different built in...
View ArticleError " "The text, ntext, and image data types are invalid for local variables"
I need to do within SQL is to query a database and then to assign these results to variables which are then used as parameters while calling a stored procedure.Within SQL you can not declare a text...
View ArticleGet package information from job
I am trying to create a report showing which SQL Agent job is running which SSIS package..so far I have searched through following tables..sysjobactivity sysjobhistory sysjobs sysjobs_view...
View ArticleHelp need in Avoiding Loop
Hi,My table and data:Create table Sample(Empid int primary key identity(1,1),EmpName varchar(50),Empsalary money,EmpDesignation varchar(30)); insert into Sample values('Jhon',8000,'Manager'),...
View ArticleCreating a 4-4-5 Time Period table
Hello:Very soon my company will be moving to a 4-4-5 reporting schedule. Basically, what this means is that the first month of the quarter will have 4 weeks, the second will have 4 weeks, and the...
View ArticleColumn Store Index in SQL SERVER 2012
Hey Folks,Hope you all are doing well there.Here i come again with one of the intresting query , it would be really appreciable if any one have solution for the same.My query is As you all know, Column...
View ArticleSQL server Query help
I have four table like below: CREATE TABLE Party ( PartyID int identity(1,1)not null, PartyRegisteredDate datetime, MemberNo varchar(16), SubsNo varchar(9), PerNo varchar(2) ) CREATE TABLE Contract (...
View ArticleJoin Between 2 Fields when Fields in One Table have Multiple Values
I have 2 Tables, which are joined by the customerID field. One table is an existing table where there will only be a single customer id in each row. The other comes from an import file...
View ArticleIf exists become an infinite loop..
Guys, do you have an idea why this simple code IF OBJECT_ID('generatortriad', 'U') IS NOT NULL DROP TABLE generatortriadand this other code (attempt)IF EXISTS (SELECT TABLE_NAME FROM...
View ArticleREPLACE
I've noticed within my fields there are BREAKS <BR>....So when I export the results into EXCEL, each break point will jump into another line.How can I replace all <BR> with a blank...
View ArticleLock request timeout period exceeded error when expand table list in SSMS...
Hi All,I know this question has been asked several times, but nothing fixed my issue. I have been facing the error "Lock request timeout period exceeded. Error 1222 when I try to expand the tables list...
View ArticlePivot sql
Hi, IDContract_Year type1Fee 1type1Fee 2type1Fee 3 type2Year1type2Year2type2Year3 12015 $1.50 $1.50 $1.50$2.00$2.00$2.00 this is my SOURCE DATA, AND i am trying to get in this model id...
View ArticleSQL Server 2005 Hierarchical Data concatenation
Hi Folks, Please help me on the following data concatenation using hierarchical Query Table Data:Level Id ParentTbl PatCol ChildTbl ChildCol 1 A a...
View Articlecase when statement not working
hi there, I am trying to work out how to get my case statement to work. I have got the following code. select pthproto.pthdbo.cnarole.tpkcnarole, pthproto.pthdbo.cnaidta.formataddr as formataddr,...
View ArticleSSIS Convert MMDDYY column to DATE?
I have a table of 120,000+ rows. One of the column is dates in the MMDDYY format. 092509 012009 091711I've brought them in from Teradata, and stored in a staging table in char format. I now need to...
View ArticleTable Trigger Problems
I am currently working on an integration of FedEx Ship Manager Software and our accounting system. The integration has a view which pulls Order and Shipping information from the database. When a user...
View ArticleIF Conditions in SQL
Hello, I am progressing in my knowledge of SQL. I have a query that I built that will INSERT and UPDATE a table depending on a parameter that gets passed in from a web page. It works fine. But, I need...
View ArticleMax of Row Number Logic
Hi,Below are my table structurecreate table Test (ProductId int primary key identity(1,1), productnumber varchar(50),productname varchar(50),Quantity int) insert into Test values('PN1001','Pepsi',20),...
View Article