Quantcast
Channel: SQLServerCentral » SQL Server 2008 » SQL Server 2008 - General » Latest topics
Viewing all 16406 articles
Browse latest View live

With recompile in the master stored proc

$
0
0
Dear all,If I have a procedure like:sp_1 (@par1, @par2)ASbeginexec sp2exec sp3endif I add the expression "with recompile" on the master SP, all the sps that run inside it will also use recompile ? or I have to add it for each procedure ?thanks

SQL Cluster Migration

$
0
0
Hi there,I have the task of migrating two 2-node SQL 2008 R2 clusters on to new hardware. Currently the plan is to create new clusters from scratch, script all the logins, jobs, linked servers etc. and then just restore all the databases onto it. Finally I will alter the DNS name of the cluster to be the same as the existing one so I don't have to modify all the applications.This will probably be fairly time consuming as there are a large number of databases on the servers.Is this the best way to do it or could someone suggest a easier method?! ....or do I just need to stop whinging and get on with it? ;-)Thanks,Matt

SSIS Warning - Global Shared Memory

$
0
0
HiI'm busy rewriting DTS packages as SSIS packages. As and when I finish a package I run it in debug mode via Microsoft Visual Studio and then examine the Exection Results to see the messages generated.Now it may or may not matter how I run the package but the following warning has been generated :-[SSIS.Pipeline] Warning: Warning: Could not open global shared memory to communicate with performance DLL; data flow performance counters are not available. To resolve, run this package as an administrator, or on the system's console.I'm one of these people who likes to run programs and get no warnings at all (if it can be helped).Can someone kindly explain what it means and if I can can get rid of it?

Performance question for migration purpose

$
0
0
[url=http://staffmobility.eu/sites/default/files/falcons_vs_seahawks_live_stream_online_tv_coverage_nfl_2016_free_week-6.pdf] Falcons vs Seahawks Live Stream[/url]

apply, although stations are allowed to play

$
0
0
[url=http://www.colorado.edu/disabilityservices/sites/default/files/webform/fox-cowboys-vs-packers-live-stream-nfl-week-american-football-watch-16-oct-2016-tv-coverage.pdf]Cowboys vs Packers Live Streaming[/url]

DBCC Checkdb cannot exclusively lock database

$
0
0
We are running weekly DBCC CheckDB job. The error is "The database could not be exclusively locked to perform the operation". If I will set database to single user mode, I am risking that some ETL and other processes that are running at weekend will fail. They recommend to "See Books Online for details of when this behavior is expected and what workarounds exist". What workaround do you use in your environments?Thanks

Mystery Value in Variable

$
0
0
I'm trying to interpret the code of the guy who preceded me at my current position (unfortunately he's dead, so I cannot consult with him). I'm parsing out a stored procedure to track what's happening; and I'm seeing a block of code that is confusing me. The confusion stems from the variable @DataSourceJobRevenue (at least I think it's a variable). In the line that begins "SET @cmd", @DataSourceJobRevenue is being used; but I can't see where it's getting its value from. I cannot find this variable mentioned anywhere else in my database; so I'm assuming it does not have a default value.Below is the code in question. If anyone can unlock this mystery for me, it'd be much appreciated.Thank youALTER PROCEDURE [dbo].[ImportJobRevenue] @DataSourceJobRevenue AS varchar(100)ASSET NOCOUNT ONDELETE FROM JobRevenueStageDECLARE @cmd varchar(100)SET @cmd = 'BULK INSERT JobRevenueStage FROM ''' + @DataSourceJobRevenue + ''' 'EXECUTE (@cmd)

Like keyword in Left join

$
0
0
I am writing one SQL query to use like in left join. below is my query for join:left JOIN (SELECT * FROM tablename) tbl05on tbl05.[col name] LIKE '%'+ tbl01.[col name] +'%' where...-------------------------this query is giving me output but instead of 1 its giving me 2 entries in output.i want first entry as a output. max is also not working in this case.

Copy a record via trigger

$
0
0
Hey All,We're trying to copy a 'mail' record to another person while retaining the original record in the original recipient's mailbox. There is only 1 Key (the PK, or course) on the column 'ML_ID'. That's not included in the select list or insert because its a PK. The 3 in the nested select is the ID for the admin account. Now, the below DOES in fact copy the record and retains the original, but also copies all previous mails that fit the where clause parameters. For example, we have users 1 and 2, and 'mails' with an id of a, b, and c. Mail A hits user 1 and the trigger is set to send to user 2:[u]MAIL/User[/u]a 1a 2Mail B hits user 1: [u]MAIL/User[/u]a 1a 2b 1a 2b 2Mail C hits user 1: [u]MAIL/User[/u]a 1a 2b 1a 2b 2c 1a 2b 2c 2Hopefully you get the idea...Now, I thought the issue might be due to recursion, but it really doesn't seem to be triggering itself, more of just copying more than what I want it to.[i]"WITH EXECUTE AS CALLERAFTER INSERTASBEGIN IF trigger_nestlevel() > 1 RETURN INSERT INTO TRN_MAILS ( ML_SENDER_TYPE,ML_SENDER_ID,ML_SENDER_NAME,ML_RECEIVER_ID, ML_RECEIVER_NAME,ML_MAIL_TYPE,ML_PATIENT_ID,ML_ENCOUNTER_ID, ML_SEND_DATE,ML_READ_DATE,ML_MESSAGE,ML_OBJECT_ID,ML_EVENT_ID, ML_BOOL_DEL_IN,ML_BOOL_DEL_OUT,ML_SUBJECT,ML_BOOL_READ,ML_MOD_USER, ML_MOD_TIMESTAMP,ML_BOOL_ADD_PMR,ML_ACTION_ID,ML_REF_ID, ML_BOOL_OPEN,ML_REPLY_DAYS,ML_REPLY_BYDATE,ML_CLOSE_DATE, ML_BOOL_THREAD_ID,ML_PENDING,ML_PATIENT_FNAME,ML_PATIENT_LNAME, ML_BATCH_NO,ML_DEL_IN_DATE,ML_BOOL_ACCEPT,ML_ACC_DONE_ID,ML_ATTACHMENTS, ML_FWD_REPLY,ML_SEND_TZ_DATE,ML_READ_TZ_DATE )SELECT ML_SENDER_TYPE,ML_SENDER_ID,ML_SENDER_NAME,3, ML_RECEIVER_NAME,ML_MAIL_TYPE,ML_PATIENT_ID,ML_ENCOUNTER_ID, ML_SEND_DATE,ML_READ_DATE,ML_MESSAGE,ML_OBJECT_ID,ML_EVENT_ID, ML_BOOL_DEL_IN,ML_BOOL_DEL_OUT,ML_SUBJECT,ML_BOOL_READ,ML_MOD_USER, ML_MOD_TIMESTAMP,ML_BOOL_ADD_PMR,ML_ACTION_ID,ML_REF_ID, ML_BOOL_OPEN,ML_REPLY_DAYS,ML_REPLY_BYDATE,ML_CLOSE_DATE, ML_BOOL_THREAD_ID,ML_PENDING,ML_PATIENT_FNAME,ML_PATIENT_LNAME, ML_BATCH_NO,ML_DEL_IN_DATE,ML_BOOL_ACCEPT,ML_ACC_DONE_ID,ML_ATTACHMENTS, ML_FWD_REPLY,ML_SEND_TZ_DATE,ML_READ_TZ_DATEFROM TRN_MAILSWHERE ML_EVENT_ID IN (36,40,22,20,45)AND ML_RECEIVER_ID = 1448 SET NOCOUNT OFFEND"[/i]Does anyone have any insight into this? Apologies if I've not made something clear. Thanks!

Why is my Full Text Indext properties showing Unique Key Count as negative?

$
0
0
When I run this statement:-Select FULLTEXTCATALOGPROPERTY ('BlobData_Fulltext_Catalog' ,'UniqueKeyCount')UniqueKeyCountI get a result that is negative. Can anyone suggest why?

Urgent please help--Append Date(yyyymmdd format) to filename (Example: tnvin_20161019.txt)

$
0
0
Hi Everyone,I have this batch file as below. I need to update this to get the date without setting it as I have done in the second line of my code below. I want it to display automatically when I run this batch file every time. The date should be in yyyymmdd format.I tried lot of options with date parameters but couldn't get this right.Can you please help me with this..*** Batch file ********************************************set naic=1211610set filedatetime=18/10/2016 11:03set date=%filedatetime:~6,4%%filedatetime:~3,2%%filedatetime:~0,2%set filename=tnvin_%date%%naic%.txtset tnpath=C:\tnvintrailer\SQLCMD -S SQLSANDBOX -E -Q "[SouthernTrust].[dbo].[P_tntr] "bcp [St].[dbo].[TmpTNVINTRInfo] out "%tnpath%%filename%" -c -T -S SQLSANDBOXSQLCMD -S SQLSANDBOX -E -Q "DROP TABLE [St].[dbo].[TmpTNVINTRInfo]"

SQL query for different values and dif tables

$
0
0
Tbl 01 Tbl 02 CityABC 12ABC45 mumbaiXYZ 12300 chennai123 SXYZAB hydrabad456 ABC delhi789 123 jaipurin this case abc, xyz are customer idsI want to write a query which takes exact values that matches with the criteria.for e.g. if tbl01 has 123 then i want 'Hydrabad' as output. i am using like keyword in my join query which is giving me 2 output 1. Hydrabad (123) 2. Chennai as it contains 123.I need this beacuse sometime in my data i get 0 before customer id in tbl01 and it is not there in tbl02 means customer ids in tbl02 does not contain 0. and it can vise versa some time. number of 0's are also not same. sometimes there are 2 zeros some time 3so i want to write if values in both the columns (tbl 01 and tbl02) is same then it will give the desired output but if its not same then first it should match and then should give me output

Get Rows On Given Range

$
0
0
Suppose, I've two tables as follows:[code="vb"]create table #table1(name varchar(100), qty int)create table #table2 (forename varchar(100), surname varchar(100), cost int)insert into #table1 values('John',1),('Paul',2),('Ringo',1)insert into #table2 values('John' , 'Smith' , 123),('John' , 'Jones' , 815 ) ,('Paul' , 'Smith' , 273),('Paul' , 'Jones' , 297),('Ringo' , 'Smith' , 755),('Ringo' , 'Jones' , 334)[/code]So what I want to do is to return the rows for each name depending upon the Qty value. Like Paul has the Qty value 2, so the query should return two rows for Paul. And for others will get one as the Qty value is one for them.I tried the following query but gets data of Paul only:[code="vb"]SELECT m.forname, k.SurName, k.Cost FROM Sample2 mINNER JOIN [Sample] kON k.ForeName = m.fornameGROUP BY m.forname, m.Qty, k.Cost, k.id, k.SurNameHAVING m.Qty > COUNT(k.ForeName) [/code]

SP4 for SQL 2008 not running

$
0
0
Hi there,I'm hoping somebody can help me here. I'm having issues installing SP4 or SP3 on an SQL 2008 Enterprise edition installation. This SP4 is a download I have used successfully on 3 other servers. It did send an error to the event viewer that shows the following:Failed extract of third-party root list from auto update cab at: <http://www.download.windowsupdate.com/msdownload/update/v3/static/trustedr/en/authrootstl.cab> with error: A required certificate is not within its validity period when verifying against the current system clock or the timestamp in the signed file.I had the admin install Win updates (win 2008 R2 standard) including SP1 to this server as it was a few years out of date.Now the update runs but doesn't fire off the GUI install window. I did an extract of files and ran the setup manually and it does nothing. Ran in CMD prompt and get the following message but nothing else: C:\temp\setup.exeMicrosoft (R) SQL Server 2008 Setup 10.00.6000.29Copyright (c) Microsoft Corporation. All rights reserved.Nothing is going to the event log now or to any other text log file from what I can see.Any ideas anyone?ThanksPatrick

Remove almost Duplicate Records

$
0
0
I have a table where I need to be able to delete records that are almost identical however with a slight difference and the Date_Added column is what really is the trigger with keeping the newest date and not the older date. My data is below. So what I need is for 80429 and 80439 to be deleted because 89296 and 89267 are newer. Any ideas?AUTOID vendor Stock EA_UOM New_Thomas_Cost New Proposed List Price DateAdded Exported Date_Exported89296 VN000176 3319B38 EA 2.64 5.85 10/20/2016 7:42 1/1/1900 0:0089297 VN000176 3319B52 EA 4.1 9.09 10/20/2016 7:42 1/1/1900 0:0080429 VN000176 3319B38 EA 2.69 5.96 10/19/2016 15:56 1/1/1900 0:0080439 VN000176 3319B52 EA 4.2 9.3 10/19/2016 15:56 1/1/1900 0:00

Extremely slow initial connection using ssms

$
0
0
For the last week or so anytime I load ssms to connect to my sql server, the initial connect takes a very long time. Like 10-20 minutes, but once it is connected once I can connect to any other instance immediately. I can even disconnect and reconnect immediately, but if I close ssms complete, and try again, I once again wait for 10+ minutes. I can use the command line tool and connect instantly every time.I feel I have ruled out dns, and ad authentication since I have the same issue using ip or name and using sql authentication or windows authentication.I can connect instantly to the same instance from any other computer. It is only affecting my computer.SQL 2008 R2Windows 10 ProSSMS 2014I also noticed that using c# to connect to sql has the same issue from my machine. So it appears to be more than just SSMS, perhaps it has something to do with the SQL native client?Thoughts?Thanks,-Bo

Help with script

$
0
0
Hell. was wondering if you could help with a sql script Im struggling to prepare. Please see the below showing two select statements against two tables with an example product code. This is the scenario I need to identify and then correct. Both tables are product tables and link on warehouse and code. (WAREHOUSE and warehouse and SAGE_PRODUCT_CODE and product). If there is a BF and BE warehouse in stockm and a BF warehouse in fecon -- then use the BF record in fecon2 to create a matching BE record in fecon2 I need a checking script to display first and then an update script. select * from pres.scheme.stockmwhere product = 'B007386'select * from pres.scheme.fecon2where SAGE_PRODUCT_CODE = 'B007386'

Shrink database while restoring

$
0
0
Can we shrink the database files while restoring from backup?

Errors in the OLAP storage engine

$
0
0
Errors in the OLAP storage engine: The version of the linked measure group, with the name of 'CURRENCY RATE', on the remote instance has changed. Repeat the operation to resolve the issue. (Microsoft SQL Server 2008 Analysis Services)

Looking for way to dynamically replace street suffix with abbreviation based on tables

$
0
0
I'm working on creating a unique address list, but many of the duplicates come in with Street one time and ST the next. I have a street suffix table with the common suffix name and the abbreviation, along with common abbreviations that people use that are not the standard one.I'd like a select statement that grabs the first match for the last suffix in a list, so an address like 1400 Court Place only replaces Place with PL. A match on the commonly used abbreviation should also trigger a replacement. So far the closest I've come is a CROSS JOIN, but that gave me matches that are not useful. Here is the example data:[code="sql"]DROP TABLE [dbo].[StreetSuffix]CREATE TABLE [dbo].[StreetSuffix]( [StreetSuffix_pk] INT NOT NULL CONSTRAINT PK_StreetSuffix PRIMARY KEY, [PrimaryStreetSuffixName] VARCHAR(10) NOT NULL CONSTRAINT DF_StreetSuffix_PrimaryStreetSuffixName DEFAULT (''), [CommonlyUsedStreetSuffixOrAbbreviation] VARCHAR(10) NOT NULL CONSTRAINT DF_StreetSuffix_CommonlyUsedStreetSuffixOrAbbreviation DEFAULT (''), [PostalServiceStandardSuffixAbbreviation] VARCHAR(10) NOT NULL CONSTRAINT DF_StreetSuffix_PostalServiceStandardSuffixAbbreviation DEFAULT (''))TRUNCATE TABLE [dbo].[StreetSuffix];INSERT INTO [dbo].[StreetSuffix] (StreetSuffix_pk, PrimaryStreetSuffixName, CommonlyUsedStreetSuffixOrAbbreviation, PostalServiceStandardSuffixAbbreviation) VALUES (1, 'ANEX', 'ANX', 'ANX');INSERT INTO [dbo].[StreetSuffix] (StreetSuffix_pk, PrimaryStreetSuffixName, CommonlyUsedStreetSuffixOrAbbreviation, PostalServiceStandardSuffixAbbreviation) VALUES (2, 'COURT', 'COURT', 'CT');INSERT INTO [dbo].[StreetSuffix] (StreetSuffix_pk, PrimaryStreetSuffixName, CommonlyUsedStreetSuffixOrAbbreviation, PostalServiceStandardSuffixAbbreviation) VALUES (3, 'PLACE', 'PL', 'PL');INSERT INTO [dbo].[StreetSuffix] (StreetSuffix_pk, PrimaryStreetSuffixName, CommonlyUsedStreetSuffixOrAbbreviation, PostalServiceStandardSuffixAbbreviation) VALUES (4, 'AVENUE', 'AV', 'AVE');INSERT INTO [dbo].[StreetSuffix] (StreetSuffix_pk, PrimaryStreetSuffixName, CommonlyUsedStreetSuffixOrAbbreviation, PostalServiceStandardSuffixAbbreviation) VALUES (5, 'AVENUE', 'AVE', 'AVE');INSERT INTO [dbo].[StreetSuffix] (StreetSuffix_pk, PrimaryStreetSuffixName, CommonlyUsedStreetSuffixOrAbbreviation, PostalServiceStandardSuffixAbbreviation) VALUES (6, 'COURT', 'COURT', 'CT');INSERT INTO [dbo].[StreetSuffix] (StreetSuffix_pk, PrimaryStreetSuffixName, CommonlyUsedStreetSuffixOrAbbreviation, PostalServiceStandardSuffixAbbreviation) VALUES (7, 'COURT', 'CT', 'CT');INSERT INTO [dbo].[StreetSuffix] (StreetSuffix_pk, PrimaryStreetSuffixName, CommonlyUsedStreetSuffixOrAbbreviation, PostalServiceStandardSuffixAbbreviation) VALUES (8, 'STREET', 'STREET', 'ST');INSERT INTO [dbo].[StreetSuffix] (StreetSuffix_pk, PrimaryStreetSuffixName, CommonlyUsedStreetSuffixOrAbbreviation, PostalServiceStandardSuffixAbbreviation) VALUES (9, 'STREET', 'STRT', 'ST');INSERT INTO [dbo].[StreetSuffix] (StreetSuffix_pk, PrimaryStreetSuffixName, CommonlyUsedStreetSuffixOrAbbreviation, PostalServiceStandardSuffixAbbreviation) VALUES (10, 'TRACE', 'TRACE', 'TRCE');SELECT * FROM [dbo].[StreetSuffix];DROP TABLE [dbo].[Address]CREATE TABLE [dbo].[Address]( [Address_pk] INT IDENTITY(1,1) NOT NULL CONSTRAINT PK_Address PRIMARY KEY, [Address] VARCHAR(150) NOT NULL CONSTRAINT DF_Address_Address DEFAULT (''),)INSERT INTO [dbo].[Address] ([Address]) VALUES ('1756 2nd Avenue');INSERT INTO [dbo].[Address] ([Address]) VALUES ('220 East 41st Street');INSERT INTO [dbo].[Address] ([Address]) VALUES ('777 6th Avenue');INSERT INTO [dbo].[Address] ([Address]) VALUES ('1466 2nd Avenue');INSERT INTO [dbo].[Address] ([Address]) VALUES ('557 10th AV');INSERT INTO [dbo].[Address] ([Address]) VALUES ('745 7th Avenue');INSERT INTO [dbo].[Address] ([Address]) VALUES ('1200 India Street');INSERT INTO [dbo].[Address] ([Address]) VALUES ('125 3rd STRT');INSERT INTO [dbo].[Address] ([Address]) VALUES ('1201 G Street NW');INSERT INTO [dbo].[Address] ([Address]) VALUES ('1400 Court Place');SELECT [Address_pk], [Address], REPLACE([Address],ss.[PrimaryStreetSuffixName],ss.[PostalServiceStandardSuffixAbbreviation]) AS [AddressAbbreviated]FROM [dbo].[Address] CROSS APPLY [dbo].[StreetSuffix] ssORDER BY [Address_pk];SELECT [Address_pk], [Address], REPLACE([Address],ss.[PrimaryStreetSuffixName],ss.[PostalServiceStandardSuffixAbbreviation]) AS [AddressAbbreviated]FROM [dbo].[Address] CROSS JOIN [dbo].[StreetSuffix] ssORDER BY [Address_pk];[/code]
Viewing all 16406 articles
Browse latest View live