XML strange problem
Ok I'm doing a few exercises in SQL Server 2012And I did the following[code="sql"]IF OBJECT_ID('ClientInfoCollection') IS NOT NULLDROP XML SCHEMA COLLECTION ClientInfoCollection;GOCREATE XML SCHEMA...
View ArticleFind First and Last Period without holes
OK, first post and Subject I can not phrase any better.1. I have a table where all records have a field for period.2. For each record I want to know what the first and last periods are in which the...
View Articlesimple MAX question
Hi there, I would like to find the MAX (score for example) and return who got that score. Imagine if I have a table of 3 fields: score, name and dob. How Do I return who has got the max score and their...
View Articlesp_addlinkedserver within a Transaction
A number of years ago, I implemented a remote query solution in SQL 2008 based off the remote execution code by Rudy Panigas shown at the link...
View ArticleDisadvantage if using View to Insert Data?
Hi there,For my DWH I am using partitioning for all my bigger tables.As I would like to use two dimensions for partitioning I decided to create different tables to splitt the years.To query the data I...
View ArticleEncrypt Stored Procedure
I would like to encrypt SP, but I do not know how security different between 1 general procedure with "WITH ENCRYPTION" : display on Object Explorer windows2 temp procedure with "WITH ENCRYPTION" : NOT...
View ArticleAliasing a FOR XML PATH result
Hi,I want to alias the output of the following:[code="sql"]-- Test table with some rubbish dataDECLARE @Test TABLE( Names [varchar](20))INSERT INTO @TestSELECT 'Simon'-- Query returns but with...
View ArticleTSQL Subtotalling
Please forgive my ignorance if this is a simple fix but I am having a brain cramp. The goal: derive new records with subtotals of a recordset.Source recordset:index, workcode, value1, CL, 52, CL, 103,...
View ArticleDynamically discovering row relationships
My database structure kind of looks like a tree - a main root table with a primary key, tables with foreign keys back to that table, other tables with foreign keys back to the 2nd level, etc. All of my...
View Articlepass through query from access to sql-how can I select all records witha date...
Hi I am an absolute 'noob' when it comes to t-sql however because of an issue we are haing in extracting some data from an sql database I need to to run a pass through query and use the following in my...
View ArticleChanging from "hard-coded" to dynamic query
Hi. My name is Momba and I'm a T-SQL noob....So I've got the following hard-coded query:[code="sql"]select * TableCurrent WHERE BRANCHID='950' AND (DISC_DTE IS NULL OR DISC_DTE >...
View ArticleDateValue Function missing in SQL Server 2012 Express
Hi AllI am trying to use the DateValue function on a table in SQL Server Express 2012 but it says that it is 'not a recognized built-in function name'. Has it been removed from the express version or...
View ArticleError using If Logic to create specific version of a table.
When I parse the code below, I get the error 'There is already an object named '#DBCC_OUTPUT' in the database.'I don't want to resort to dynamic SQL if I can avoid it. I didn't include all the columns...
View Articleregular expression format supported by that CLR
Hi,I am new for CLR..I want to achieve following criteria.The format can be formatted as It can begin with V, E, or a number.• If it begins with V, then it has 2 numbers, a decimal, then up to two...
View ArticleHow to find the tables to join ?
Hello,I am beginner in T-SQL.I need to find the tables to the join between the table "Product" table and the "Customer" of the database AdventureWorks2012.Any idea ? Thank you.
View ArticleDatabase Deployment using SSDT
Hello,We recently have been using the December release of SSDT to script out a database deployment and noticed that the script generated DROP and the CREATE statements for tables, even though the table...
View ArticleWhat's wrong with my DISTINCT
I've got another noob question...When I run this query to just grab the emp_id I get 6474 but when I request more fields I get 6605?[code="sql"]select distinct CONVERT (varchar(9),EMPLOYEE_ID) AS...
View ArticleOpen row set command not working as expected
Hi,i need to use openrow set command to fetchdata from excel.it is throwing error- The OLE DB provider "Microsoft.ACE.OLEDB.12.0" has not been registered.But i am able to fetch data from SSIS by...
View ArticleBCP comma delimited file into a table
I must be overlooking something really simple, but I am stuck. keep getting the error: Error = [Microsoft][SQL Server Native Client 11.0]BCP host-files must contain at least one columnHere is my...
View ArticleHelp with a While/Loop Query
Good MorningI am new to T-Sql and I have been taske with creating a simple Time table with four columns:Date date not null,CalendarYear int not null,CalendarMonth varchar (30) not null,FinancialYear...
View Article