Wednesday, September 11, 2013

[SQL Server] Comparing a to a substring

[SQL Server] Comparing a to a substring


Comparing a to a substring

Posted: 11 Sep 2013 10:06 AM PDT

I have a filed UserName as for Table A "Z109032, My name" and a query asSELECT LEFT(UserName, 7) as CAR FROM car10 to get Z109032 which needs to be compared to another table that has Z109032. The other table has the field username with just Z109032 and the first and the last name in different fields as Table B ID first last Z109032 My Nameis there any way we can compare these fields in the two tables A and B so that i can find the user on the other table based on the substring of the first table.

Inserting a record into a table

Posted: 11 Sep 2013 05:37 AM PDT

I have a table as followsID Type XID Note21 Note 1 This is a note21 Note 2 This is not for 2 the primary key is a composite key made up of "ID+Type+XID" and i am trying to insert a new record as (22,Note,1, this is note for 22). however i receive a message a primary key violation for inserting "1" again i think, how can i manage my insert so that the new record is inserted for 22 while ignoring the violation. It could probably be an error on design and i have no choice but to work around it. thanks.

Creating a CSV file from a Trigger

Posted: 10 Sep 2013 10:38 PM PDT

Hi All,I am in the process of starting a project and wanted to understand the best way to automate the creation of a CSV file after a process has completed.I could get the user to run a Crystal Report which would create a CSV - but wanted to automate and remove the extra task from the user.So basically I need to create a CSV file from an INSERT transaction.any help would be appreciated.Thanks

Quotes Identifire Default value

Posted: 10 Sep 2013 04:50 PM PDT

Dear all We are using SQL 2012 Express edition & Enterprise edition. As per the http://technet.microsoft.com/en-us/library/ms174393.aspx default value for Quotesidentifier is ON. But when we create new db it shows DB properties - options - Quoted identifier Enabled = False.Please correct me if i am wrong. How to set it as default on.Regards

[MS SQL Server] Is sys.dm_db_index_usage_stats a relatively good indicator of DB useage?

[MS SQL Server] Is sys.dm_db_index_usage_stats a relatively good indicator of DB useage?


Is sys.dm_db_index_usage_stats a relatively good indicator of DB useage?

Posted: 10 Sep 2013 07:27 AM PDT

I'm trying to determine approximately the last time a database was "touched" by users. Thus far, sys.dm_db_index_usage_stats seems to be about the best option. Can't really use the "Last modified" on the MDF / LDF files, as those will change based on SQL accessing them.I'm not trying to use this to determine what indexes might be droppable, just to get an estimate of about the last time a user accessed the DB. The column I'm looking at especially is the last_user_update result.Thanks,Jason

Hot add memory in sql 2008 r2 enterprise

Posted: 10 Sep 2013 05:17 AM PDT

On a single vmware host, we have 8 vm's, each running a single instance of sql server 2008 r2 enterprise (SP2) on Windows 2008 R2. Each VM had 8GB of memory, and we recently hot-added 8 additional GB to each VM. Both the operating system and SQL appeared to recognize the new RAM right away. However, when I increased the SQL min and max memory settings from 4 and 6GB to 8 and 12GB, we started encountering various memory-related errors. The error log was flooded with the following error messages until I set the min and max memory back to 4 and 6GB, respectively:-Memory constraints resulted reduced backup/restore buffer sizes. Proceding with 6 buffers of size 64KB.-Failed to map 16777216 bytes of contiguous memory-There is insufficient system memory in resource pool 'default' to run this query.-Warning: The available page file space has dropped below 4Mb.So my question is, what is the proper procedure for hot-adding memory to SQL servers? Does it require an operating system reboot, SQL service reboot, etc? I was under the impression that "hot-add" meant no reboot necessary, but perhaps that only applies to the guest operating system, and not SQL Server?

[Articles] The Future of Knowledge Measurement

[Articles] The Future of Knowledge Measurement


The Future of Knowledge Measurement

Posted: 10 Sep 2013 11:00 PM PDT

In part 3 of his thoughts on certifications, Steve Jones gives an idea for how we might move forward from here.

[SQL 2012] Installed wrong edition

[SQL 2012] Installed wrong edition


Installed wrong edition

Posted: 10 Sep 2013 05:32 PM PDT

Hi,I installed Standard Edition of SQL Server 2012 instead of Enterprise Edition. Do I have to remove all of the features before installing enterprise edition or is there a shortcut I could take?ThanksG

Data Type Money is adding extra zero

Posted: 10 Sep 2013 07:52 PM PDT

Trying to copy one table to another in sql 2012, data type was set before me. Strangely, my end result have 10 times more money. I.e 27152555833.00 would appear as 271525558330.00 in end column?The tables are identical, anybody have any idea why it would happen?

Syncing/Refreshing data from one environment to another

Posted: 10 Sep 2013 11:01 PM PDT

Hi,We have dev,test and prod environments. The developers make the DDL and data changes on dev and the we will have to move this to test and after the successful testing changes has to be moved onto prod.Right now I am using redgate sql campare and sql data compare to achieve this.Is there any better way of doing this? Sometime a table data in one environment has to be updated with the data from the other as part of the database sync. For this I use import/export or BCP to move data to destination server db and then run the update command.I am wondering is there is any better ways of doing this?Thanks.

GEO - Spatial

Posted: 10 Sep 2013 05:09 AM PDT

I need to find the name of the county based on longitude and latitude values. Could someone give some ideas on how to do it? We will buy data somehow . I have done some coding but all I get is the nearest county. That may not be the right county because of boundaries.Any help would be greatly appreciated.

Become a License Reseller or Not?

Posted: 10 Sep 2013 02:46 PM PDT

I've been pondering this question for awhile now and i just can't seem to find worthwhile information without initiating the process possibly further than i'm interested.Now a bit of background...Been working for a software company going on 8 years now and we sell a mid-tier (40-60k typical installation cost) small business asset management system. We are a SQL Server product, yet as a company do not provide or even refer prospects and new clients to a var/lar to purchase SQL Server if they do not already have it for other packages.We've always taken the approach of letting the customer find a reseller, at which time they typically buy it from a local IT company, then pass it off to my company to install/configure/maintain/troubleshoot.This seems to be increasingly common as our markets move into more and more remote locales and smaller upstart companies.My question is, does anyone know if starting a small license reseller company to simply provide a complimentary service to our customers (our owners don't seem to have a problem with the idea) is worth it/a good idea simply to pick up 5-10 SQL Server licensing deals a year (most are going to be server + cal it seems as they are under ~25 users and that seems to be how most are being steered as far as i can tell)?

[T-SQL] I can't make heads nor tails of this....

[T-SQL] I can't make heads nor tails of this....


I can't make heads nor tails of this....

Posted: 10 Sep 2013 06:06 AM PDT

I was given this query this morning. It's not a pattern of syntax I can ever recall seeing before. I guess it works, but I can't figure out how to write a query using these conventions. Does this make any sense to anyone here?(Note - I've replaced the table names with 'aaaa', 'bbbb', etc in a lame attempt to disguise where the data comes from, but aside from that, no changes.[code]select rtrim(dbo.aaaa.vst_ext_id), rtrim(convert(char,dbo.aaaa.adm_ts,1)), rtrim(convert(char,dbo.aaaa.dschrg_ts,1)), rtrim(convert(char,bth_ts,1)), datediff(year,bth_ts,dbo.aaaa.dschrg_ts), isnull(pat_calc_age_no,0), isnull(pat_calc_age_unit,''), rtrim(bbbb.cod_dtl_ext_id), rtrim(cccc.cod_dtl_ext_id), rtrim(dddd.cod_dtl_ext_id), rtrim(dbo.eeee.plan_ext_id), rtrim(ffff.cod_dtl_ext_id) from dbo.kkkk right join (dbo.eeee right join (dbo.gggg right join (dbo.hhhh ffff inner join (dbo.hhhh dddd inner join (dbo.jjjj inner join (dbo.hhhh cccc inner join (dbo.hhhh bbbb inner join dbo.aaaa on bbbb.cod_dtl_int_id = dbo.aaaa.pat_ty) on dbo.aaaa.vst_sta_cd = cccc.cod_dtl_int_id) on dbo.jjjj.psn_int_id = dbo.aaaa.psn_int_id) on dddd.cod_dtl_int_id = dbo.aaaa.fin_cls_cd) on ffff.cod_dtl_int_id = dbo.aaaa.dschg_srv_cd) on dbo.gggg.vst_int_id = dbo.aaaa.vst_int_id) on dbo.eeee.plan_int_id = dbo.gggg.plan_int_id) on dbo.kkkk.vst_int_id = dbo.aaaa.vst_int_id where cccc.cod_dtl_ext_id <> 'ADMIT' and dbo.gggg.pyr_seq_no = 4981 and dbo.aaaa.dschrg_ts > '12/31/2003' and dbo.aaaa.dschrg_ts < '1/1/2005' order by VisitID[/code]

Compare a date to a previous group of records' max date

Posted: 10 Sep 2013 10:15 PM PDT

I want to reference a previous group's max date and compare it to the date on the current record.My data looks like this:-Grp - Date 00 - 28-10-2012 10 - 29-10-2012 10 - 28-10-2012 10 - 28-10-2012 20 - 30-10-2012 20 - 05-11-2012 20 - 10-11-2012 20 - 30-10-2012 30 - 01-11-2012So we can that for Grp 10, the max date is 29-10-2012, for Grp 20, the max date is 10-11-2012, etc...I want to reference the previous group's max date and compare it to the date on the current record.For example, for Grp 20, dated 05-11-2012, it needs to be compared to the max date for Grp 10 (29-10-2012) to calculate the difference in dates.Grp - Date - Previous Date - Delay 00 - 28-10-2012 - 10 - 29-10-2012 - 28-10-2012 - 1 10 - 28-10-2012 - 28-10-2012 - 0 10 - 28-10-2012 - 28-10-2012 - 0 20 - 30-10-2012 - 29-10-2012 - 1 20 - 05-11-2012 - 29-10-2012 - 7 20 - 10-11-2012 - 29-10-2012 - 12 20 - 30-10-2012 - 29-10-2012 - 1 30 - 12-11-2012 - 10-11-2012 - 2Is this possible in TSQL or do i need to write Package/Function?Any guidance would be appreciated.

Weird Date Issue slowing down Stored Proc

Posted: 10 Sep 2013 10:05 PM PDT

Hi All, can anyone help shed some light on the following issue...SQL Server 2008 SP.My SP returns data almost instantly if the date range I supply has data on all possible dates within the date range. If however, I put a date range in that includes one or more days without date, it grinds to a halt.For example, if I run it so the date range is a monday to friday and each of these days has data, the date returns instantly. However if I run it from say, thursday to saturday (and the saturday has no data), the SP takes about 15 seconds to run. If I scale up the date range to about 6 months, there may be many days with no data - suddenly the query is taking 4 to 5 minutes to run! I have indexes set up on all the joining columns and the date field. Sp below (apologies that I can't get it to format into a nice layout here)...ALTER PROCEDURE [dbo].[sp07319_UT_Reporting_Surveyors_by_Spans_Surveyed](@StartDate DATETIME, @EndDate DATETIME, @CircuitFilter VARCHAR(MAX), @VoltageFilter VARCHAR(MAX), @SurveyorFilter VARCHAR(MAX))ASSET NOCOUNT ONSELECT A.[intStaffID] AS [StaffID], ISNULL(A.[strForename], '') AS [Forename], ISNULL(A.[strSurname], '') AS [Surname], ISNULL(A.[strSurname], '') + ': ' + ISNULL(A.[strForename], '') AS [SurveyorName], ISNULL(Y.[SurveyedSpanCount], 0) AS [SurveyedSpanCount], ISNULL(Y.[SurveyedSpanClear], 0) AS [SurveyedSpanClear], ISNULL(Y.[SurveyedSpanNotClear], 0) AS [SurveyedSpanNotClear], ISNULL(Z.[ToBeSurveyedSpanCount], 0) AS [ToBeSurveyedCount], ISNULL(X.[AllocatedSpanCount], 0) AS [AllocatedSpanCount]FROM [tblStaff] A LEFT OUTER JOIN (SELECT B.[SurveyorID], ISNULL(COUNT(A.[SurveyedPoleID]), 0) AS [AllocatedSpanCount] FROM [UT_Surveyed_pole] A INNER JOIN [UT_Survey] B ON A.[SurveyID] = B.[SurveyID] INNER JOIN [UT_Pole] C ON A.[PoleID] = C.[PoleID] INNER JOIN [UT_Circuit] D ON C.[CircuitID] = D.[CircuitID] WHERE B.[SurveyDate] >= @StartDate AND B.[SurveyDate] <= @EndDate AND (@CircuitFilter = '' OR C.[CircuitID] IN (SELECT [splitstring] FROM dbo.udf_parse_string_into_integer_table(@CircuitFilter))) AND (@VoltageFilter = '' OR D.[VoltageID] IN (SELECT [splitstring] FROM dbo.udf_parse_string_into_integer_table(@VoltageFilter))) GROUP BY B.[SurveyorID]) X ON A.[intStaffID] = X.[SurveyorID] LEFT OUTER JOIN (SELECT B.[SurveyorID], ISNULL(COUNT(A.[SurveyedPoleID]), 0) AS [SurveyedSpanCount], ISNULL(SUM(CASE ISNULL(A.[IsSpanClear], 0) WHEN 1 THEN 1 ELSE 0 END), 0) AS [SurveyedSpanClear], ISNULL(SUM(CASE ISNULL(A.[IsSpanClear], 0) WHEN 0 THEN 1 ELSE 0 END), 0) AS [SurveyedSpanNotClear] FROM [UT_Surveyed_pole] A INNER JOIN [UT_Survey] B ON A.[SurveyID] = B.[SurveyID] INNER JOIN [UT_Pole] C ON A.[PoleID] = C.[PoleID] INNER JOIN [UT_Circuit] D ON C.[CircuitID] = D.[CircuitID] WHERE B.[SurveyDate] >= @StartDate AND B.[SurveyDate] <= @EndDate AND ISNULL(A.[SurveyStatusID], 0) > 0 AND (@CircuitFilter = '' OR C.[CircuitID] IN (SELECT [splitstring] FROM dbo.udf_parse_string_into_integer_table(@CircuitFilter))) AND (@VoltageFilter = '' OR D.[VoltageID] IN (SELECT [splitstring] FROM dbo.udf_parse_string_into_integer_table(@VoltageFilter))) GROUP BY B.[SurveyorID]) Y ON A.[intStaffID] = Y.[SurveyorID] LEFT OUTER JOIN (SELECT B.[SurveyorID], ISNULL(COUNT(A.[SurveyedPoleID]), 0) AS [ToBeSurveyedSpanCount] FROM [UT_Surveyed_pole] A INNER JOIN [UT_Survey] B ON A.[SurveyID] = B.[SurveyID] INNER JOIN [UT_Pole] C ON A.[PoleID] = C.[PoleID] INNER JOIN [UT_Circuit] D ON C.[CircuitID] = D.[CircuitID] WHERE B.[SurveyDate] >= @StartDate AND B.[SurveyDate] <= @EndDate AND ISNULL(A.[SurveyStatusID], 0) = 0 AND (@CircuitFilter = '' OR C.[CircuitID] IN (SELECT [splitstring] FROM dbo.udf_parse_string_into_integer_table(@CircuitFilter))) AND (@VoltageFilter = '' OR D.[VoltageID] IN (SELECT [splitstring] FROM dbo.udf_parse_string_into_integer_table(@VoltageFilter))) GROUP BY B.[SurveyorID]) Z ON A.[intStaffID] = Z.[SurveyorID]WHERE (@SurveyorFilter = '' OR A.[intStaffID] IN (SELECT [splitstring] FROM dbo.udf_parse_string_into_integer_table(@SurveyorFilter))) AND ISNULL(A.[IsUtilityArbSurveyor], 0) = 1ORDER BY [Surname] ASC, [Forename] ASC

variable product costing

Posted: 10 Sep 2013 10:41 PM PDT

Not sure how to explain this but here goes...I have a forecast of volume for a product for the year. A product costing can change through the year.I need to calculate a forecast value based on a costing table.so something like...[code]SELECT fcast.Year, fcast.Customer, fcast.StockCode, fcast.Type, fcast.Measure, fcast.MonthNo, fcast.Volume, cost.CostFROM #forecast_unpivot fcastLEFT JOIN( SELECT Customer, StockCode, Year, MonthNo, Cost FROM #costing) costON fcast.Year= cost.YearAND fcast.Customer = cost.CustomerAND fcast.StockCode = cost.StockCodeAND fcast.Year = cost.YearAND fcast.MonthNo = cost.MonthNo[/code]but i only get cost matches on the exact month (i've attached the results in a text file (sqcl.txt), so the NULLS need to be the previous costing)i need to get jan cost to appear in feb then when the cost change in mar apply the new cost to all future months.if i use >= on month i get duplication.thanks** edit - i've add the full sql code, creates tables (temp), data etc. (full_sql.txt)*** edit - i've added another text file (monthNm_to_monthNo.txt) which is a function to convert date name to date number

IF EXISTS ( SELECT 1 ......vs..... IF EXISTS ( SELECT *

Posted: 10 Sep 2013 06:59 PM PDT

Hi,is there a difference in terms of performance?. The execution plans are identical. Does an index on or off, an index be used? Is there a rule what syntax should be used when?RegardsNicole ;-)--------------------------------- IF EXISTS ( SELECT * FROM Northwind.dbo.Customers WHERE CustomerID = 'ALFKI' ) PRINT '1' ELSE PRINT '0'--------------------------------- IF EXISTS ( SELECT 1 FROM Northwind.dbo.Customers WHERE CustomerID = 'ALFKI' ) PRINT '1' ELSE PRINT '0'--------------------------------- IF EXISTS ( SELECT COUNT(1) FROM Northwind.dbo.Customers WHERE CustomerID = 'ALFKI' ) PRINT '1' ELSE PRINT '0'--------------------------------- IF EXISTS ( SELECT TOP(1) CustomerID FROM Northwind.dbo.Customers WHERE CustomerID = 'ALFKI' ) PRINT '1' ELSE PRINT '0'

Geography, find the common most point from 4 Lat/Long points

Posted: 10 Sep 2013 05:48 AM PDT

I am trying to create a Function that I can pass 4 data points (Lat/Long) to and have it calculate the center-most point (lat/long). I thought of using a Polygon and using the EnvelopeCenter function, but I cannot control what order the data points are entered. The field techs make four readings and then upload the results. They take the readings from the same point. My sample DB is rough, but hopefully enough to give you an idea of what I am working with. I am new to the Geography data type. --Creating table to hold spatial dataCREATE TABLE dbo.StreetSignSpaital ( ID uniqueidentifier NOT NULL DEFAULT(NEWID()) , SignUnitID varchar(25) NOT NULL , Point1 geography NULL , Point2 geography NULL , Point3 geography NULL , Point4 geography NULL)--Loading a sample record. INSERT INTO dbo.StreetSignSpatial( SignUnitID , Point1 , Point2 , Point3 , Point4 )SELECT 'E004010038DBE180' , geography::STGeomFromText( 'POINT(-122.561536 45.603118166)', 4326) , geography::STGeomFromText( 'POINT(-122.5615208333 45.6031455)', 4326) , geography::STGeomFromText( 'POINT(-122.56151366666 45.603131666)', 4326) , geography::STGeomFromText( 'POINT(-122.56154616666 45.603134333)', 4326)I did come across something on a Google search that I could simply take the aggregate of the Lat values and the Long values and that would be the common point, but that seems WAY too simple. Hope someone can help and thank you for looking.JJ

joining tables

Posted: 10 Sep 2013 07:24 AM PDT

hello all, Here's what I got:Table 1 structure:Id int,controlID varchar(13)data:1,10002,10013,10024,10035,1004And so ontable 2:id int,controlstart varchar(13),controlend varchar(13),box intdata:1,1000,1001,12,1002,1003,23,1004,1005,3and so onHow would I write a query to join the 2 tables that would display info like this:1000,11001,11002,21003,21004,31005,3Thanks for all the help!

view points to linked server tables

Posted: 10 Sep 2013 06:32 AM PDT

Our lead wants me to maintain two different version of VIEWfor DEV and PROD.We're building custom reports for Financial Application systemand we're not allowed to query PROD Db directly, only through views.In DEV it is "SELECT * FROM EU1_Transform.dbo.MapGLAccount INNER JOIN EU1_Transform.dbo.iScalaCompanies ...."In PROD he wants me to have this:"SELECT * FROM LINKEDSERVER.dbo.EU1_Transform.dbo.MapGLAccount INNER JOIN LINKEDSERVER.EU1_Transform.dbo.iScalaCompanies ...."I'm not sure inner joins work the same way with linked server.I mean will the right INDEXES be used and so on?Is it a good idea?

[SQL Server 2008 issues] SSIS Package runs as a package but won't run in job scheduler

[SQL Server 2008 issues] SSIS Package runs as a package but won't run in job scheduler


SSIS Package runs as a package but won't run in job scheduler

Posted: 10 Sep 2013 10:07 AM PDT

I have a package that will not complete in the job scheduler, runs fine as a package. Part of the process was to delete a file on our network using the File System Task Editor delete file and when the job runs in the scheduler I get an error saying that the server does not have permissions. It runs fine from the server when I run the package.I changed it to rename the file instead of deleting it and now it says it can not find the file to rename it when I run it in the scheduler.I am at a total loss and am very new to doing all of this. Any help would be greatly appreciated as I am supposed to go on vacation in a week and a half and need for these to be running while I am gone. :-)

Simple Transpose - why can't I do it??

Posted: 10 Sep 2013 01:37 PM PDT

Guri (is that the plural of Guru?)I have a result set that I need to present in a graph:Results: Category PrevWk2 PrevWk1 CurrWkBlueStore 1.5 3 8.25RedStore 4.5 4.5 15.5and I need it to be:Week: BlueStore RedStorePrevWk2 1.5 4.5PrevWk1 3 4.5CurrWk 8.25 15.5 for the SSRS Graph, so that the X axis will be the weeks and the series will be the Red & Blue values...I have looked at the PIVOT and Case examples and I still can't get it to work.Can anyone help a brother out?(Feeling a bit daft!!) Cheers,David

Fillfactor Property not saving

Posted: 10 Sep 2013 11:17 AM PDT

Hi ,Some how SSMS Index Fillfactor Property is not saving Fillfactor settings.We have SQL server 2008 R2 .I checked server property ->Database Settings it is set to 0 or 100%.But when i go to table->index property it shows 70 %.I changed to 100,then went back to index property and it is back to 70.Any idea why SSMS is not saving changes?

unable to run power shell script from SQL server agen

Posted: 10 Sep 2013 06:39 AM PDT

hello,i created this power shell script to retun SQL server configurationsconfiguration, the script works fine when I run it from Powershell ISE, however it fails when i schedule it to run as power shell step in sql agent as ajob, it gives me syntax error, any ideas what I'm doing wrong?, i read some articles about assigning the get-date to a variable, i tried it without any lock Import-Module SQLPS -DisableNameChecking #One way to map New-PSDrive -Name UNCPath -PSProvider FileSystem -Root \\Share\Servers\foreach ($instancename in get-content -path UNCPath:\Servers.txt) { $Date =Get-date -Format "yyyy-m-d_hmmtt" $folder= "UNCPath:\servers" $filename = "$($instanceName)_Configuration_$($Date).csv" $fullpath =Join-Path $folder $filename $server = New-Object 'Microsoft.SqlServer.Management.Smo.Server' -ArgumentList $instanceName$server.Configuration.Properties | Export-Csv -Path $fullpath } remove-psdrive -name UNCPath

New query in project sometimes prompts for connection--other times not

Posted: 10 Sep 2013 01:42 AM PDT

I'm using SSMS 2008 R2 connected to the same version database on two different machines. On both machines, I did this:1. Connected to the server2. No query windows are open3. Created a project4. Right-clicked on the Queries folder in Solution Explorer and selected "New Query."On one machine, I am immediately prompted for a connection. On the other, I am not. How is this controlled? How can I change one machine to behave like the other in this respect?Thanks!

SSIS to download .txt file from URL and import data in SQL Server table

Posted: 10 Sep 2013 04:18 AM PDT

There is a text file placed on a URL lets say http://mysubsite.domain.com/Customers.txtThis text file has \t \Column1 \t \Coilumn2 and so on then to have new line data for column1 and then Column2 with n rowsI have to pull this list of customers in existing customer table. if this customer already exists then do nothing if this customer is not in list then add in Customer table. I need some guidance if this could be done through SSIS, if yes then how? I have no idea how to implement this in SSIS. I was trying to write a win32 service in c# to download text file locally and then run BCP to export data in a temp file then call SP to see if the customer is updated then update else if not found then add in Customer table. I am not sure if this could be done through SSIS and if yes i hope it would be fast and quick to implement, if someone already worked on it. What is the best option to choose, I need to know what is the best solution and how it could be done if possible in SSIS? I need to do this on daily bases to get text file up to date with my Customer table.Shamshad Ali

Index rebuild Maintenance Plan may not be running properly

Posted: 09 Sep 2013 09:44 PM PDT

HiI have 2 jobs from a maintenance plan and 1 backup job from sqlbackup (redgate). The job are scheduled as follows:Sunday 23:00Hrs - The Rebuild indexs on all user databasesSunday 23:15Hrs - The system databases Integrity checkSunday 23:15Hrs - The sqlbackup job of all system db'sI have noticed that the 1st job to rebuild all user database indexes is running in less than 1 minute and I am thinking this should probably take longer. The job succeeds but when I look in the log file for the job history I see something like this:[quote]Source: Rebuild Index Task Executing query "ALTER INDEX [PK_ABC_XXX...".: 8% complete End Progress Progress: 2013-09-08 23:00:14.91 Source: Rebuild Index Task Executing query "USE [ABC] ".: 8% complete End Progress Progress: 2013-09-08 23:00:14.92 Source: Rebuild Index -[/quote]Because I am not seeing 100% and only 8% complete does this mean the alter index statement is not completing the index rebuild task fully ? I was thinking this may be the case as either the the backup job somehow interferes with the 23:00hr job ?Any ideas on as to why the index rebuild task runs so quickly ?

Logshipping - SQL server 2008 R2

Posted: 10 Sep 2013 01:37 AM PDT

Recently logshipping is configured on one of the sql instances in our environment between two different sql isntances. Everthing looks good other than primary server Lsalert job. It keeps failing on the primary instance. When I verify the log shipping tables on the primary sql instance the Secondary name was updated wrongly. that means seconday server name is udpated as primary server. it' causing this problem. both sql instance are newly built.Does anybody had/heard this issue before?Thanks.

Error DTExec: The package execution returned DTSER_FAILURE (1)

Posted: 09 Sep 2013 09:45 PM PDT

Hi,A Maintenance Plan Job for UpdateStatistics is scheduled from SQL Server 2008 and it is a weekly job (Sunday). Last Sunday it failed with the below error. Can some body help me to fix the issue.Error:Executed as user: ABC\XXX. Microsoft (R) SQL Server Execute Package Utility Version 10.50.1600.1 for 64-bit Copyright (C) Microsoft Corporation 2010. All rights reserved. Started: 6:00:02 AM Progress: 2013-09-08 06:00:11.52 Source: {9B20A854-9645-4762-B4C7-8B5DA1A19210} Executing query "DECLARE @Guid UNIQUEIDENTIFIER EXECUTE msdb..sp...".: 100% complete End Progress Error: 2013-09-08 06:22:09.05 Code: 0xC0024104 Source: Update Statistics Description: The Execute method on the task returned error code 0x80131501 (An exception occurred while executing a Transact-SQL statement or batch.). The Execute method must succeed, and indicate the result using an "out" parameter. End Error DTExec: The package execution returned DTSER_FAILURE (1). Started: 6:00:02 AM Finished: 6:22:09 AM Elapsed: 1327.41 seconds. The package execution failed. The step failed.Thanks in advanceTapas

Table name by a value

Posted: 09 Sep 2013 08:56 PM PDT

How to know a Table name by a value?plz help me

How to insert Parent node text if child node is avilable?

Posted: 09 Sep 2013 08:07 PM PDT

Hi,I have an XML that I need to output somewhat differently, for reference: <?xml version="1.0"encoding="UTF-8"standalone="true"?> <Computer > <OS Name="Microsoft Windows 7 Ultimate" ServicePack="1"/>OS - Category, Namem, Service Pack - Property, <HardDisks> HardDisks - Category, Value - Save as Name in the Property table <HardDisk Value="C:\ (NTFS)"/> </HardDisks> <LocalGroups> <Group Name="Administrators"> LocalGroups - Category, Name - Property <Member Name="Administrator"/> Member - Category, Administrator, whargrove - Property, Administrators - Parent <Member Name="whargrove"/> </Group> <Group Name="Backup Operators"> </Group> <Group Name="Guests"> <Member Name="Guest"/> </Group> <Group Name="IIS_IUSRS"> LocalGroups - Category, IIS_USERS - Property <Member Name="IUSR"/> LocalGroups - Member, IUSER - Property, IIS_USERS - Parent </Group> <Group Name="boinc_projects"> </Group> </LocalGroups> </Computer>Need to insert data like below into my table from above xml. Here is a one special case i.e If the node contains child node need to insert parent node as parent in the table Parent column if child not exist need to insert NULL. [code="sql"] Category Property Value Parent OS Name WH& NULL HardDisks Null Null Null HardDisk Value C:\ (NTFS) HardDisks LocalGroups Null Null Null Group Name Administrators LocalGroups Member Aministrator Null LocalGroups Member whargrove Null LocalGroups[/code]My query is below:[code="sql"]insert into AssetProperty (Category, Property, Value, Parent) select T.C.value('local-name(.)', 'nvarchar(max)') as Category, A.C.value('local-name(.)', 'nvarchar(max)') as Property, A.C.value('.', 'nvarchar(max)') as Value, T.C.value('local-name(.)', 'varchar(max)') as Parent from @XMLdata.nodes('Computer//*') as T(C) outer apply T.C.nodes('./@*') as A(C)[/code]Any solution for this?

SQL failover cluster - prestaging objects in AD

Posted: 09 Sep 2013 07:51 PM PDT

Hi all,What I'm looking for is a succint summary of what needs to be created & what permissions granted in AD to facilitate a failover cluster install in a low permission environment (ie. where SQL can't create these objects itself). I have an idea of what needs to be created and granted, but want to make sure that it covers everything without granting too much :-Dnb. I am a SQL person not an AD person - I have had a look at the MS articles on granting cluster permissions ... and am a bit lost in all the AD terminology :hehe:So here's what I have so far:Create computer object for each physical node in AD & the Cluster name (I understand this is done by the Windows clustering)Create MSDTC object in AD (not sure where this gets done?)Create Virtual SQL Name object in AD Grant full control of this to the following: Cluster computer object Each physical node's computer object

Tuesday, September 10, 2013

[SQL Server] Login creation failed

[SQL Server] Login creation failed


Login creation failed

Posted: 25 Jul 2013 08:38 PM PDT

Hello Master,My client created a local non domain windows account and now they want me to add that acount on SQL Server and want sysadmin rights. My SQL Server is in domain on that machine. While creating user, I am able to search that account (As it is local machine account) but I am not able to create login for the same. I got an error : "Error 15401: Windows NT user or group '%s' not found".Is it necessary that new login should be in domain ? OR how can I create login for Nondomain(local account) account ?

Alternative to Cursor

Posted: 10 Sep 2013 09:02 AM PDT

I am looking for a way to call a stored procedure for each record of a select statement.I have read that Cursor is a bad idea to do so... Then How should I call the store procedure to display each record without passing any parameters.

SSMA Migration

Posted: 10 Sep 2013 12:06 AM PDT

I am trying to use the SSMA to migrate my tables from Access 2007 to SQL server 2012. Is there a literal step by step process to migrate my tables from start to finish that I can follow?

Search This Blog