Hi There,I want to create a column that usto numbers upto a specified value, and the resets. I've tried using the identity column and then using DBCC CHECKIDENT, but this doesnt doesn't have the desired affect. Here's an example of what I'm after.AutoRow1234 -------- reset1234 --------resetAny help would be great, many thanksStuart
Hi! Let's say users of my app can build some reports based on a current database schema and my custom-database adapter will generate some SQL to get the right data. User can save his report template ( basically data needed to create SQL ) in some storage. Will it be better solution to generate stored procedure for such report and save stored proc to a database and their name with raport data so next time user needs this report it will use stored proc. Jarod
I am new to programming and sqlserver 2000. i use sql2000 as my database server...
I have a problem on auto-generating medicine codes. and i hope someone would help me with my script.
as you noticed i declared two variables (@id and @code). I am having a problem in generating @code... i would just like to create an autogenerated medicines_code from another field from another table (hosp_counter.counter_id)
here is how my medicines_code should look like ('MEDS34') "where 34 is from a counter_id in hosp_counter table...
but it only creates a medicines_code = 'M' (below is the result)
34(this is from counter_id)M(this is the autogenerated code)AUTOGENERATE11111010110012110010000000018/29/2007 11:29:46 AM1/1/19001/1/1900
here is my script in autogenerating medicine code...
I am using sybase aSE12.5. I have a table with only one column withdatatype char(2). when i query this table to select all the records, ishould get these records in the ascending order and they should be numbered, i.e, the o/p should look something like thiscolumn_name------ --------1 AB2 AC3 ADand so on.I cannot add an extra column and i need this to be done in a single query.--Message posted via http://www.sqlmonster.com
Hi All, I want to write a console application to send email. There is a Date field in the SQL Server and I need to send email 2 weeks before that date.I have no idea how to write a console application and make it work.Does anybody have code for this? If so please post it. Thanks a lot, Kumar.
I have a trigger for a table which stores email information generated from an ACCESS form. The trigger should send an auto email response to users who submitted an email to request for their password (we have forgetful users!). There is something wrong with my trigger because the auto email is sent out with a blank body... I will appreciate any advice!
Thank you!
My trigger: CREATE TRIGGER tr_SendPassword ON PIPEmail FOR INSERT AS DECLARE @Password varchar(100) DECLARE @EmailAddress varchar(100) DECLARE @message varchar(100) IF (select count(*) from inserted) = 1 BEGIN IF exists (SELECT * FROM inserted WHERE Subject = 'Forgot my password') BEGIN select @Password = 'We received an email request from you for your password. Your password for SAR Search is: ' + UserRole.Password, @EmailAddress = [User].Email from UserRole join inserted on UserRole.WindowsUser = inserted.WindowsUser join [User] on [User].WindowsUser = UserRole.WindowsUser
exec master.dbo.xp_sendmail @recipients=@EmailAddress, @subject='SAR Search password request', @message=@Password END END
I want to send auto email to my subscribers(no. of subscribers always vary) This auto email has to be send daily. Could it be done by generating certain Stored Procedure ? if yes then please help me by providing Stored Procedure.
I have below code which send email from SQL Table "testing$" with use of store procedure but I am not getting any email, please check where is the error and if I run below code as query then it give me expected result but mail not received,
I would like some help conceptualizing how to acomplish this task. My client has requested the ASP.NET web/SQL Server application send an email to one of our locations based on whether that location complied (via the web app) to each week's report. Here's how the flow would go: The location checks the webpage weekly and selects their compliance to each record on the report. (They could overlook one of the records and not make a selection.) The SQL db would then query the compliance table and create a report of those locations with at least one "non-compliance." Then the Db would send a reminder email to each location on that report. The Db tables have the email address info assigned to each location, so I can join that to the compliance log table. Can this be done? I am using SQL Server Management Studio Express and Visual Web Developer (VB.net). Thank you for your ideas,SMc
Hi Experts, I have a table with fields: remindWHO remindWHEN remindWHATsomeone@test.com 6/20/05 do blah blah I want SQL Server Agent automatically run every morning at 1:00 AM, check against "remindWHEN" date, if match with current date, send out email to "remindWHO" for what they need to do in "remindWHAT" I was told this can be done by using the "Jobs" feature under SQL Server Agent to do this, but I don't know how to write Transact-SQL-Script under "Job Step". Please help me. Or any better alternative?I appreciate for any help.
Hi, I wrote the following function in an ActiveX script task in the database transformation. When I sent it to my own email address, it sent out the message fine, but when I change it to "SP Directors" which is a distribution list, and execute this step, it gave the error stated: "ActiveX Scripting encountered a Run Time Error during the execution of the script." Any one can help me on this problem, thank you so much in advance.
'Name or IP of Remote SMTP Server objMessage.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.iparty.com"
'Server port (typically 25) objMessage.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
hi there, i m newbie in using the ms sql server.i wouldlike to learn how to write the store procudure.i hope u all can guide me on this. i have one table with data appid int (PK) leaveappid int (FK) firstapproval int firstapproval email varchar, 2nd approval int 2nd approval email varchar resutl firstapproval result secondapproval. i would like to do a automatic send mail function where: the first mail will send to the firstapproval email.if after 2 days, the firstapproval no response(the result firstapproval is empty) then the email will automatic send to the second approval. how can i write the SP for this case? i really have no idea to start since i duno how to write the SP syntax and dont have the concept too. hope can hear from u all soon. thanx
I have to send updated Employee list from employee master table to a particular email ID on every last date of Month and when a new employee is added / deleted / edited. Also need to send this as an Excel file
I tried the following but "Invalid Object name dbo.tbl_EmployeeMaster" error coming while inserting a new employee.
USE [eXact] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER TRIGGER [dbo].[trg_Email]
Since upgrading from SQL Server Management Studio 2008 R2, I've noticed that it no longer autosaves queries that have not been manually saved first. If a file has been manually saved the autorecover files end up in the following directory:
%appdata%MicrosoftSQL Server Management Studio11.0AutoRecoverDatSolution1
However, I have ended up in the situation where I have unsaved queries when my computer has crashed and have not been able to recover them.
I have also found references to .sql files stored in temp files in the following directory, but the files here seem to be very haphazardly caught:
I have an MS SQL Server table with a Job Number field I need this field to start at a certain number then auto increment from there. Is there a way to do this programatically or within MSDE?
I have a report that gets sends out through a subscription and sometimes the report has multiple pages and all those pages appear within one email.Is it possible to set the subscription in such a way that an email is sent per page when the subscription executes.
Under IIS SMTP I can set bounced email redirect etc. how to do that with dbmail, the idea is I can get the list of bounced emails somewhere so I can create a report.
what I want to achieve is to load a text file that has email addreses from disk and using the email addresses in the text file look it up against the email addresses in the database table then once matched delete all the users in the table whose email address were in the text file.
I also want to update some users using a different text file.
I am developing a ASP.NET application using SQL Server as my database. I want to create a number that is unique.
The number will have 8 digits.
first 2 digits correspond to year. ex:04 or 03
the next 6 digits start with 000001 and it should get added for each new entry of data.
i am not able to generate number in the way i said. I am relatively new to SQL. so any suggestions as how to go about solving the problem???. Are there any samples/codes available for this.
I have generated an SQL script such that when it is run, it will automatically create tables if not existing or drop the existing tables. The problem I have is that, is there any way I can also make the script create not only the tables but also transfer the data from the old database to the new database?
I would really appreciate if any of you could point me to any existing programs, scripts etc that can do that. Thanks in advance
Is there a way to generate SQL Scripts from a stored procedure?
For disaster recovery and documenation reasons, we'd like to create scripts of our databases periodically. I, being somewhat lazy, would like to automate this so I really don't have to remember to run this every so often.
I am unable to see how to generate a leading zero.
Table A
declare @TableA table ( ID numeric , Fruits varchar(10) ) insert @TableA select 1,'Oranges' union all select 2,'Mangoes' union all select 3,'Apricots'
ID Table A 1 Apples 2 Oranges 3 Grapes 4 Apricots
declare @TableB table ( seed numeric , ) insert @TableB select 080513000448 union all select 080513000449 union all select 080513000450
Table B seed 080513000448 080513000449 080513000450
I wrote the following query but i need generate a leading zero not sure which function can help maybe the right function but i am not sure how to use it in this case
SELECTconvert(varchar(10), getdate(), 12) + (SELECT CASE WHEN SUBSTRING(ISNULL(max(seed),'00000'),1,6) = convert(varchar(10), getdate(), 12) THEN SUBSTRING(ISNULL(max(seed),'00000'),7,12) ELSE '000000' END AS SEED FROM B) + (row_number() over (order by Id)) as SEED FROM A
A simple question! I would like to create a database that creates say serial numbers and saves them to a table. If poss I would like to create them on demend and not duplicate.....
Can anyone suggest a case-study/reference links/video demos for creating a cube using Analysis Services and generation of reports using Reporting Services.
Help again please,I need to insert rows into a table from another table. The tables areidentical column wise except the table im inserting from does not havea primary key value. On insert I need to generate a primary key thatis consecutive based on the table im inserting into. Also the table iminserting into does not have a identity column. Much appreciated.