The following command works ok: create default [Zero] as 0
but the command: if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Zero]') and OBJECTPROPERTY(id, N'IsDefault') = 1) create default [Zero] as 0
returns: Server: Msg 156, Level 15, State 1, Line 3 Incorrect syntax near the keyword 'default'.
Env: Microsoft SQL Server 2000 - 8.00.194 (Intel X86) Standard Edition on Windows NT 5.0 (Build 2195: Service Pack 4)
Hi I want to create a table with one column, which is a identitycolumn.Let's say like this:CREATE TABLE DefaultTable(N int identity(0,1))Then I want to fill this table with 15,000,000 records, so that I havea table with the numbers 0 to 14,999,999.How can I do this as fast as possible. A standard INSERT would take along time.(It can be a temp table or a table variable. I just need a list withnumbered 0 to 15,000,000)Thank you.Gidon
I went ahead and installed RS even though it was clear Microsoft install was confused (re: preivous post). Now I get to experience the thrill of configuration hell.
Report Server Virtual Directory had a green check. Unfortunately the Name block says <Not Set>. When I try to create a New... default directory I get the error message: "The virtual directory could not be created. The previously set virtual directory will still be used."
Does anyone know where the <Not Set> virtual directory is stored on the computer?
addl info:
ReportServicesConfigUI.WMIProvider.WMIProviderException: The virtual directory specified already exists. Specify a different name.
at ReportServicesConfigUI.WMIProvider.RSReportServerAdmin.CreateVirtualDirectory(String virtualDirectory, String path)
I'm trying to create a login in the default domain. I know I can pullthis information from xp_loginconfig, but don't see how I can use it inthe context of sp_grantlogin.For example, pull the domain the user is currently logged in on andinsert it into the sp_grantlogin script. Has anyone ever done this inthe past?
This is for SQL2k5. The database may be small or big, I don't know (it's going out to multiple customers). I'm wondering if in general it's considered "better" to create a single non-primary default filegroup and put all the objects there, or just leave everything in primary? In one training years back I got the impression that recovering the primary filegroup was important for certain restore operations, so it was always wise to separate them like this.
I have a website I'm ready to test on the server it will call home. I just got connected to the remote SQL server that it will be using. As I've been creating the site, I've been using the default SQL Express set-up in Visual Studio. Is there a way to have Visual Studio create all those default tables, procedures, etc. OR is there a way to copy all of that stuff from the SQL Express running on my machine to the remote SQL Server 2005? -Mathminded
I've never had to do this, but when I downloaded the Web Workflow Approvals Starter Kit, it requested that I install the database into a User Instance of .SQLEXPRESS.
Now the problem is, I've installed it onto a default instance, so I was wondering whether you can create a named instance on top of a default instance... and if so, how would you do that?
For reasons that are not relevant (though I explain them below *), Iwant, for all my users whatever privelige level, an SP which createsand inserts into a temporary table and then another SP which reads anddrops the same temporary table.My users are not able to create dbo tables (eg dbo.tblTest), but arepermitted to create tables under their own user (eg MyUser.tblTest). Ihave found that I can achieve my aim by using code like this . . .SET @SQL = 'CREATE TABLE ' + @MyUserName + '.' + 'tblTest(tstIDDATETIME)'EXEC (@SQL)SET @SQL = 'INSERT INTO ' + @MyUserName + '.' + 'tblTest(tstID) VALUES(GETDATE())'EXEC (@SQL)This becomes exceptionally cumbersome for the complex INSERT & SELECTcode. I'm looking for a simpler way.Simplified down, I am looking for something like this . . .CREATE PROCEDURE dbo.TestInsert ASCREATE TABLE tblTest(tstID DATETIME)INSERT INTO tblTest(tstID) VALUES(GETDATE())GOCREATE PROCEDURE dbo.TestSelect ASSELECT * FROM tblTestDROP TABLE tblTestIn the above example, if the SPs are owned by dbo (as above), CREATETABLE & DROP TABLE use MyUser.tblTest while INSERT & SELECT usedbo.tblTest.If the SPs are owned by the user (eg MyUser.TestInsert), it workscorrectly (MyUser.tblTest is used throughout) but I would have to havea pair of SPs for each user.* I have MS Access ADP front end linked to a SQL Server database. Forreports with complex datasets, it times out. Therefore it suit mypurposes to create a temporary table first and then to open the reportbased on that temporary table.
Hi, Does anyone have a workaround or know of a fix to this problem: Default value set to 'date pick' from date currently within field by setting value equal to that field . ie if date is 01/01/2010 date picker opens in Jan 2010 - works ok. However, once published to Sharepoint and run through browser the Date Picker ignores the default value and the date picker opens for today. ie April 2008.
I'm trying to create a proc for granting permission for developer, but I tried many times, still couldn't get successful, someone can help me? The original statement is:
I created a cursor that moves through a table to retrieve a user's name.When I open this cursor, I create a variable to store the fetched name to use within the BEGIN/END statements to create a login, user, and role.
I'm getting an 'incorrect syntax' error at the variable. For example ..
CREATE LOGIN @NAME WITH PASSWORD 'password'
I've done a bit of research online and found that you cannot use variables to create logins and the like. One person suggested a stored procedure or dynamic SQL, whereas another pointed out that you shouldn't use a stored procedure and dynamic SQL is best.
Can I dynamically (from a stored procedure) generatea create table script of all tables in a given database (with defaults etc)a create view script of all viewsa create function script of all functionsa create index script of all indexes.(The result will be 4 scripts)Arno de Jong,The Netherlands.
I have some code that dynamically creates a database (name is @FullName) andthen creates a table within that database. Is it possible to wrap thesethings into a transaction such that if any one of the following fails, thedatabase "creation" is rolledback. Otherwise, I would try deleting on errordetection, but it could get messy.IF @Error = 0BEGINSET @ExecString = 'CREATE DATABASE ' + @FullNameEXEC sp_executesql @ExecStringSET @Error = @@ErrorENDIF @Error = 0BEGINSET @ExecString = 'CREATE TABLE ' + @FullName + '.[dbo].[Image] ( [ID][int] IDENTITY (1, 1) NOT NULL, [Blob] [image] NULL , [DateAdded] [datetime]NULL ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]'EXEC sp_executesql @ExecStringSET @Error = @@ErrorENDIF @Error = 0BEGINSET @ExecString = 'ALTER TABLE ' + @FullName + '.[dbo].[Image] WITHNOCHECK ADD CONSTRAINT [PK_Image] PRIMARY KEY CLUSTERED ( [ID] ) ON[PRIMARY]'EXEC sp_executesql @ExecStringSET @Error = @@ErrorEND
I'm new to using SSIS and have been reading and learning slowly how to use it. I'm trying to create an identical copy of our database for reporting. I've used the Import/Export wizard, but have had some issues with foreign keys and with sql_variant columns.
I've tried searching for anything but haven't had any luck as of yet. I guess I don't even know where to start or what to look for.
Hi Minor and inconsequential but sometimes you just gotta know: Is it possible to define a non-primary key index within a Create Table statement? I can create a constraint and a PK. I can create the table and then add the index. I just wondered if you can do it in one statement. e.g. I have: CREATE TABLE MyT (MyT_ID INT Identity(1, 1) CONSTRAINT MyT_PK PRIMARY KEY Clustered, MyT_Desc Char(40) NOT NULL CONSTRAINT MyT_idx1 UNIQUE NONCLUSTERED ON [DEFAULT])which creates a table with a PK and unique constraint. I would like (pseudo SQL):CREATE TABLE MyT (MyT_ID INT Identity(1, 1) CONSTRAINT MyT_PK PRIMARY KEY Clustered, MyT_Desc Char(40) NOT NULL CONSTRAINT MyT_idx1 UNIQUE INDEX NONCLUSTERED ON [DEFAULT]) No big deal - just curious :D Once I know I can stop scouring BOL for clues. Tks in advance
Just a quick one. I have some create scripts that were created for mysql and i am wanting to convert them to a
SQL Server create script. I am just wondering if anyone knows of any utilities or codeplex projects, etc that can perform the convert process.
The script is fairly basic but it is not fully compatible but i have a lot of them thus why i want to automate the process. The majority of the script is just table create statements like the following:
Code Snippet -- ----------------------------------------------------- -- Table `dbo`.`Staff` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `dbo`.`Staff` ( `StaffId` INT NOT NULL AUTO_INCREMENT , `IndividualId` INT NOT NULL DEFAULT 0 , `PositionId` INT NOT NULL DEFAULT 0 , `EmploymentStartDate` DATETIME NULL , `EmploymentEndDate` DATETIME NULL , `SupervisorStaffId` INT NULL , `TerminatedEmploymentReasonId` INT NULL , `DeletedFl` BIT NOT NULL , `CreateDateTime` DATETIME NOT NULL , `CreateUserId` INT NOT NULL , `ChangeUserId` INT NOT NULL , `ChangeDateTime` DATETIME NOT NULL , `VersionNum` INT NOT NULL , PRIMARY KEY (`StaffId`) , INDEX Individual_Staff_IndividualId_Ref (`IndividualId` ASC) , INDEX Lookup_Staff_PositionId (`PositionId` ASC) , INDEX Staff_Staff_SupervisorStaffId_Ref (`SupervisorStaffId` ASC) , INDEX Lookup_Staff_TerminatedEmploymentReasonId (`TerminatedEmploymentReasonId` ASC) , CONSTRAINT `Individual_Staff_IndividualId_Ref` FOREIGN KEY (`IndividualId` ) REFERENCES `dbo`.`Individual` (`IndividualId` ) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `Lookup_Staff_PositionId` FOREIGN KEY (`PositionId` ) REFERENCES `dbo`.`Lookup` (`LookupId` ) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `Staff_Staff_SupervisorStaffId_Ref` FOREIGN KEY (`SupervisorStaffId` ) REFERENCES `dbo`.`Staff` (`StaffId` ) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `Lookup_Staff_TerminatedEmploymentReasonId` FOREIGN KEY (`TerminatedEmploymentReasonId` ) REFERENCES `dbo`.`Lookup` (`LookupId` ) ON DELETE NO ACTION ON UPDATE NO ACTION);
Thanks for the help
Anthony
Note: i know if you have a mysql database you can go from one to the other, but i specifically need to take these mysql create scripts and convert them to sql server create scripts and there are a LOT of them i.e. more than 1000 script files that each contains a couple of hundred table create statements.
I've tried those two operations in the Management Studio. Though we can create a mining structure and mining model in Management Studion, but we cannot process the analysis-service database.
(1) I create only a mining structure through CREATE MINING STRUCTURE. No error reported. But if I process the analysis-service database in Management Studio I always get error
'Error : The '<mining_structure__name>' structure does not contain bindings to data (or contain bindings that are not valid) and cannot be processed.
I then tried to create it by creating and running an XMLA script. It was successful. However, it's much harder to learn XMLA.
If any of you created an analysis-service database in Mgt Studio, and create a mining structure in the same place using DMX script, can you process the database?
(2) Is there any use of CREATE MINING STRUCTURE operation without binding to any table? Examples I saw so far did not show relating it to do. In my experience processing the analysis-service database with that mining structure is doomed to fail.
(3) Is there any way we can create mining structure through CREATE MINING
STRUCTURE operation in Management Studio and use RELATED TO clause
to bind it to any Relationship to an attribute column (mandatory only if it applies), indicated by the RELATED TO clause
(4) If this is the fact, is there any use of CREATE MINING STRUCTURE operation? If we use BI Dev Studio, it's much easier to use the wizard.
(5) I found I cannot create a mining model inside a mining structure through operation CREATE MINING MODEL. If you call that operation, you end up having a mining model and a mining structure with the same name. I found that in order to create a mining model inside a mining structure you have to call operation ALTER MINING STRUCTURE ADD MINING MODEL. Is it true this is the only way?
is it possible to give a default value for a column which is generated as a result of left outer join... when there is no value for a particular column it shows null is it possible to change give a default value based on its data type?
Hi, I'm creating a dynamic group of values using SELECT and UNION Example: (SELECT Description = 'Changed PhoneNumber from ' + @old_PhoneNumber + ' to ' + @PhoneNumber WHERE @PhoneNumber <> @old_PhoneNumber UNION ALL SELECT Description = 'Changed FaxNumber from ' + @old_FaxNumber + ' to ' + @FaxNumber WHERE @FaxNumber <> @old_FaxNumber UNION ALL SELECT Description = 'Changed EmailAddress from ' + @old_EmailAddress + ' to ' + @EmailAddress WHERE @EmailAddress <> @old_EmailAddress) The problem here is that SQL Server thinks "Description" is an int (by default probably) and gives me an error when I try to assign a string to it. I'm taking that information and using it as a field in a INSERT INTO ... SELECT statement, so I don't think I am able to use a DECLARE statement or if that would even work. Does anyone know how I can make it so that Description is always a varchar?
When creating a table the default value field how do I input a default value into this field so when the user does his input it is automatically displayed. I have a yes/no user defined data type and I want the default value to be no.
i want a defauld vaule in my query to come for each row(50 row)
say i have address table with column name,street1, state,pin but no column for city---
How do i return a query for each name(50 row) which has a default value of city as 'Miami' for all 50 rows the city name is not there in databse at all
I have database in sql server. One field called datesent, i would like to set the default value as now(), i just type in the default value in database design, it didn't work. Please help, many thanks.
Code: SELECT M.District, SUM(case when P.PropType = 'T' or M.Status = 'SA' then V.CurrentTaxable else 0 end), SUM(case when SUBSTRING(P.Code,1,1) = 'P' then V.CurrentTaxable else 0 end), SUM(case when P.PropType <> 'T' and M.Status <> 'SA' and SUBSTRING(P.Code,1,1) <> 0 then V.CurrentTaxable else 0 end)
[code]...
In other words, I am trying to sum 1 variable into 3 categories depending upon certain conditions. I have to explicitly negate all the conditions from the first 2 SUM's to simulate a default ending else condition. Is there any construct in SQL that will me to do the last SUM if the first 2 SUM's fail without all the negation conditions?