Pivot Query Error
I'm using:Microsoft SQL Server 2008 (SP3)I'm trying to pivot a view. Here's the code:select Company_Code ,Vendor_Code ,[CC] AS CC ,[COI - AL] AS COI_AL ,[COI - AL C] AS COI_AL_C ,[COI - ER] AS COI_ER...
View ArticleObtain rows from a complex sql query
Hi to all, please somebody who can help me, my scenario is as next:One table like nextReservation (table)Boat (string)reservation (date)class (string)room1_cod (int)room1 (int)room2_cod (int)room2...
View Articlepassing parameters to table valued functions and using parameters as column...
I am creating a function where I want to pass it parameters and then use those parameters in a select statement. When I do that it selects the variable name as a literal not a column. How do I switch...
View ArticleEXECUTE permission denied for local system user
I have a NetIQ alert that runs a stored procedure that generates an execute permission denied error each time it runs. The NetIQ agent is running as the local system user. As I understand it, the local...
View ArticleSQL Loop and While to expand a record set
Looking for some TSQL help. I have a file with about 750K records in it. The records look something like this:First_6_of_Phone_Number|Last_4_of_Phone_Number_Start|Last_4_of_Phone_Number_End...
View Articleadding input parameter in SP to be used with LIKE operator
Hi All, please advise on below scenario.In my SP i want to add one parameter @order_type (whose values to be displayed on drop-down list of the report is :--> "All", "Only FSV", "Only Rx" Now, this...
View ArticleI was checking how many conditions can slow my stored procedures, pls tel me...
Hi,I am using following to free up buffer and catch (Only for testing , to find speed of SP in diffrent situation)is there any thing else i can add to following list. DBCC FREEPROCCACHEDBCC...
View ArticleUPDATE() function with Insert Trigger
I created a table with an Insert Trigger and then tried using the UPDATE() function to determine if the column value was passed. E.g., INSERT INTO mytable (col1, col2) VALUES ('hello',...
View ArticleComparing data size in one table to column widths in another table
I have data in a table that has a large number of columns, many of them nvarchar of varying widths. Im trying to take that data and insert it into another table but Im getting the warning message...
View Articlestatic Decimal value in insert query
HI am going to insert decimal value in table but i got this error" Arithmetic overflow error converting numeric to data type numeric."HERE val one is a decimal value how can do this?INSERT INTO...
View ArticleIncrease Scope of CTE?
I am really starting to like CTEs. My only qualm is that you can only use them within the first statement after you declare them. I wish they would remain active for the duration of the sql batch just...
View ArticleUpdate Query With Escape Character
Hi, I am using sql server 2008 R2 and I am trying to update my column which contains single quote ( ' ). I want to replace this single quote with white space.I am trying it with escape character which...
View Articlewrong estimation
I have created filtered index on table:CREATE NONCLUSTERED INDEX [ix_test] ON [dbo].[myTable] (col0 ASC) INCLUDE (col1) WHERE (col2 IN(1,2,3)) ON [PRIMARY] GOcol2 is TINYINT data type.Then i have query...
View ArticleSelect group by query
I'm wanting to exclude 3 values from the group by clause within a select statement, how would I achieve this with the following select statement:SELECT Distinct ClientName AS Client, Service AS Serv,...
View ArticleIf condtion in calculation part
Hi i want to claculate concessbed days . here i want to check if it is not or not then only i am going to calculate.Here is my code. UPDATE c SET @CONCESSIONBED= IF(t.OCCBEDDAYS>0,...
View ArticleLINQ datetime comparison in where clause
i have a nullable birthdate column in sql server which i am using to compare age search criteria in linq to sql.Now the problem is, i can't compare the property on the nullable type which is 'year' in...
View ArticleGet consecutive duplicate nos - TSQL
I want TSQL statement to find the hat trick details based on run.IDOverBallRun101110102121103131104141105152106162107214108224109234110241111252112261Result:102121103131104141107214108224109234
View ArticleHelp with Complex Query
HiI have to write a query that looks like so:Cust ID | Prgm1 | Desc1 | Date1 | Prgm2 | Desc2 | Date2 | PrgmN | DescN |...
View Articlehow to count comma seprated values in sql
Dear all,here is my table record for inch column:Inch:17,23,1612,15,17,36,4412,17,18,2811,17,1917,21,24,5714,13i want to count the record which split by commalet said:SELECT COUNT (TM_ID) AS TOTAL FROM...
View ArticleFinding rows with mismatched birth dates
I am attempting to find persons in a data set with multiple rows containing mismatched birth dates.Even limiting the select to 40 rows, this code will run for hours.If I take out the check for month,...
View Article