SELECT CAST(lotw AS varchar(5)) + ' x ' + CAST(lotl AS varchar(5)) + ' / ' + CAST(lotsq AS varchar(6)) AS lotsqft FROM testTable
lotw, lotl, lotsq are all of type int. Is it possible for sql server to format them in a number format:
LIke This ------------------------ lotsqft ------------------------ 400 x 50 / 20,000 50 x 50 / 2,500 2,000 x 1,850 /3,700,000 ========================
NOT LIke This ------------------------ lotsqft ------------------------ 400 x 50 / 20000 50 x 50 / 2500 2000 x 1850 /3700000 ========================
Thanx for your help, I do hope I did not stump you, lol.
Is there any way can I get the 'SELECT' query result in table format? I want to email the query result so that they can read it very easily. Thank you, Gish
Hi guys n gals ! I am having a few problems manipulating the results of my data reader,To gather the data I need my code is: // database connection SqlConnection dbcon = new SqlConnection(ConfigurationManager.AppSettings["dbcon"]); // sql statement to select latest news item and get the posters name SqlCommand rs = new SqlCommand("select * from tblnews as news left join tblmembers as members ON news.news_posted_by = members.member_idno order by news.news_idno desc", dbcon); // open connection dbcon.Open(); // execute SqlDataReader dr = rs.ExecuteReader(); // send the data to the repeater repeater_LatestNews.DataSource = dr; repeater_LatestNews.DataBind(); Then I am using: <%#DataBinder.Eval(Container.DataItem, "news_comments")%> in my repeater.What I need to do is pass the "news_comments" item to a function I created which will then write the result. The code for my function is: // prevent html public string StripHtml(string data) { // grab the data string theData = data; // replace < with &alt; theData = Regex.Replace(theData, "<", "<"); // return result return theData; } But I am having problms in doing this,Can anyone point me in the right direction on what I should be doing ???
Has anyone every seen this error message? If so, what caused it?
Server: Msg 515, Level 16, State 2, Procedure sp_helpdb, Line 53 Cannot insert the value NULL into column '', table ''; column does not allow nulls. INSERT fails. The statement has been terminated.
Hi all, I am using ASP.NET 2003 with SQL Server as database. I have a database of a book store with BookPicture, Author, Title, and Description of the Book. Now when the user searchers for a book with a keyword, how can I display the results which should show: 1. The picture of the book, 2. The at it right, Title of Book, 3. The author,4. The descritionThen the image of "Add to cart" Each search result must be separated by a box like the cell of a table. Is it possible to be done? Thanking you in advance Tomy
i use sp_helpdb on one of my databases everyday to estimate growth. 3 days in a row now i get the same results how could this be every day there are about 30000 record that gets inserted to my tables inside the db. should the information changed since it is growing in size ?
Well i have been using sp_helpdb 'mydatabasename' to get the info for 3 consecutive days now and it returns the same result every day in KB for data files and in MB overall database size. Wich is kinda impossible since this is a warehouse and there are about 30000 records insert every night what is going on. plz help
Hi, I have MOM 2005 installed to monitor all our sql servers. In one of the sql server on a specific db, I get error alerts when running the sp_helpdb error.
The error output is
"Server: Msg 515, Level 16, State 2, Procedure sp_helpdb, Line 53 Cannot insert the value NULL into column '', table ''; column does not allow nulls. INSERT fails. The statement has been terminated."
I checked the sp_helpdb stored procedure and here is where it fails:
insert into #spdbdesc (dbname, owner, created, dbid, cmptlevel) select name, suser_sname(sid), convert(nvarchar(11), crdate), dbid, cmptlevel from master.dbo.sysdatabases where (@dbname is null or name = @dbname)
I understand this is a temporary table created by the stored procedure to insert all the db info.
I ran a query as follows:
select name, suser_sname(sid), crdate, dbid, cmptlevel from master.dbo.sysdatabases
The output is
DB Name User Name Cr date db id cmpt master sa2000-08-06 01:29:12.250180 model sa2000-08-06 01:40:52.437380 msdb sa2000-08-06 01:40:56.810480 RMSummaryNULL2002-06-13 16:40:32.203880 tempdb sa2005-11-29 19:10:48.450280
The problem is in RMSummary database and the "dbo" login does not have a username.
How do I add a User Name "sa" to the DB Owner "dbo" for the RMSummary database?
I did try the following things with no success:
1. Try to delete the 'dbo' user in 'RMSummary' database so that I can add a new login name as 'dbo' and username is 'sa'. Error message is 'dbo' owns some objects and does not get deleted. 2. I tried sp_changedbowner but it does not work either.
I have a strange question and hope someone can shed some light on theproblem.First let me give you my scenario. We are using doubletake to replicate ourdatabase server files between the local site and off site. I will namethese servers srv1a (local) and srv1b (remote). It now time to move to newservers. These servers will be srv2a (local) and 2b (remote).Currently srv1a replicates to srv1b. The sqlserver service is off on srv1b.It is only replicating the database files. Works great.Now the problem. srv1a and srv1b have all the logs and data files on thed: drive. On the new servers (2a and 2b) we will place the log files one: and the data files on f:. This is the case for all databases exceptthe system databases, which will reside all ldf and mdf on f:.In order to move to the new servers, as a test we began replicating to srv1ato svr2a. It placed all the system dbs on srv2a d: drive and all otherfiles in the new structure (e: and f:). There is some work that you mustdo to move the master, msdb, model, and temp to the new location (change thestartup parameters and detaching and reattaching some other databases). Allthis works great and we have everything up and running.As part of a sanity check, I ran the following statementsselect name, filename from master..sysdatabases where name = 'master'GOexec sp_helpdb master.GOresults arename filenamemaster d:Microsoft SQLServerMSSQLdatamaster.mdf(1 row(s) affected)name db_size owner dbid createdmaster 22.00 MB sa 1 Aug 6 2000 Status=ONLINE,name fileid filenamefilegroup size maxsize growth usagemaster 1 F:Microsoft SQL Server DataMSSQLDatamaster.mdfPrimary 19072 KB Unlimited 10% data onlymastlog 2 F:Microsoft SQL Server DataMSSQLDatamastlog.ldfNULL 3456 KB Unlimited 10% log onlyIf you notice that sysdatabases table is showing the master files on D: butsp_help is showing on F: F: is the correct location. Also my startparameters is-dF:Microsoft SQL Server DataMSSQLDatamaster.mdf-lF:Microsoft SQL Server DataMSSQLDatamastlog.ldf-eF:Microsoft SQL Server DataMSSQLDataERRORLOGAny ideas why the two are not showing the same thing? Everything is workingfine and all other databases (sp_helpdb) is correct and sp_helpfile masteris showing the same thing as sp_helpdb master. Since I though sp_helpdb wasquerying sysdatabases, I am confused as to why this is happening.Any help would be greatly appreciated. Sorry for the long post.
I want to do a 'select db_size from sp_helpdb where name = @DB;' The problem is that SQL doesn't interpret sp_helpdb as a table :-( How can I query the result of this stored procedure?
Hi friends, I want to select only filename column of sp_helpdb's output.But I don't know how should I do this? Other way is doing a direct select from sysfiles or sysdatabases but as you know microsoft doesn't recommand this way. Also I can select that filed in my application level but it is strange for me: Of course sql server should has a proper way to do a select from output curosr of this procedure,Doesn't it? -Thanks in advance
When I run sp_helpdb against the master (or any other DB for that matter) I get the following error:
Server: Msg 515, Level 16, State 2, Procedure sp_helpdb, Line 53 Cannot insert the value NULL into column 'owner', table 'tempdb.dbo.#spdbdesc_ 0010001A6EF'; column does not allow nulls. INSERT fails. The statement has been terminated.
I have about 20 DBs on a SQL Server 2000 Standard Edition Instance with sp3a .
There have been no changes made to the Server or the SQL Server Instance in quite some time. Can anyone tell me how I should proceed??????
Hi,One of our customers claims that the sp_helpdb truncates database namelarger than 24 characters, the release is 7.00.1094, did any oneencounter such a problem ???
I'm trying to create an email report which gives a result of multiple results from multiple databases in a table format bt I'm trying to find out if there is a simple format I can use.Here is what I've done so far but I'm having troble getting into html and also with the database column:
I need to send the result of a procedure to an update statement.Basically updating the column of one table with the result of aquery in a stored procedure. It only returns one value, if it didnt Icould see why it would not work, but it only returns a count.Lets say I have a sproc like so:create proc sp_countclients@datecreated datetimeasset nocount onselect count(clientid) as countfrom clientstablewhere datecreated > @datecreatedThen, I want to update another table with that value:Declare @dc datetimeset @dc = '2003-09-30'update anothertableset ClientCount = (exec sp_countclients @dc) -- this line errorswhere id_ = @@identityOR, I could try this, but still gives me error:declare @c intset @c = exec sp_countclients @dcWhat should I do?Thanks in advance!Greg
I have an Execute SQL Task that executes "select count(*) as Row_Count from xyztable" from an Oracle Server. I'm trying to assign the result to a variable. However when I try to execute I get an error: [Execute SQL Task] Error: An error occurred while assigning a value to variable "RowCount": "Unsupported data type on result set binding Row_Count.".
Which data type should I use for the variable, RowCount? I've tried Int16, Int32, Int64.
---------------------------------------------------------------------- I executed it in my SQL Server Management Studio Express and I got: Commands completed successfully. I do not know where the result is and how to get the result viewed. Please help and advise.
HI, I ran a select * from customers where state ='va', this is the result...
(29 row(s) affected) The following file has been saved successfully: C:outputcustomers.rpt 10826 bytes
I choose Query select to a file then when I tried to open the customer.rpt from the c drive I got this error message. I am not sure why this happend invalid TLV record
As the topic suggests I need the end results to show a list of shows and their dates ordered by date DESC. Tables I have are structured as follows:
SHOWS showID showTitle
SHOWACCESS showID remoteID
VIDEOS videoDate showID
SQL is as follows:
SELECT shows.showID AS showID, shows.showTitle AS showTitle, (SELECT MAX(videos.videoFilmDate) AS vidDate FROM videos WHERE videos.showID = shows.showID) FROM shows, showAccess WHERE shows.showID = showAccess.showID AND showAccess.remoteID=21 ORDER BY vidDate DESC;
I had it ordering by showTitle and it worked fine, but I need it to order by vidDate. Can anyone shed some light on where I am going wrong?
I am trying to code a WHERE xxxx IN ('aaa','bbb','ccc') requirement but it the return values for the IN keyword changes according to another column, thus the need for a CASE function.
WHERE GROUP.GROUP_ID = 2 AND DEPT.DEPT_ID = 'D' AND WORK_TYPE_ID IN ( CASE DEPT_ID WHEN 'D' THEN 'A','B','C' <---- ERROR WHEN 'F' THEN 'C','D ELSE 'A','B','C','D' END )
I kept on getting errors, like
Msg 156, Level 15, State 1, Line 44Incorrect syntax near the keyword 'WHERE'. which leads me to assume that the CASE ... WHEN ... THEN statement does not allow mutiple values for result expression. Is there a way to get the SQL above to work or code the same logic in a different manner in just one simple SQL, and not a procedure or T-SQL script.
I'm using a subquery to return a delivery charge line as a column in the result set. I want to see this delivery charge only on the first line of the results for each contract. Code and results are below.
declare @start smalldatetime declare @end smalldatetime set @start = '2015-03-22 00:00' -- this should be a Sunday set @end = '2015-03-28 23:59' -- this should be the following Saturday
In this example, I only want to see the delivery charge of 125.00 for the first line of contract HU004377. For simplicity I have only shown the lines for 1 contract here, but there would normally be many different contracts with varying numbers of lines, and I only want to see the delivery charge once for each contract.
I have created SSRS report which has many overlapping objects, the output in PDF format seems to good but in word format it is not giving the required output.
I have date coming to one page as a string in the following format"May 4 2005 12:00AM" I need to query one of my tables using this date in combination of other nondate values. How can I convert this date into valid sql server datetime format before I query a database tables Please help
I have a table which stores date-of-birth in varchar 19861231(yyyymmdd). A view takes this data. I want to store this date as mmddyyyy in the view. How can we achieve this?
I have a set of csv files and a set of Format Specification files for each of the csv files. I need to convert the csv files into another format of csv files as specified in the Format Specification files. All the columns of the input csv files do not have a mapping with the columns of the output csv files. How can I achieve this using SSIS ? This is an urgent requirement. Please reply asap. Thanks.
I am stuck at one place, where I have to convert CSV format file data into SAP IDOC format file. In SSIS we don't have any such SAP adapter (though we have .NET Data Provider for mySAP suite [SSIS SAP Adapter] but this is still not fully supported by Microsoft, plus it doesn't have feature to convert data into IDOC format) that can do this. Can someone here please provide me some pointers on any third party adapters available in market to do this job or if anyone has already developed some custom approach to achieve this task?
Your quick response on this is highly appreciated.
dear all can anybody help me soon.... i am using visual studio 2005 webapplication based on sql server 2005 database. i can get one date from sql using one query. I am selecting my field based on following code CONVERT(varchar, Oman.Positions.Datum, 9) AS LastUpdate this case my output is May 4 2008 3:19:45:000AM..... this output is correct but from this output i want to avoid millisecond part. ie i want the output like May 4 2008 3:19:45 AM.... how i can do this regards