Using a UDF to decrypt column
I have a table called #encryption Create Table #encryption (EmployeeIDEncrypted varchar(100),EmployeePartialID varchar(10))and I have a function which uses the EmployeeIDEncrypted value and...
View ArticleCalculating elapsed time between actions within tasks
I have the following data:TaskID ActionID User ActionDateAndTme 1 11 1 2008-07-02 08:45:00 1 12 1 2008-07-02 08:50:00 1...
View ArticleRetrieving document from a table path
Hi All,I have document path in a table Varchar column like this...Column NameGUID/GUID/x.docGUID/y.pdfGUID/GUID/GUID/z.xlsI have not seen this pattern before. Each GUIDS here might be pointing to...
View ArticleHow to REPLACE in a ntext column
Re: How to REPLACE in a ntext columnI have a ntext column in a table. Say the value is 'xxxxabcxxxxx'. I want to replace the 'abc' with '123'. I have tried several ways but have not been successful....
View ArticlePossible issue with protected view when using Openrowset to import data from...
Hi thereI am having a weird issue when trying to import data from an XLSX file into SQL (2008). The data is test data provided by a client. I noted that when I opened it in Excel on my workstation it...
View ArticleOutput results to text file using T-SQL
I need to create a text file using sql view. let me know how it can be achieved using T-SQL. ANy help appreciated.
View ArticleUpdate Column by "aggregating" text from another table column
Hi,SUPPOSE I HAVE THESE 2 TABLES:IF OBJECT_ID('dbo.HUC824K', 'U') IS NOT NULL DROP TABLE dbo.HUC824K;CREATE TABLE dbo.HUC824K( FIPS_C [varchar] (254) NULL, HUC8 [varchar] (8) NULL); INSERT INTO...
View ArticleGenerate sql script of a table schema in SQL 2000 through script
I wrote some scripts for correcting my old sql 2000 db schema compared to new sql 2000 db. This is done through a loop operations. First check if any table not found in my old db, then running a table...
View ArticleGetting the records which has special characters that has ASCII value greater...
Hello All,I have a table called PipeSummary and has a column called LineName. This column is of varchar data type, size 100. This column has the data which includes special characters. This is the...
View ArticlePutting the results of an IF and ELSE in a temp table
Hello all. Im having an issue with a task. I want to write values into a temp table from an if and else condition. However in to into #temptable clause of the else it is saying that the table already...
View ArticleCONTAINSTABLE returns empty table
Hello,I am using CONTAINSTABLE with 5 tables join.Now, problem is that when anyone table is empty then It does not check remaining tables and returns empty table.For example,CONTAINSTABLE(tables1,...
View ArticleHow can Optimize this query . when i try to run this query it take more than...
SELECT x1yzef Case When DATEDIFF(dd, CreateDate, GetDate()) >= 120 Then 1 Else 0 End As Over120Flag, Sum(Units) As TtlUnits, Sum(VisitCt) As TtlVisitCt,...
View ArticleGetting Return value from a dynamic sql stored procedure SQL Server 2008
As a result of a migration process from SQL Server 2000 to 2008. we have stored procedures that are going to be held on a linked server and thus are building dynamic sql combining the server name in...
View Articleif else
i am using this code for searching against diffrent parameters. but when i enter wrong record error messag is shown "not found" when i enter valid record it populated to datagridview and agin error...
View ArticleDuplicate Records for All Fields but One
AllHow would I go about deleting rows from a table which are complete dups except for one field (one row will have a value for FileName and the other will be NULL in FileName - otherwise they are...
View ArticleWithin SSMS calculated column changes format of name
I have a column "Name" which is the format John Doe .How would I make my new computed column take this name and make it "Doe, John"?I originally had it splitting the column into First and Last, then...
View Articlesql server 2000 data not sorting with index on table columns used in join...
Hi,SQL server 2000 query results not showing data properly. Previously it was showing proper data but from some days it showing random result set.Again when we backup the sql database and restores on...
View ArticleResetting IDENTITY Seed in Table Variable
How can the identity seed be reset on a column (ID INT IDENTITY(1,1) ) in a table variable (@table) ? Thanks.Kalman Toth Database & OLAP Architect sqlusa.comNew Book / Kindle: Pass SQL Exam...
View ArticleHint recompile to inner query
If i have sql statement(which is inside dynamic sql) like this:DECLARE @myId intSET @myId=(SELECT TOP 1 myId FROM myTable WHERE myName='myName')The plan for this query is always cached, I have checked....
View ArticleHelp
select dbo.fnFormatFullName(i.Ind_GUID, 'tblindividual')as [Member Name], ISNULL(dbo.fnFormatFullName(ii.Ind_GUIDTo, 'tblindividual'), RTRIM( ft.famt_surname) + ',' +...
View Article