Quantcast
Channel: Forum Getting started with SQL Server
Viewing all 6989 articles
Browse latest View live

Full Text Index with docx and xlsx is not working

$
0
0

Hi,

I am Having a sql server 2012.In My DB, I have one table. In this table, having one colum Document and its datatype is

Image data type. I have created a fulltextindex on this table.If i searching a word in .doc, it will give a result.But if i search a word in .docx,It wont give any result.Why it is not working?Please give me a good installation.

Regards,

Dileep


SQL server password policy

$
0
0

In SQL server 2005 and 2008, is there a TSQL query to show for all sql authentication accounts, whether they are subject to password complexity and/or password expirty policies?

Is the password complexity policy a feature with MSSQL itself, or is it linking to the password policy on the operating system?

guest account

$
0
0
Is there anyway to query via TSQL, to list all databases in a SQL instance (2000, 2005 and 2008) to list if the guest account has access to the database?

SELECT top two longest running steps from a log file

$
0
0

Simplified example.

Our jobs write records to our own internal log file. I want to write a query that will pull log records for a specific job, between specific dates. This will help determine if the job is running slower than usual and to find the steps within the job that are the longest running.

Jobs are identified by the Type field. Type=1 is a specific job name.

Each job writes a DESC=START record to the log at the beginning of the job. the Desc=START record will be updated at the end of the job with the ENDDT.

I want to pull the top two longest running steps (ENDDT-BEGINDT) for each job (Type) where the step startdr and enddt falls between the START startDT and end dt.

I also want to always pull key step names, like DESC=START and DESC=xya for each job.

LOG RECORDS

DESC,TYPE,BEGINDT,ENDDT
START,1,2014-10-22 07:56:56.000,2014-10-22 09:56:56.000
aaa,1,2014-10-22 07:57:56.000,2014-10-22 08:57:56.000
bbb,1,2014-10-22 08:57:56.000,2014-10-22 09:01:56.000
ccc,1,2014-10-22 09:01:56.000,2014-10-22 09:56:56.000
xya,1,2014-10-22 09:55:56.000,2014-10-22 09:56:56.000
START,1,2014-10-21 11:56:56.000,2014-10-22 02:56:56.000
aaa,1,2014-10-21 11:57:56.000,2014-10-22 01:57:56.000
bbb,1,2014-10-22 01:57:56.000,2014-10-22 02:56:56.000
ccc,1,2014-10-22 02:56:56.000,2014-10-22 02:56:56.000
xya,1,2014-10-22 09:55:56.000,2014-10-22 09:56:56.000


Desired result set.

If pulling job type 1 records for last 2 days, would end up with this result set. START and xya are always pulled and then the top 2 longest running steps for each of the START records.

DESC,TYPE,BEGINDT,ENDDT,Duration
START,1,2014-10-22 07:56:56.000,2014-10-22 09:56:56.000
aaa,1,2014-10-22 07:57:56.000,2014-10-22 08:57:56.000
ccc,1,2014-10-22 09:01:56.000,2014-10-22 09:56:56.000
xya,1,2014-10-22 09:01:56.000,2014-10-22 09:56:56.000
START,1,2014-10-21 11:56:56.000,2014-10-22 02:56:56.000
aaa,1,2014-10-21 11:57:56.000,2014-10-22 01:57:56.000
bbb,1,2014-10-22 01:57:56.000,2014-10-22 02:56:56.000
xya,1,2014-10-22 09:55:56.000,2014-10-22 09:56:56.000

I am asking for help in how to create this query. Thanks

manage historical data that will be used in grouping by webforms/reports?

$
0
0

Our system receives transactions in a per-minute basis, and each transaction is stored in aRaw Data table that's exclusively for this. All reports, gridview webforms, etc come from tables that are derived from this master table.

In this case I can't group the data during run-time due to the volume of data. So for tasks like the daily summary, should I just have a job that runs once daily and groups all the data from the current day and inserts it into a historical daily table? The same thing with the weekly?

I considered using BIDS and creating a cube, but due to the presentation of the data, it was beginning to look more complex. In other words, in order to show the desired result in a grid (plus include filters), I would need to use tons of MDX, which I still don't master.

Thanks.


VM

New to MSSQL - need help with a query to remove spaces within a field

$
0
0

After data conversion the leading and trailing spaces were removed from the data in the "tag" column.  However spaces in the middle of the column were not removed.  Tag data must be unique.  When I run an update script I get the message that "Cannot insert duplicate key in object 'mytablename'.   This tells me that my data looks like this:

AAAAA[space][space]BBBBB --unique tag

AAAAA[space]BBBBB -- unique tag

If I remove the spaces from each I will have duplicates.  Therefore I'd like to update the records as follows:

AAAAABBBBB --unique tag

DUP-AAAAABBBBB -- unique tag

How can I write a script that not only removes the spaces but also identifies the duplicate record?

With nolock is recomended

$
0
0

Hello

With(nolock) si recomendated with a database OLTP.


sqlquery to get all cases in a child table

$
0
0

I have to tables - demographics and PatSubs.  Both tables are linked by caseno filed.

Now, PatSubs may have one or many substance entry for the caseno.

If I do the following:

USE [njpies2013]

GO

SELECT [CaseNumber]

     ,[CenterCode]

     ,[YearCode]

      ,[SubVerbatim]

     

 FROM [dbo].[ToxExpSub]

   where SubPoisindexCode = 6931087

GO

I will only get the cases in PatSub that match =693107; however what I want is if there's a record with PoisendexCode 6931087 than give me all the entries in PatSub for THAT caseno

Please help me with this query,

Thanks

Raul


Raul Rego


Entity Framework and Package Manager Publishing to Azure

$
0
0

I am creating a secure ASP.NET MVC 5 app and need to update the database in the Package Manager Console. There is an error that occurs every time I try to update the database. Following the instructions on this page http://azure.microsoft.com/en-us/documentation/articles/web-sites-dotnet-deploy-aspnet-mvc-app-membership-oauth-sql-database/

I get the following error:

PM> update-database
Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
System.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 50 - Local Database Runtime error occurred. Error occurred during LocalDB instance startup: unable to create the SQL Server process.
)

I have ensured that the Azure SQL has the firewall rule to allow my IP address access. Any advice would be appreciated. 

sql server access

$
0
0
after downloading sql server several times I can't see the basic database engine loaded

Memory utilization was very high

$
0
0
Hi All

Memory utilization was very high 
RAM Was 18GB.
SQL SERVER.exe was utiling around 16GB 

Kindly suggest me how can we bring down memory utilization.
(we are not utilizing mirroring and Logshipping)

Regards
subu

subu

Export data using stored procedure to excel

$
0
0

How to export and save data from SQL Server to MS Excel using stored procedure.

Thanks in advance


Abhinav

Querying distinct

$
0
0

I am trying to execute a simple distinct query (i.e. select distinct name from tags), but the query is still returning duplicate names. 

Is there something else, am I suppose to add to the distinct query to make, the query return unique names from the 'tags' table. 

Please advice further.  Many thanks

Converting non atomic values into atomic

$
0
0

Hi everyone,

Assume that we have a table in the below shown way.

col1col2

1db2,sqlserver,oracle

2sybase,sqlite,teradata

3informix,postgrel,derby

col2 in the above table has non atomic values ryt.

Is there any way to cut the values into pieces while retrieving. 

eg:  db2sqlserveroracle

       sybasesqliteteradata 


Thanks and Regards, Readers please vote for my posts if the questions i asked are helpful.

Incorrect syntax near the keyword 'Values'

$
0
0

Hi all I was wondering if you could help I keep getting this error when I try to build this stored procedure in sql 2008

CREATE PROCEDURE dbo.TutorialAddHeadline
	@title varchar(100), @content varchar(MAX), @publisher varchar(50), @linkurl varchar(255)
AS
	BEGIN
	DECLARE @hash binary(16);
	SET @hash = dbo.TutorialHash(@title, @content);

VALUES(@publisher, @title, @content, @linkurl, @hash);
END

thanks


WMI query problem

$
0
0

I'm trying to run the following wmi query:

select ProcessId,Name,PageFileUsage from Win32_Process where ((Name = 'sqlservr.exe' AND CommandLine LIKE '%-sMSSQLSERVER%'))

I can do this with a local admin account, but not with the non-admin account I created.  If I remover the 'CommandLine Like' part of the query it runs fine.  This account is set up to run WMI queries and pulls everything else I need so far except this query which lets me see into my SQL Server instances.

Any ideas or suggestions are appreciated. 

Table Designer & computed colums & case statement

$
0
0
 

i am creating a table using table designer and i want to add a computed column for Age as follows:

CASE WHEN BirtheDate IS NULL THEN NULL
  WHEN DATEDIFF(yy,BirthDate, CURRENT_TIMESTAMP) >50 THEN 'OLDER'
  WHEN DATEDIFF (yy, BirthDate, Current_Timestamp)>40 then 'middle age' 
  else 'younger'

END

however, whenever i type this code i get an error. is there something that i should change to get it work?

is it possible to use case in table designer for a computed field?

Any answers i would be grateful.

thanks


sukai

which index will it take and why ?

$
0
0

Hi, 

I have a table Employee and i have an index on EmpID on this table. Now i have created a view EmpView on this table. I have created an index on this view for the same column EmpID.

Now my question is If i query select * from Empview where empId = something then which index will it consider and why?? 

Thanks in advance

Balaji 


Balaji - BI Developer

BCP Utility Comma

$
0
0
I have the following problem. I need to create a .csv file with SQL (with the bcp utility). I can create this .csv file and the following data is inserted:
1","ad","dsa","333","","2","0","","","","""

I want to avoid this double quotes. I want only double quotes if there is a comma in one field. For better understanding, the following 3 cases must be done.

Fields containin commas can be surounded by quotation marks, these must be double quotation marks (“ ”) and not single (‘ ’) e.g.

“a, b, c” would be accepted as 1 single field but a, b, c would be 3 separate fields.

In adition, any double quotation marks which need to be displayed in a field must also be surounded by double quotation marks e.g.

If an address should display as “The Street”, this should be sent as ““The Street””

Apostrophes can be sent in the file e.g.
A client with surname O’Clay and forename Jenny with a free text field holding “comma, example” would be sent in the file as O’Clay,Jenny,”comma,example”.


This is my code:
bcp TESTPROJECT.dbo.table out c:\aa.txt -c -t"\",\"" -r"\"\n\"" -S .\sql2014 -U username -P password

So the problem is in the -t"\",\"" -r"\"\n\"" part but how I can do this?

How to update Junction Table

$
0
0

I have trigger setup on the sql server end, which inserts data into the tables products and prices, however my junction table 'Product_Prices', is not automatically updating with the records, when the trigger is executed. 

Here is my database table schema:

Products
(
Product_id [pk]
Product
type
UploadDate
)Prices
(
Price_id [pk]
price
uploadDate
)Product_Prices
(
Product_id REFERENCE Products (Product_id)
price_id REFERENCE prices (price_id)
Foiergn KEY (Product_id, price_id)
Note
)

Is my structure incorrect or am I missing something?

Please advice. 

Many thanks for your time and help. 

Viewing all 6989 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>