Reputation: 11694
I am trying to generate random data for my sql server database. Ive created a stored procedure that takes length of string to be generated but the problem is that it wont allow me to call it inside the insert statement.
insert into table1 (varchar_data,int_data) value ((sp_GenerateRandomString 4),CAST(RAND() * 10 AS INT) % 6 + 1 )
also this is not working
insert into table1 (varchar_data,int_data) select ((sp_GenerateRandomString 4),CAST(RAND() * 10 AS INT) % 6 + 1 )
Upvotes: 1
Views: 2546
Reputation: 171774
You should use a user defined function instead of a stored procedure. A stored procedure cannot be used in expressions, but functions can.
A good introduction can be found here: http://www.sqlteam.com/article/user-defined-functions
Upvotes: 3