.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

how to store query string in sql server 2005

Posted By:      Posted Date: October 20, 2010    Points: 0   Category :ASP.Net

Hi all,


how to store query string in sql server 20005 

View Complete Post

More Related Resource Links

Store Null Data In image datatype in sql server 2005



i wanted to store image in sqlserver database image field and i did. But now in some cases i want to store null value in that image field please let me know how to do this using file uploader.please give complete sample code.


Sql Server 2005 ( remove header information from query output file "Job 'bustd_Daily_Query_Output_1

Dear All,I have scheduled job for querying output & asve it into particuler folder....but in the top of file i getting the message like "Job 'bustd_Daily_Query_Output_13July09' : Step 1, 'Query1' : Began Executing 2009-07-13 16:32:06"I want to remove this & want output in txt file format without above header....RegardsRavendra Cindia

How to query the Active directory using SQL Server 2005

Hi, I am trying to query Active server from Sql Server 2005 and getting error I used following script to create link server EXEC sp_addlinkedserver 'ADSI3', 'Active Directory Services 111', 'ADSDSOObject', 'adsdatasource' and then trying to connect using following statement SELECT   * FROM OpenQuery(ADSI, 'SELECT * FROM ''LDAP://DC=local.mycompany.ca'' WHERE objectCategory=''User'' ') and getting following error An error occurred while preparing the query "SELECT * FROM 'LDAP://DC=local.resound.ca' WHERE objectCategory='User' " for execution against OLE DB provider "ADSDSOObject" for linked server "ADSI". Please let me know if you know How to query the Active directory using SQL Server 2005 Thanks, Raj    Dreaming a world without any war in anywhere

Decrypt the encrypted store procedure through the T-SQL programming in SQL Server 2005


HI ,


I have a encrypted store procedure in my production server .Right now I do not have the script now I want do some modification.

Please any one can help me to decrypt the store procedure it will be a great help for me.


For any suggestion thanks  in advance.

" Education is the beginning of transformation. Dedicate yourself to daily learning via Blogs/Forums/books and coaching "
Click here to read my blog

Tracing of query in sql server 2005

hi friends,

Is it possible that while a query is running in sql server 2005 but cann't be possible to trace it in profiler or in activity monitor.

Thanks in Advance

slective order by in sql server 2005 query

except ascending or decending can we define our own choice of order by, like if i set order by hour it display 0(zero) first, but if time start form 1800 then how to display 18 first then 19 then 20 then so on to 5am can any body help in sql 2005 server

select query sql server 2005


i have three table

1)    tbl_pages              primary key column is  (intPk_PageID)

2)   tbl_pagecontents   foreign key colum (intPk_PageContentID) reference with tbl_pages

3)   tbl_banners           foreign key colum  (intFk_pageid) reference with tbl_pages

select * from tbl_pages
intPk_PageID   vcr_PageTitle    vcr_PageUrl         int_PageStatus
1                      Contact Us          contactus.aspx             1
2                      News                   news.aspx       

Using connection string instead of datasource in report server 2005



I am using a datasource in the report server where all the reports use that shared datasource while calling the reports from asp.net pages.

Now, as asp.net pages uses the connection string for the databases which is assigned in the web.config file, i want the reports also use the same connection string because you don't need to change on both places( web.config and report server datasource).

Any idea plz

i am working on VS2005 and ssrs 2005


Do not feel regret.... just try to improve..... its far better

SQL Server 2005 store procedure performance issue


We are calling store procedure from vb.net client following are the observation.

1) sqlserver 2005  takes huge amount of time (more than 1 hour) to execute procedure. The procedure has select statement using join statement. (Generally this procedure executes and populate data in 5 seconds when it is called from .net client.)

2) If same procedure is executed from sql server management studio, procedure executes and populate data in 5 seconds (works as per expectation)

3) If we recompile procedure (i.e. open procedure in alter mode in management studio and click on execute button) ,  the procedure executes and populate data as per expectation.

4) This is intermittent issue on production machine. Most of the time procedure is executed and populate data as per expectation when called from vb.net client. But it does not give expected outout in some scenario. The frequency for occurring the issue is  once in 15 days and there is no pattern in which the issue is occurring.


Can any one help to resolve the issue.


Thanks in advance!!!




split string sql server 2005



I have a table called SubjectRank that provides subject and it's ranking.

I have a string that can be in any format. It can be 'hello cat, how -are you lion?' or 'yes horse'. In short it can be received in any manner and i have no control on how user sends the string.

What I need to do is check if the string contains any words in the subject column. If yes I need to return that word.

In addition if the string contains more than one subject from the table than I must check the ranking and return the value with the highest ranking. (1 lowest) So if the string contains 'hello cat, how -are you lion?' the sp must return the word lion.


How can I achieve this?




[Sql Server 2005] Need help to query with joins


Hi all :)

I hope anyone save me from madness ...

here is my query

                      t1.date, t1.employeeID, t2.name AS customer,

                     t3.description AS service, t4.total as amount

FROM            Trg_EmployeeCalendar AS t1 LEFT OUTER JOIN
                    EmployeeJobs AS t4 ON t1.employeeID = t4.employeeID AND t1.date = t4.date LEFT OUTER JOIN
                    Customers AS t2 ON t2.id_location = t4.locationID LEFT OUTER JOIN
                    ServiceCategory AS t3 ON t3.id_service = t4.serviceID LEFT OUTER JOIN

With this query, if an employee has two jobs in different l

Executing XML query from SQL 2005 pointing to SQL 2000 server

Occurs with root command.
Executed as user: DOMAIN\SERVER01. Error Code: 0  Error Source= ADODB.Command  Error Description: Item cannot be found in the collection corresponding to the requested name or ordinal.    Error on Line 18.  The step failed.
Executed as user: DOMAIN\SERVER01. Error Code: 0  Error Source= Microsoft OLE DB Provider for SQL Server  Error Description: Line 1: Incorrect syntax near 'ROOT'.    Error on Line 20.  The step failed.
Dim oCmd, sSQL, oDom
   Set oDom = CreateObject("Microsoft.XMLDOM")
   Set oCmd = CreateObject("ADODB.Command")
  oCmd.ActiveConnection ="Driver={SQL Native Client};Database=Validation;Server=server1;Uid=sa;Pwd=;"
   sSQL = "<?xml version=""1.0"" ?>"
   sSQL = sSQL &

SQL Server 2005 - How to Call One Store Proc from Other Store Proc ?


Hi ,

I have a Requirment, How can I called One Store Procedure from Other Store Procedure ?

After Calling to Other Store Proc, How can i Store that other Store Proc Result Sets in the Temp Table, So i can process in the Current Store Proc Result Sets ?



How to write a SQL query to present values horizontally sql server 2005

Suppose I have one table called Jobs:

    [JOBID] [int] IDENTITY(1,1) NOT NULL,
    [PARTDESC] [nvarchar](64) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    [OrderPlacedBy] [nvarchar](64) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [SpecialistName] [nvarchar](64) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    [Priority] [int] NOT NULL,
    [Symptoms] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    [CustomerNotes] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    [ShopNotes] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    [JobType] [nvarchar](32) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    [JobState] [nvarchar](32) COLLATE Latin1_General_CI_AS NULL,
    [JobAddedDate] [datetime] NOT NULL,
    [JobStartedDate] [datetime] NULL,
    [JobFinishedDate] [datetime] NULL,
    [JobShippedDate] [datetime] NULL,
    [RecievedDate] [datetime] NULL

I want to see the specialist name and his jobs IDs horizontally.

ANA 201,502,605,701,774
BEN 102,103,051
JEN 705,401,402,509,409,408

A s

Help converting an Acesss SQL query to SQL Server 2005 query


I am trying to convert this microsoft access query to sql 2005 query. Thank you for taking the time to look.

(This is taking a markup field (MultiplierCode) with a value like 1.45/1.5 and splitting into 2 numbers (1.45 would be the regular markup (based on the pay rate) and the 1.5 would be the overtime markup of the Bill Rate. Then updating orders and assignments based on that.)

UPDATE Order_Root INNER JOIN assignmentroot ON Order_Root.OrderID = assignmentroot.OrderID SET Order_Root.Bill = [order_root]![pay]*(Left([order_root]![MultiplierCode],(Len(Left([order_root]![MultiplierCode],InStr([order_root]![MultiplierCode],"/"))))-1)), Order_Root.OBillRate = [order_root]![pay]*(Left([order_root]![MultiplierCode],(Len(Left([order_root]![MultiplierCode],InStr([order_root]![MultiplierCode],"/"))))-1))*(Right([order_root]![MultiplierCode],Len([order_root]![MultiplierCode])-InStr(1,[order_root]![MultiplierCode],"/"))), Order_Root.DBillRate = [pay]*(Left([order_root]![MultiplierCode],(Len(Left("order_root]![[MultiplierCode]",InStr([order_root]![MultiplierCode],"/"))))-1)*2), assignmentroot.BillRate = [payrate]*(Left([order_root]![MultiplierCode],(Len(Left([order_root]![MultiplierCode],InStr([order_root]![MultiplierCode],"/"))))-1)), assignmentroot.OBillRate = [payrate]*(Left([order_root]![MultiplierCo

SQL Server 2005/2008 Query Monitoring via DMVs


My understanding is that sys.dm_exec_query_stats is for archive aggreated query statistics so I’ve been using the query below to monitor active long running queries and it works fine for single statements – however it seems to return hugely inflated total_elapsed_time values with some procs or functions where multiple statements are run. I’m also interested if anyone know how to find query completion times from DMVs?


Select …<some columns>
FROM sys.dm_exec_requests er
CROSS APPLY sys.dm_exec_sql_text(er.sql_handle) as st
INNER JOIN sys.dm_exec_sessions AS es
ON es.session_id = er.session_id
INNER JOIN sys.dm_exec_connections AS ec
ON ec.session_id = es.session_id
where er.total_elapsed_time / 1000.0 > @ElapsedThreshold
ORDER BY er.total_elapsed_time DESC;

search a string in SQL Server 2005.



I have SQL Server 2005 installed. I want to search a string (phone number) in my DB. I don't know the string is stored in which DB,which table, or even which column. All I know is the string. I don't want to export the DB to excell. It seems that 2005 can't generate a script with script data. What shall I do? Could you pleasae give me a T-SQL or something so that I can run it to search the string?

Best Regards,


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend